Skip to content

Commit 5aee206

Browse files
test(ui): pin the direct-URL record form save and nav CEL visibility in Live E2E UI (#28034)
<!-- claude-projects-attribution: {"github_login":"os-bill"} --> _Requested by **Bill** · [project thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wg57ReKcW3wEma7daYWHXqAD)_ Fixes #27555 Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么**:必过检查 `Live E2E UI` 多了两个场景:按 URL 直接打开整页编辑表单、改标题、保存,要看到保存提示、留在应用内的记录页、经 API 回读到新值(#27454);应用导航项的裸字符串 `visible` 按 CEL 求值,为真显示、为假隐藏且不报错(#27457)。`list-row-action-cel.spec.ts` 从夜间清单移入必过清单。 - **为什么改**:这两个缺陷都是合并后才在浏览器里发现的,单元测试没拦住;现在真实前后端栈每个 PR 都会跑它们。 - **风险与回滚**:只动测试和 `ui/package.json` 的两条脚本清单,不改产品代码。本地 `Run the live e2e specs` 步骤从约 35 秒变成约 40 秒,远低于 #27550 的 2 分钟预算。回滚 = 把两个文件名移回 `test:e2e:live:nightly`(新文件删掉即可)。 - **先看**:`ui/e2e/live/record-form-direct-url.spec.ts`;`ui/e2e/live/list-row-action-cel.spec.ts` 的第二个用例;`ui/package.json` 两条脚本。 - **两分钟验证**:看本 PR 的 `Live E2E UI` 检查日志,`Run the live e2e specs` 步骤应列出 15 条全部通过,其中 3 条来自这两个文件,步骤耗时在 2 分钟内。 - **需要你做的**:无,席位落地。 ## What changes - **New `ui/e2e/live/record-form-direct-url.spec.ts` (#27454).** The test creates its own `showcase_task` through the data API (on a seeded project, `status: backlog`), opens `/apps/com.example.showcase/showcase_task/record/ID/edit` with `page.goto` (a fresh page, so the only earlier history entry is `about:blank`, the direct-URL entry the defect needs), renames the title, clicks Save and asserts: the save request answered 2xx; the toast `Task "NEW TITLE" updated` is visible; the URL path is exactly the record's detail path, inside the app; the form page is gone; `GET /api/v1/data/showcase_task/ID` returns the new title. The task is deleted in `finally`. A new file rather than an extension of `action-modal.spec.ts`: that file is about the modal transport, and a full-page form by URL is a different surface. - **`ui/e2e/live/list-row-action-cel.spec.ts` gains a navigation case (#27457).** It authors its own package and app through the metadata API the way Studio's menu-entry inspector writes VISIBLE WHEN (a bare string): one entry `'org_owner' in current_user.positions`, one `'e2e_no_such_position' in current_user.positions`, publishes the drafts, opens the app and asserts the first entry is shown, the second is absent, and no `predicate could not be evaluated` line reached the browser console (hidden because false, not because it faulted closed). `in` is CEL-only syntax, so on the legacy evaluator both entries are hidden. The test first asserts the seeded admin's `get-session` positions contain `org_owner`, and deletes the package in `finally`. The existing row-action case is unchanged. - **`ui/package.json`:** `record-form-direct-url.spec.ts` and `list-row-action-cel.spec.ts` join `test:e2e:live:ci`; `list-row-action-cel.spec.ts` leaves `test:e2e:live:nightly`. Both passed the promotion rule (readings below). Both headers say they are in the `:ci` allowlist since this card, the way `studio-editor.spec.ts` says it. - No changeset: the diff is tests plus two script lines in `ui/package.json`, the private workspace root (`object-ui-monorepo`, `"private": true`); no published package changes. ## Acceptance notes - **Finding, for the seat to file (class a).** #27454's fix holds only when the form is opened on the app's package-id address. Opened on the app's NAME alias (`/apps/showcase_app/showcase_task/record/ID/edit` or `/apps/showcase_app/showcase_task/new`, the address every other live spec uses and the form old bookmarks carry), the console first moves the URL to the package-id address with a `replace` navigation (`canonicalAppPathname` effect in `AppContent.tsx`, from #26183). That navigation gives the entry a generated `location.key`, so `RecordFormPage`'s `hasInAppHistory = location.key !== 'default'` reads true and `goBack` runs `navigate(-1)`, out of the document. Measured on this branch's stack, one fresh page per row: | Address | Mode | `history.state.key` after load | URL after Save | Toasts | |---|---|---|---|---| | `showcase_app` (alias) | edit | generated | `about:blank` | 0 | | `showcase_app` (alias) | new | generated | `about:blank` | 0 | | `com.example.showcase` | edit | none | record detail, in app | 1 | | `com.example.showcase` | new | none | object list, in app | 1 | In a real tab the alias rows land on whatever page the tab showed before, as in #27454. This spec opens the package-id address, the one the console's own links and the address bar carry, so it pins the fix as delivered; an alias-URL case would be red today and is not added. Dedupe words: `RecordFormPage goBack location.key`, `canonical app pathname replace history`, `direct URL alias save leaves app`. - Page block `visibleWhen` (#27457's reproduction B) is not added live: the card asks for one navigation case. The jsdom acceptance test `SchemaRenderer.bareCelVisibleWhen-27457.test.tsx` covers it. - `.github/workflows/ci.yml`'s `live-e2e-ui` comment still says "the four allowlisted live specs", and `examples/app-showcase/test/console-live-specs.live.test.ts` says "Four of its specs are the required `Live E2E UI` job"; both counts were already stale and are now further off (eight files). `ci.yml` is out of bounds for this card and the test file is outside its file surface; neither count is read by a gate (the test reads the nightly script by name, now 13 specs). - The project attribution link in the first two lines names this card thread, as the harness requires of a PR the thread opens. ## Verification All runs: this branch's workspace backend (`ui/e2e/live/ci/start-backend.sh`, `objectstack dev --seed-admin --fresh` on `examples/app-showcase`, port 4110) and the Console production build (`VITE_BASE_PATH=/ vite build`) served by `vite preview` on 5290 with `DEV_PROXY_TARGET`, the `Live E2E UI` job's stack step for step after its turbo build filters; `--retries 0`; one long-lived backend across all runs (the CI job boots a fresh one per run, so this is the harder condition). Shared container, 4 cores. | Reading | Runs | Result | Playwright total per run (wall) | |---|---|---|---| | Incumbent allowlist before this change (control) | 1 | 12/12 | 34.8 s (36.0 s) | | The two specs, 3 tests (3/3 consecutive, taken as 5 consecutive) | 5 | 5/5 green, 15/15 tests | 6.7–7.5 s (7.7–8.6 s) | | Enlarged allowlist, `pnpm run test:e2e:live:ci` (the 5/5) | 5 | 5/5 green, 75/75 tests | 38.5–40.3 s (39.5–41.4 s) | <details><summary>Per-test time over the 5 pair runs (min–max)</summary> | Test | Time | |---|---| | row-action `visible` predicates are CEL-evaluated (unchanged) | 2.0–2.3 s | | nav entry bare-string `visible` read as CEL (new) | 1.5–1.7 s | | full-page edit form opened by URL saves, toasts, stays in the app (new) | 2.3–2.9 s | </details> Budget: about +5 s on the step locally (incumbent 34.8 s, enlarged 38.5–40.3 s). The job comment in `ci.yml` measured the incumbent four-spec step at 14–24 s on CI; this PR's own `Live E2E UI` run is the first CI reading of the eight-file step, projected well inside the 120 s budget. <details><summary>Ablations (one per scenario, through scripts/ablation-replace.mjs under the verify lock, Console rebuilt per leg)</summary> Both specs ran in each leg, so each leg also shows the other scenario's test staying green. - **#27454:** `RecordFormPage.tsx` anchor `const hasInAppHistory = location.key !== 'default';` replaced with `const hasInAppHistory = window.history.length > 1;` (the pre-fix test). Mutation landed (anchor 1 to 0, replacement 0 to 1, blob dd43d8e to 70c521b1); the rebuilt bundle carries `history.length>1` once (0 before). Result: `record-form-direct-url` red (`Task "…" updated` toast not found: the page went Back to `about:blank`), the two CEL tests green. - **#27457:** `ExpressionEvaluator.ts` anchor `if (!unwrappedEnvelope) {` replaced with a branch that never takes the CEL route for a bare string and carries a string marker. Mutation landed (blob 484f34d to 4ac105fe); the rebuilt bundle carries the marker once. Result: the nav case red (`CEL Shown Entry` not visible), the row-action case and the record-form test green. - **Restore:** both files restored to the HEAD blob with `git diff HEAD` empty (the tool's own verdict), the Console rebuilt from HEAD, both markers 0 in the bundle, and every reading above was taken after that. </details> <details><summary>Gate lines (command :: exit code)</summary> `node scripts/pm/dispatch-gates.mjs --commands` derived 31 families from the three changed paths; each ran locally, plus `node scripts/check-sdui-manifest.mjs`, `pnpm --dir ui run type-check:e2e` (the program lists both changed spec files) and `pnpm --dir ui check:new-line-citations`: 34 lines, every one exit 0. `--ran` reconciliation: 31 derived, 31 run, 0 NOT-MEASURED. CI runs the rest (the repo-wide scans, `Live E2E UI` itself). ```text node scripts/check-closing-keyword-parity.mjs :: exit 0 node scripts/check-closing-keyword-parity.mjs --self-test :: exit 0 node scripts/check-comment-mask-corpus.mjs :: exit 0 node scripts/check-osv-exemptions.mjs :: exit 0 node scripts/check-osv-exemptions.mjs --self-test :: exit 0 node scripts/osv-base-relative.mjs --self-test :: exit 0 pnpm --filter @objectstack/spec run check:llms-txt :: exit 0 pnpm check:changeset-fixed :: exit 0 pnpm check:cross-package-test-inputs :: exit 0 pnpm check:dispatcher-error-vocabulary :: exit 0 pnpm check:driver-memory-census :: exit 0 pnpm check:engine-double-contract :: exit 0 pnpm check:gitlink-declared :: exit 0 pnpm check:manifest-repository-directory :: exit 0 pnpm check:merge-driver :: exit 0 pnpm check:nul-bytes :: exit 0 pnpm check:override-consistency :: exit 0 pnpm check:pnpm-flag-spellings :: exit 0 pnpm check:published-files :: exit 0 pnpm check:query-options-erasure :: exit 0 pnpm check:refd-timer-probe :: exit 0 pnpm check:test-source-alias :: exit 0 pnpm check:tier-file-adoption :: exit 0 pnpm check:turbo-task-graph :: exit 0 pnpm check:type-check-coverage :: exit 0 pnpm check:type-check-debt :: exit 0 pnpm check:undeclared-dep-imports :: exit 0 pnpm check:vendor-export-contract-resolve :: exit 0 pnpm check:watch-hint-literal :: exit 0 pnpm check:where-matcher :: exit 0 pnpm check:workspace-manifest-cycles :: exit 0 node scripts/check-sdui-manifest.mjs :: exit 0 pnpm --dir ui run type-check:e2e :: exit 0 pnpm --dir ui check:new-line-citations :: exit 0 ``` </details> All readings on head `2b1c6d27`. --- _Generated by [Claude Code](https://claude.ai/code/session_01Utp6CZ1fJX9wr5Lrj1S9H4)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent e1dde1a commit 5aee206

3 files changed

Lines changed: 141 additions & 3 deletions

File tree

‎ui/e2e/live/list-row-action-cel.spec.ts‎

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { test, expect } from '@playwright/test';
22

33
/**
4-
* Live e2e for row-action visibility on the CEL engine (issue #1584).
4+
* Live e2e for `visible` predicates on the CEL engine: a row action's (issue
5+
* #1584) and an app navigation entry's (objectstack-ai/objectstack#27457).
56
*
67
* The showcase task list surfaces the `showcase_mark_done` row action, gated by
78
* the CEL predicate `visible: '!record.done'`. After unification, that predicate
@@ -15,7 +16,19 @@ import { test, expect } from '@playwright/test';
1516
* covered deterministically by the jsdom component tests
1617
* (`packages/plugin-grid/.../RowActionMenu.test.tsx`) — this spec guards the
1718
* live render path end-to-end. Non-mutating: it only opens the menu.
19+
*
20+
* The navigation case authors its own package and app through the metadata
21+
* API, the way Studio's menu-entry inspector writes a VISIBLE WHEN: a bare
22+
* string, which the spec defines as CEL shorthand. It deletes the package
23+
* afterwards.
24+
*
25+
* In the required `Live E2E UI` job's `test:e2e:live:ci` allowlist since
26+
* objectstack#27555, under the promotion rule (3/3 consecutive green, plus a
27+
* 5/5 run of the enlarged allowlist); the readings are on that card's PR.
1828
*/
29+
30+
const API = process.env.LIVE_API_URL || 'http://localhost:3000';
31+
1932
test('row-action `visible` predicates are CEL-evaluated on the showcase task list', async ({ page }) => {
2033
await page.goto('/apps/showcase_app/showcase_task');
2134

@@ -33,3 +46,50 @@ test('row-action `visible` predicates are CEL-evaluated on the showcase task lis
3346
const markDone = page.getByTestId('row-action-showcase_mark_done');
3447
expect(await markDone.count()).toBeLessThanOrEqual(1);
3548
});
49+
50+
test('a nav entry\'s bare-string `visible` is read as CEL: shown when true, hidden when false', async ({ page, request }) => {
51+
// The seeded admin holds `org_owner`, so the first predicate is true for this
52+
// session and the second, naming a position nobody holds, is false.
53+
const session = await request.get(`${API}/api/v1/auth/get-session`);
54+
expect(session.ok(), `get-session answered ${session.status()}`).toBe(true);
55+
expect((await session.json())?.user?.positions).toContain('org_owner');
56+
57+
const stamp = Date.now();
58+
const pkgId = `com.e2e.navcel${stamp}`;
59+
const appName = `e2e_navcel_${stamp}`;
60+
const pkgRes = await request.post(`${API}/api/v1/packages`, {
61+
data: { manifest: { id: pkgId, name: `E2E Nav CEL ${stamp}`, version: '0.1.0', type: 'app' } },
62+
});
63+
expect(pkgRes.ok(), await pkgRes.text()).toBeTruthy();
64+
65+
try {
66+
// `in` is CEL-only syntax: the legacy JS-dialect evaluator faults on it and
67+
// fails closed, so on that engine both entries are hidden.
68+
const putRes = await request.put(`${API}/api/v1/meta/app/${appName}?mode=draft&package=${pkgId}`, {
69+
data: {
70+
name: appName,
71+
label: `E2E Nav CEL ${stamp}`,
72+
navigation: [
73+
{ id: 'nav_cel_shown', type: 'object', objectName: 'showcase_task', label: 'CEL Shown Entry', visible: "'org_owner' in current_user.positions" },
74+
{ id: 'nav_cel_hidden', type: 'object', objectName: 'showcase_task', label: 'CEL Hidden Entry', visible: "'e2e_no_such_position' in current_user.positions" },
75+
],
76+
},
77+
});
78+
expect(putRes.ok(), await putRes.text()).toBeTruthy();
79+
const publishRes = await request.post(`${API}/api/v1/packages/${pkgId}/publish-drafts`);
80+
expect(publishRes.ok(), await publishRes.text()).toBeTruthy();
81+
82+
const faults: string[] = [];
83+
page.on('console', (m) => {
84+
if (/predicate could not be evaluated/i.test(m.text())) faults.push(m.text());
85+
});
86+
await page.goto(`/apps/${pkgId}`);
87+
88+
await expect(page.getByRole('link', { name: 'CEL Shown Entry', exact: true })).toBeVisible();
89+
await expect(page.getByRole('link', { name: 'CEL Hidden Entry', exact: true })).toHaveCount(0);
90+
// Hidden because the predicate is false, not because it faulted closed.
91+
expect(faults, faults.join('\n')).toEqual([]);
92+
} finally {
93+
await request.delete(`${API}/api/v1/packages/${pkgId}`);
94+
}
95+
});
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import { test, expect } from '@playwright/test';
2+
import { expectToast } from './helpers';
3+
4+
/**
5+
* Live e2e for the full-page record form opened by DIRECT URL — a pasted link,
6+
* a new tab, a deep link — rather than by in-app navigation
7+
* (objectstack-ai/objectstack#27454).
8+
*
9+
* After a save the form page returns to where the user came from. With no page
10+
* of this console behind it, a history Back crosses the document boundary: the
11+
* save toast is lost with the unloaded document and the user lands outside the
12+
* app. The page must instead go to the record inside the app. A fresh
13+
* Playwright page is exactly that entry: its only earlier history entry is
14+
* `about:blank`, not a console page. The URL is the app's one address (its
15+
* package id), the one the console's own links and its address bar carry.
16+
*
17+
* The record is the test's own, created and deleted through the data API;
18+
* the stored value is read back through the same API after the save.
19+
*
20+
* In the required `Live E2E UI` job's `test:e2e:live:ci` allowlist since
21+
* objectstack#27555, under the promotion rule (3/3 consecutive green, plus a
22+
* 5/5 run of the enlarged allowlist); the readings are on that card's PR.
23+
*/
24+
25+
const APP = 'com.example.showcase';
26+
const OBJECT = 'showcase_task';
27+
const API = process.env.LIVE_API_URL || 'http://localhost:3000';
28+
29+
test('a full-page edit form opened by URL saves, toasts, and stays inside the app', async ({ page, request }) => {
30+
// A seeded project to hang the task on (`project` is a required master-detail).
31+
const projectsRes = await request.get(`${API}/api/v1/data/showcase_project?$top=1`);
32+
expect(projectsRes.ok(), await projectsRes.text()).toBeTruthy();
33+
const projectsBody = await projectsRes.json();
34+
const project = (projectsBody?.records ?? projectsBody?.data ?? [])[0];
35+
expect(project, 'a seeded showcase_project exists').toBeTruthy();
36+
37+
const stamp = Date.now();
38+
const createRes = await request.post(`${API}/api/v1/data/${OBJECT}`, {
39+
data: { title: `E2E Direct URL ${stamp}`, project: project.id ?? project._id, status: 'backlog' },
40+
});
41+
expect(createRes.ok(), await createRes.text()).toBeTruthy();
42+
const created = await createRes.json();
43+
const recordId = created?.id ?? created?.record?.id ?? created?.data?.id;
44+
expect(recordId, 'created task id').toBeTruthy();
45+
46+
try {
47+
const recordPath = `/apps/${APP}/${OBJECT}/record/${encodeURIComponent(recordId)}`;
48+
await page.goto(`${recordPath}/edit`);
49+
const form = page.getByTestId('record-form-page');
50+
await expect(form).toHaveAttribute('data-mode', 'edit');
51+
52+
const title = form.locator('input[name="title"]');
53+
await expect(title).toHaveValue(`E2E Direct URL ${stamp}`);
54+
const renamed = `E2E Direct URL renamed ${stamp}`;
55+
await title.fill(renamed);
56+
57+
const [saved] = await Promise.all([
58+
page.waitForResponse(
59+
(r) => ['PATCH', 'PUT'].includes(r.request().method()) && r.url().includes(`/api/v1/data/${OBJECT}/`),
60+
{ timeout: 15_000 },
61+
),
62+
form.locator('button[type="submit"]').click(),
63+
]);
64+
expect(saved.ok(), `the save answered ${saved.status()}`).toBe(true);
65+
66+
// The toast survives because the document did not unload…
67+
await expectToast(page, new RegExp(`Task "${renamed}" updated`));
68+
// …and the page landed on the record, inside the app.
69+
await expect(page).toHaveURL((url) => url.pathname === recordPath);
70+
await expect(page.getByTestId('record-form-page')).toHaveCount(0);
71+
72+
const readRes = await request.get(`${API}/api/v1/data/${OBJECT}/${encodeURIComponent(recordId)}`);
73+
expect(readRes.ok(), `GET ${OBJECT}/${recordId} answered ${readRes.status()}`).toBe(true);
74+
expect((await readRes.json()).record?.title).toBe(renamed);
75+
} finally {
76+
await request.delete(`${API}/api/v1/data/${OBJECT}/${encodeURIComponent(recordId)}`);
77+
}
78+
});

‎ui/package.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@
111111
"test:e2e": "playwright test",
112112
"test:e2e:ui": "playwright test --ui",
113113
"test:e2e:live": "playwright test --config=playwright.live.config.ts",
114-
"test:e2e:live:ci": "playwright test --config=playwright.live.config.ts screen-flow.spec.ts action-modal.spec.ts master-detail.spec.ts saved-view-filter.spec.ts studio-object-designer.spec.ts studio-editor.spec.ts",
115-
"test:e2e:live:nightly": "playwright test --config=playwright.live.config.ts cascading-options.spec.ts declared-sharing-rules-reach-13091.spec.ts field-conditional-rules.spec.ts form-view-subforms.spec.ts grid-conditional-rules.spec.ts grid-file-upload.spec.ts grid-parent-rules.spec.ts inline-edit-polish-2572.spec.ts list-row-action-cel.spec.ts read-only-member-record.spec.ts record-history-display.spec.ts required-when-submit.spec.ts summary-rollup.spec.ts user-filters.spec.ts",
114+
"test:e2e:live:ci": "playwright test --config=playwright.live.config.ts screen-flow.spec.ts action-modal.spec.ts master-detail.spec.ts saved-view-filter.spec.ts studio-object-designer.spec.ts studio-editor.spec.ts record-form-direct-url.spec.ts list-row-action-cel.spec.ts",
115+
"test:e2e:live:nightly": "playwright test --config=playwright.live.config.ts cascading-options.spec.ts declared-sharing-rules-reach-13091.spec.ts field-conditional-rules.spec.ts form-view-subforms.spec.ts grid-conditional-rules.spec.ts grid-file-upload.spec.ts grid-parent-rules.spec.ts inline-edit-polish-2572.spec.ts read-only-member-record.spec.ts record-history-display.spec.ts required-when-submit.spec.ts summary-rollup.spec.ts user-filters.spec.ts",
116116
"test:e2e:import-harness": "playwright test --config=playwright.import-harness.config.ts",
117117
"test:e2e:import-console": "playwright test --config=playwright.import-console.config.ts"
118118
},

0 commit comments

Comments
 (0)