Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 77 additions & 65 deletions examples/app-showcase/e2e/detail-shapes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,33 @@ import { test, expect } from '@playwright/test';
* real-backend browser verification that closed objectui#2546 (PR4: legacy
* monolith detail renderer + `renderViaSchema` kill-switch removed).
*
* Four shapes, one invariant each, all through the single SchemaRenderer /
* `buildDefaultPageSchema` path the console now has:
* - grouped → fieldGroup sections render; `collapse: 'collapsed'`
* actually collapses (Money hides `budget` until opened)
* - ungrouped → flat details body, no section cards
* - stageField:false → NO `record:path` stepper despite a `status` field
* named to bait the heuristic
* Three shapes, all through the single SchemaRenderer /
* `buildDefaultPageSchema` path the console now has. The default record page
* draws no stage bar (`record:path`) and no key-field strip
* (`record:highlights`) — objectstack#35891 — so every case asserts both
* absent: the stage is the status tag beside the record's name, and
* `highlightFields` leaves every field in its group.
* - grouped → fieldGroup sections render, highlighted members
* included; `collapse: 'collapsed'` actually collapses
* (Money hides `amount` and `budget` until opened); the
* header's stage tag reads `stageField: 'status'`
* - stageField:false → NO stage tag despite a `status` field named to bait
* the heuristic
* - related-heavy → related lists surface by prominence (ADR-0085), in the
* one-column stack tier (objectstack#27524): a
* `relatedList: 'primary'` list is a body table in the
* details (objectstack#27055, Target 8), the rest are
* panels of the right column below them and read their
* rows when they come into view
* details (objectstack#27055, Target 8) and takes no tab;
* the rest are tabs of the tab row (objectstack#35595),
* and one with records is a card of the 概览 tab's rail
* below the details (objectstack#35596)
*
* Runs against the console the backend serves at /_console (baseURL from
* playwright.config.ts; storageState carries the admin session). The
* semantic-zoo fixtures are objects but not seeded records — each run
* creates its own rows via the REST API.
*
* Assertions are scoped to what the *pinned* console build supports
* (.objectui-sha). The fb35e48 bump brought in objectui#2577, so the grouped
* case also pins the follow-up UX contract: highlight strip drops the record
* title, group icon/description render, and currencyConfig money shows its
* symbol.
* The grouped case also pins objectui#2577's UX contract: group
* icon/description render, and currencyConfig money shows its symbol.
*/

// Ambient `process` for the env reads below — the showcase tsconfig doesn't pull
Expand All @@ -44,6 +47,9 @@ const recordUrl = (object: string, id: string) =>
`/_console/apps/${APP}/${object}/record/${encodeURIComponent(id)}`;

const PATH_STEPPER = '[aria-label="Record path"]';
const HIGHLIGHT_STRIP = 'section[aria-label="Record highlights"]';
/** The header's stage tag, plain or as its menu, carries the field it reads. */
const stageTag = (field: string) => `[data-record-stage-tag="${field}"]:visible`;

let zooId = '';
let zooLegacyId = '';
Expand Down Expand Up @@ -95,24 +101,20 @@ async function openRecord(page: import('@playwright/test').Page, url: string) {
test('grouped: fieldGroup sections render and Money starts collapsed', async ({ page }) => {
const errors = await openRecord(page, recordUrl('showcase_semantic_zoo', zooId));

// Stepper from stageField: 'status'.
// record:path renders a desktop + a mobile variant — assert the visible one.
await expect(page.locator(PATH_STEPPER).first()).toBeVisible();

// objectui#2577: the record title is the page H1 — it must NOT repeat as a
// (truncated) chip in the highlight strip; status/amount still do.
const strip = page.locator('section[aria-label="Record highlights"]');
await expect(strip).toBeVisible();
const stripText = (await strip.innerText()).replace(/\s+/g, ' ');
expect(stripText, 'strip repeats the record title').not.toContain('E2E Zoo');
expect(stripText).toContain('4,200');

// Declared groups render as titled sections. Their highlighted members
// (status/amount) are hoisted to the strip; the non-highlighted members
// (code/budget) keep the groups visible in the body.
await expect(page.getByText('Basics', { exact: true })).toBeVisible();
await expect(page.getByText('Money', { exact: true })).toBeVisible();
await expect(page.getByText('ZG-1')).toBeVisible();
// objectstack#35891: no stage bar and no key-field strip. The stage
// (stageField: 'status') is the header's tag beside the record's name.
await expect(page.locator(PATH_STEPPER)).toHaveCount(0);
await expect(page.locator(HIGHLIGHT_STRIP)).toHaveCount(0);
await expect(page.locator(stageTag('status')).first()).toHaveText(/Active/);

// Declared groups render as titled sections, every member in its own
// group: the highlighted ones (status in Basics, amount in Money) are not
// taken out of them.
const details = page.locator('[data-record-column="details"]');
await expect(details.getByText('Basics', { exact: true })).toBeVisible();
await expect(details.getByText('Money', { exact: true })).toBeVisible();
await expect(details.getByText('ZG-1')).toBeVisible();
await expect(details.getByText('Status', { exact: true })).toBeVisible();

// objectui#2577: fieldGroups[].icon renders as a real (Lucide svg) icon in
// the section header — not as literal icon-name text.
Expand All @@ -130,10 +132,13 @@ test('grouped: fieldGroup sections render and Money starts collapsed', async ({
).toBeVisible();
await expect(page.getByText('banknote', { exact: true })).toHaveCount(0);

// collapse: 'collapsed' — Budget stays hidden until the header is opened.
await expect(page.getByText('Budget', { exact: true })).toHaveCount(0);
// collapse: 'collapsed' — Amount and Budget stay hidden until the header is
// opened; then both are in the Money group.
await expect(details.getByText('Budget', { exact: true })).toHaveCount(0);
await expect(details.getByText('4,200')).toHaveCount(0);
await page.getByText('Money', { exact: true }).click();
await expect(page.getByText('Budget', { exact: true })).toBeVisible();
await expect(details.getByText('Budget', { exact: true })).toBeVisible();
await expect(details.getByText('4,200')).toBeVisible();
// objectui#2577: fieldGroups[].description renders under the expanded
// header, and the fixed-mode currencyConfig.defaultCurrency (USD) drives a
// real $ symbol.
Expand All @@ -143,30 +148,33 @@ test('grouped: fieldGroup sections render and Money starts collapsed', async ({
expect(errors, 'uncaught page errors on grouped detail').toEqual([]);
});

test('stageField:false: status renders as a plain field, no stepper', async ({ page }) => {
test('stageField:false: status renders as a plain field, no stage tag', async ({ page }) => {
const errors = await openRecord(
page,
recordUrl('showcase_semantic_zoo_legacy', zooLegacyId),
);

// The whole point of `stageField: false`: the status-named select must NOT
// become a chevron path. (objectui#2168 pinned strict-false handling.)
// become the header's stage tag. (objectui#2168 pinned strict-false
// handling.) No stage bar or strip either, as on every default page.
await expect(page.locator('[data-record-stage-tag]')).toHaveCount(0);
await expect(page.locator(PATH_STEPPER)).toHaveCount(0);
await expect(page.locator(HIGHLIGHT_STRIP)).toHaveCount(0);
// …but the field itself still renders (as a value, not a lifecycle).
await expect(page.getByText('Green').first()).toBeVisible();

expect(errors, 'uncaught page errors on stageField:false detail').toEqual([]);
});

test('ungrouped + related-heavy: flat details and the related panels on Contoso', async ({ page }) => {
test('related-heavy: body tables, the tab row and the rail on Contoso', async ({ page }) => {
// The synthesized record page lays itself out by the width of the view it
// occupies, by one rule (objectstack#26678, objectstack#27524): details |
// the right column from `RECORD_PAGE_TWO_COLUMN_MIN_WIDTH` (760 px,
// `@object-ui/plugin-detail`), and ONE column below it — the details, then
// the right column's panels in their order. No tier draws a tab strip. The
// case stays in that stack tier on purpose: the column tiers are what every
// other page of this smoke draws at the Desktop Chrome viewport, and the
// stack is also what the split pane (720 px) and a phone draw.
// the 概览 tab's rail. The tab row (objectstack#35595) is drawn in every
// tier. The case stays in that stack tier on purpose: the column tiers are
// what every other page of this smoke draws at the Desktop Chrome viewport,
// and the stack is also what the split pane (720 px) and a phone draw.
//
// The window and the sidebar are derived, not picked. A collapsed console
// sidebar draws no icon rail from 768 px up — ruling 6973617688 on
Expand Down Expand Up @@ -195,21 +203,27 @@ test('ungrouped + related-heavy: flat details and the related panels on Contoso'
await page.getByTestId('sidebar-keep-open').click();
await expect(page.getByTestId('sidebar-keep-open')).toHaveAttribute('aria-pressed', 'true');

// Heuristic stepper (account.status is a select named "status").
// record:path renders a desktop + a mobile variant — assert the visible one.
await expect(page.locator(PATH_STEPPER).first()).toBeVisible();
// objectstack#35891: no stage bar, no key-field strip; the heuristic stage
// (account.status is a select named "status") is the header's tag.
await expect(page.locator(PATH_STEPPER)).toHaveCount(0);
await expect(page.locator(HIGHLIGHT_STRIP)).toHaveCount(0);
await expect(page.locator(stageTag('status')).first()).toBeVisible();

// One column and no tab strip: the details, then the right column.
// One column: the details, then the rail. The tab row opens on 概览.
await expect(page.locator('[data-record-page-tier]')).toHaveAttribute('data-record-page-tier', 'stack');
await expect(page.locator('[data-record-columns]')).toHaveAttribute('data-record-columns-shown', 'details');
await expect(page.getByRole('tab', { name: /Details|Related|Invoices|Projects/i })).toHaveCount(0);
await expect(page.locator('[data-record-tab="overview"]')).toHaveAttribute('aria-selected', 'true');

// Related lists surface by prominence (ADR-0085), as record page v3 draws
// them (objectstack#27055, Target 8): Invoices and Projects are
// `relatedList: 'primary'` (CORE relationships), so each is a body table in
// the details, with its rows read at open; the rest of Contoso's lists
// (Contacts and the Field Zoo lookups) are panels of the right column,
// before its last panel, 动态 (objectstack#34590).
// the details, with its rows read at open, and takes no tab of its own; the
// rest of Contoso's lists (Contacts and the Field Zoo lookups) are tabs, and
// one with records is a card of the rail (objectstack#35596).
// CONTROL for the absence below: an ordinary list's tab is drawn under the
// same `OBJECT.FIELD` id, so a renamed id scheme reds here, not silently.
await expect(page.locator('[data-record-tab="showcase_contact.account"]')).toHaveCount(1);
await expect(page.locator('[data-record-tab^="showcase_invoice."], [data-record-tab^="showcase_project."]')).toHaveCount(0);
const details = page.locator('[data-record-column="details"]');
const invoicesTable = details
.getByRole('table')
Expand All @@ -220,29 +234,27 @@ test('ungrouped + related-heavy: flat details and the related panels on Contoso'
await expect(invoicesTable.getByRole('cell', { name: 'INV-1002', exact: true })).toBeVisible();
await expect(projectsTable.getByRole('cell', { name: 'Data Platform', exact: true })).toBeVisible();
const rightColumn = page.locator('[data-record-column="right"]');
// objectstack#34590, ruling 6937542160 — 动态 last (supersedes objectstack#27524 Targets 5 and 8's 动态-first).
await expect(rightColumn.locator(':scope > *').last()).toHaveAttribute('data-record-timeline-panel', '');
await expect(rightColumn.getByRole('region', { name: /^(Invoices|Projects)$/ })).toHaveCount(0);

// Ungrouped shape: the details body is flat — no fieldGroup section cards.
// (Contoso declares no fieldGroups; spot-check a body field label.)
await expect(page.getByText('Basics', { exact: true })).toHaveCount(0);
// Contoso's own groups render in the details (ADR-0085 §5), its highlighted
// fields among their members.
await expect(details.getByText('Profile', { exact: true })).toBeVisible();

// objectui#2577 + currencyConfig: annual revenue renders with its symbol
// in the strip, and the meta footer doesn't dangle "Created by" on the
// actor-less seeded row.
await expect(page.getByText('$25,000,000', { exact: false }).first()).toBeVisible();
// objectui#2577 + currencyConfig: annual revenue (a highlighted field, left
// in its Profile group) renders with its symbol in the details, and the
// meta footer doesn't dangle "Created by" on the actor-less seeded row.
await expect(details.getByText('$25,000,000', { exact: false }).first()).toBeVisible();
const footer = page.locator('[data-testid="record-meta-footer"]');
await expect(footer).toBeVisible();
const footerText = (await footer.innerText()).replace(/\s+/g, ' ');
expect(footerText, 'footer dangles "Created by" without an actor').not.toMatch(/Created by/);
expect(footerText).toMatch(/Created/);

// A panel reads its rows once it is in view: below the details here, so
// the Contacts panel reads Contoso's seeded contacts when scrolled to.
const contactsPanel = rightColumn.getByRole('region', { name: 'Contacts', exact: true });
await contactsPanel.scrollIntoViewIfNeeded();
await expect(contactsPanel.locator('[data-related-card-row]').filter({ hasText: 'Carl Fox' })).toBeVisible();
// The rail's Contacts card summarizes the Contacts tab: its first rows,
// Contoso's seeded contacts among them.
const contactsCard = rightColumn.getByRole('region', { name: 'Contacts', exact: true });
await contactsCard.scrollIntoViewIfNeeded();
await expect(contactsCard.locator('[data-record-summary-row]').filter({ hasText: 'Carl Fox' })).toBeVisible();

expect(errors, 'uncaught page errors on related-heavy detail').toEqual([]);
});
8 changes: 6 additions & 2 deletions packages/cli/test/lint-strict-warnings.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ function expectVerdictKeys(run: Run, payload: Record<string, unknown>, label: st
/**
* One shape, four knobs. `engines` absent is one warning (`protocol/missing-
* engines-range`); a master_detail without `required` is a second; omitting
* its `deleteBehavior` / `inlineEdit` is two suggestions; an unknown list-view
* column is an error. Each fixture below turns the knobs it needs and no other.
* its `deleteBehavior` and the parent field group that places the line items
* (`relatedList`; the FK's `inlineEdit` only picks the form factor) is two
* suggestions; an unknown list-view column is an error. Each fixture below
* turns the knobs it needs and no other.
*/
function stack(
ns: string,
Expand All @@ -135,6 +137,7 @@ function stack(
const { engines = true, requireMaster = true, adviseMaster = true, unknownColumn = false } = opts;
const enginesLine = engines ? `engines: { protocol: '>=1' },` : '';
const masterAdvice = adviseMaster ? `deleteBehavior: 'cascade', inlineEdit: true,` : '';
const lineGroup = adviseMaster ? `fieldGroups: [{ key: 'lines', label: 'Lines', relatedList: '${ns}_line' }],` : '';
const masterRequired = requireMaster ? `required: true,` : '';
const columns = unknownColumn ? `'title', 'nope_missing'` : `'title'`;
return `
Expand All @@ -147,6 +150,7 @@ export default {
sharingModel: 'private',
fields: { title: { type: 'text', label: 'Title' } },
listViews: { all: { label: 'All', columns: [${columns}] } },
${lineGroup}
},
{
name: '${ns}_line',
Expand Down
12 changes: 7 additions & 5 deletions ui/e2e/live/form-view-subforms.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test';
import { selectOption, fillLookup } from './helpers';
import { addLineItem, selectOption, fillLookup } from './helpers';

/**
* Tier 0 live e2e: an object's standard New/Edit modal renders inline child
Expand All @@ -10,14 +10,15 @@
* lines in one atomic /api/v1/batch.
*
* This exercises the full modern grid:
* • the trailing "ghost" row — type straight into it, no "Add line" click;
* • "Add line" appends an editable row (the grid draws no blank entry row,
* objectstack#35507), and only the line that carries data is submitted;
* • a Product catalog typeahead whose selection auto-fills the line's
* description + unit_price (matching field names);
* • the computed read-only `amount = quantity × unit_price`, recomputed live
* and persisted in the batch (so the parent total rolls it up server-side).
*/
test('New <object> modal renders relationship-derived subforms and submits an atomic batch', async ({ page }) => {
const batches: any[] = [];

Check warning on line 21 in ui/e2e/live/form-view-subforms.spec.ts

View workflow job for this annotation

GitHub Actions / Lint UI

Unexpected any. Specify a different type
page.on('request', (r) => {
if (r.method() === 'POST' && r.url().includes('/api/v1/batch')) {
try { batches.push(r.postDataJSON()); } catch { /* ignore */ }
Expand All @@ -39,9 +40,10 @@
await selectOption(page, 'status', 'draft');
await expect(dialog.getByText('Northwind', { exact: false }).first()).toBeVisible();

// Pick a catalog product in the ghost row — its description + unit_price
// auto-fill, and the row materialises (no "Add line" click).
// "Add line", then pick a catalog product on the new row — its description
// + unit_price auto-fill.
const li = dialog.getByTestId('line-items');
await addLineItem(page);
await li.getByTestId('lookup-trigger').first().click();
const option = page.getByRole('option', { name: /Widget A/i }).first();
await option.waitFor({ state: 'visible' });
Expand Down Expand Up @@ -72,13 +74,13 @@
expect(ops[0]).toMatchObject({ object: 'showcase_invoice', action: 'create' });
expect(ops[0].data.name).toBe(name);
expect(ops[0].data.status).toBe('draft');
const child = ops.find((o: any) => o.object === 'showcase_invoice_line');

Check warning on line 77 in ui/e2e/live/form-view-subforms.spec.ts

View workflow job for this annotation

GitHub Actions / Lint UI

Unexpected any. Specify a different type
expect(child?.data?.invoice).toEqual({ $ref: 0 });
expect(child?.data?.product).toBeTruthy(); // the chosen product id
expect(child?.data?.description).toBe('Standard widget'); // auto-filled
expect(Number(child?.data?.unit_price)).toBe(29.99); // auto-filled
expect(Number(child?.data?.amount)).toBe(59.98); // computed (2 × 29.99)
expect(Number(child?.data?.position)).toBe(0); // sort position stamped from row order
// The empty ghost line must NOT have been persisted as a blank child.
// Exactly the one line that was added and filled is persisted.
expect(ops.filter((o: any) => o.object === 'showcase_invoice_line')).toHaveLength(1);

Check warning on line 85 in ui/e2e/live/form-view-subforms.spec.ts

View workflow job for this annotation

GitHub Actions / Lint UI

Unexpected any. Specify a different type
});
14 changes: 13 additions & 1 deletion ui/e2e/live/grid-conditional-rules.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect } from '@playwright/test';
import { addLineItem } from './helpers';

/**
* B2 in grids (A1): an inline line-item cell honors its column's `requiredWhen`
Expand All @@ -18,12 +19,23 @@ test('a line cell flags required per row from a row-scoped requiredWhen', async
const dialog = page.getByRole('dialog');
await expect(dialog.getByTestId('md-form-submit')).toBeVisible();

// The grid draws no blank entry row (objectstack#35507): a new invoice's
// grid is empty until "Add line" appends the row this case drives.
const grid = dialog.getByTestId('line-items');
await addLineItem(page);
const qty = grid.locator('input[aria-label="Qty"]').first();
await expect(qty).toBeVisible();

// Below threshold: a small qty leaves Description optional (no invalid flag).
// A line Add just appended reads no required cell red until a save of the
// form is tried (objectstack#35816, objectstack#35940), so try one: the
// header is empty, so it is refused, and from then on the line's verdicts
// are drawn. CONTROL: the line's always-required, still empty Product now
// reads red — the flags are live, so the absence below is a verdict.
await qty.fill('2');
await dialog.getByTestId('md-form-submit').click();
await expect(grid.getByTestId('line-items-invalid-0-product')).toBeVisible();

// Below threshold: a small qty leaves Description optional (no invalid flag).
await expect(grid.getByTestId('line-items-invalid-0-description')).toHaveCount(0);

// Cross the threshold: quantity >= 100 ⇒ Description (still empty) flags
Expand Down
Loading
Loading