Skip to content

Commit e68d23b

Browse files
feat(console): the console reads and edits forms as form items (#38484)
Part of #37087 Clause-②: yes Metadata-protocol: none Skills-docs: none — no metadata an author writes changes; the console reads and writes the `form` type card ② added. ## 维护者速读 - 用户能看到什么变化:Setup 的公开表单页看起来不变,只是改读改写表单类型;在 Studio 里打开一个表单(地址 `…/metadata/form/表单名`)就是表单设计器,能改字段、必填、分组、标题、地址和提交后的提示,存草稿再发布;控制台自己的表单页改读表单类型。表单类型暂不进 Studio 菜单(下一张 PR)。 - 为什么做:ADR-0159 把表单独立成 `form` 元数据,控制台要改读改写它,后面才能退役开发者页的公开表单页。 - 出错会怎样:最坏是某个表单在 Setup 里开关失败、或在 Studio 里存不上;设计器没有开关,保存和发布都按当时存着的开关写回,所以不会把 Setup 关掉的表单重新打开;匿名打开和提交不经这张 PR 的代码;可整体撤回。 - 要你做什么:契约审核(L2)未完成,先不用批;审核通过后席位会附审核记录请你批。 ## What changes ADR-0159 D9 for the console, card ③ PR 1 of 2 (the seat's claim 7248756424, amendment 7248849494). Every console surface here reads and writes the `form` type; the server's projection (ADR-0159 D5, completed by #38453) serves an old-shape form there too. 1. **Setup → Configuration → Public forms** (`ui/packages/app-shell/src/views/setup/`): the list read is `GET /meta/form`; the row reader takes the `form` item itself (no `viewKind` filter, no `config` hop). The two layered reads, the save paths, the reset and the override save name `form`. A switch saves `authorableForm(effective)` with `sharing.enabled` set: the read's `_` keys and the old shape's `data` are left out, since `FormSchema` refuses `data`. The shipped-off judgement reads the app's own document from the `form` layered read's `code` with the spec's `formExplicitlyWithdraws` (ADR-0159 D6 rule 6). A row whose app document cannot be read (`code: null`) is shown as status unknown and offers no switch. 2. **The #36784 designer becomes the `form` editor** (`studio-design/publicForm/`): `publicFormDesign.ts` reads and writes the top-level body. `PublicFormsDesigner.tsx` now holds `FormItemEditor`, which edits one form, and `FormItemPage`, registered as the `form` type's `EditPage` and `CreatePage`. It has no switch: `storedNow` reads `sharing.enabled` and `sharing.allowAnonymous` again at every save and publish, and a draft whose sharing differs is saved again before it is published. A form an installed app ships is saved as a declared override in the app's `.custom` pair. A form with no public link (one an action opens) is edited without an address. The new-name and address checks read the effective `form` list plus `form` drafts. The designer's own list and the Form-tab switch from #36784 are not carried over. 3. **List columns and registration** (`formListColumns.tsx`; the `form` resource is registered in `services/builtinComponents.tsx` beside the other lazy editor pages, so `metadata-admin/registry.ts` stays free of side effects): name (shows `title` when there is no `label`), label, object, public address and status. `/meta/types` serves no list layout for `form`, so these are the client's own `listColumns`. `form` stays out of Studio's menu. 4. **`FormPage`** (`ui/apps/console/src/components/FormPage.tsx`): the internal route reads `GET /api/v1/meta/form/NAME`. The anonymous route is unchanged. 5. **Strings**: new `engine.studio.publicForms.*` and `engine.list.col.publicAddress` / `publicState` keys in `./namespaces/studio` (en, zh). This PR removes no key. Outside the claimed file surface (reported to the seat): - `ui/packages/app-shell/src/views/studio-design/StudioMetadataArea.tsx`: one branch, so that a `form` item in a package's Studio area opens `FormItemPage` with the area's `customization`, `publishNonce` and `onDraftSaved`. Only the area's surface holds a read-only base's customization. Without it, an installed app's form could not be saved as its override. - `ui/packages/app-shell/src/services/builtinComponents.tsx`: the `form` resource's registration (`listColumns`, lazy `EditPage` / `CreatePage`). The claim named `metadata-admin/registry.ts`, but a registration there makes that module side-effectful and `check-side-effects-array` refuses it; every other editor page registers here. - `ui/packages/app-shell/src/views/runtime-metadata-persistence.ts`: `RuntimeArtifactType` gains `'form'`, and a `form` save invalidates the view caches the way a `view` save does, because Setup's switch goes through `saveAndPublishInPackage('form', …)`. Read first (by risk): 1. `studio-design/publicForm/PublicFormsDesigner.tsx`, `storedNow`, `save` and `publish`: the no-switch rule. 2. `setup/publicForms.ts`, `switchPublicForm` / `authorableForm` / `markShippedOff`: the body a switch writes over an old-shape form. 3. `studio-design/publicForm/publicFormDesign.ts`, `publicFormItemOf`: what is kept, and what is dropped (`data`, `viewKind`, `config`, `_` keys). ## Tests - `publicFormDesign.test.ts` (29): the top-level body both ways; a new form passes `FormSchema.safeParse`; an old-shape projected item is written back without `data` or `_formDefinedIn`; sharing is written as read (off stays off, an unchanged address keeps the stored `publicLink`, a changed one becomes `/forms/SLUG`); a form with no public link; `isPublicFormItem`. - `PublicFormsDesigner.test.tsx` (14, the #36784 tests re-pointed to the `form` shape): create, taken address and name, delete, the no-switch rule at save and at publish, the publish re-save of a draft whose sharing differs, reads that fail, a form with no public link, an old-shape save without `data`. Every write is asserted as type `form` with a body `FormSchema` accepts. - `setup/publicForms.test.ts`, `PublicFormsSetupPage.test.tsx`: the list read and both layered reads are `form`; the shipped-off judgement from the `form` layered `code`; a row whose app document cannot be read is status unknown with no switch; a switch over an old-shape row writes no `data`. - `FormPage.*` (about 30 files): the internal route reads `/meta/form/NAME`; the fixtures moved to the top-level body. - `PublicFormsDesigner.test.tsx` (+2, head `48a01c7ff7`, L2 S2): "shows the server's address refusal its own check missed (409 FORM_ADDRESS_TAKEN) as the address clash, at save and at publish" and "CONTROL: shows any other 409 as a pending draft". Ablation (the `FORM_ADDRESS_TAKEN` branch deleted): 1 failed, 15 passed, the failure is the address case (received the pending-draft sentence), the CONTROL stayed green; restored to the HEAD blob. - `FormPage.recordObject.test.tsx` (+1, L2 S3): "Log Time on a task: /meta/form/NAME is read, the form renders the record, and the submit writes it". The real `ActionRunner` runs `{type:'form', target:'showcase_task.edit'}` with record 42; FormPage reads exactly one `/api/v1/meta/form/showcase_task.edit` and no `/meta/view`, renders the record and PATCHes `/data/showcase_task/42`. ## Acceptance notes - Setup's address-clash refusal (`409 FORM_ADDRESS_TAKEN`) still shows one sentence that does not name the form holding the address: naming it needs a new key in all 11 locale files, outside this surface. Carrier: PR 2 of #37087, under claim amendment 7251711074 (card item 1, "shows the refusal with both names"; L2 S1, L1 R2). - A form an action opens: checked live on head `48a01c7ff7` and pinned by a test (see Verification, L2 S3). - This PR removes no translation key, so the removed-key probe is owed by PR 2. ## Remaining `formViews` / `viewKind: 'form'` hits under `ui/` Docblocks only in `FormPage.tsx`, `recordFormNavigation.ts`, `SchemaForm.tsx`, `clientValidation.ts`, `registry.ts`, `view-item-normalize.ts`, `freeze-schema.ts` and `imported-defaults.ts`; the view editor's own form arm (`anchors.ts`, `ViewPreview.tsx`, `view-item-normalize.ts`), which still edits a `view`; `MetadataProvider.tsx`, kept on purpose for packages that still ship forms in `views:`; and the developer `PublicFormsPage`, which PR 2 retires. ## Verification - Tests on head 83c51d8: app-shell `ConditionWidget.conditionScope`, `studio-design/publicForm`, `StudioMetadataArea.*`, `views/setup` and `runtime-metadata-persistence.*`: 35 files, 458 passed. An earlier run of all of `views/metadata-admin`, `views/studio-design` and `views/setup` was red only on the conditionScope exhaustiveness check, while `form` was registered in `registry.ts`; moving the registration fixed it (the targeted run above). Also `packages/i18n` plus the console's `src/components` and the two form-page tests in `src/__tests__`: 173 files, 2618 passed, 13 skipped. - Type checks: `@object-ui/console` `type-check` exit 0 (after building its dependencies). - Gates: `dispatch-gates --commands` derived 28 families, each run and recorded; `--ran` reconciles 28 derived, 28 run, 0 NOT-MEASURED. `pnpm --dir ui exec vitest run scripts/` was killed by memory (SIGKILL, exit 1) while a build ran beside it; run again alone it exits 0, recorded as an extra line. - Dogfood (`examples/app-showcase`, `objectstack dev`, console dev server, signed in as the seeded admin): - Setup lists both showcase forms as `form` items, both on. Switching Contact off makes `GET /forms/contact-us` and its submit answer 404; switching it on again answers 200. - Studio opens the old-shape `showcase_inquiry.contact` at `/studio/com.example.showcase/metadata/form/showcase_inquiry.contact`. Removing `message` is refused (the object requires it). Adding `source` as required, removing `company` and retitling, then save and publish: the anonymous form serves the new title and fields, a submit without `source` answers `400 VALIDATION_FAILED`, with it `201`. - Off in Setup, then edited and published in Studio: the form stays off (404) and Setup still shows it off. Switched on again, it serves the newest title. - New form: the title Contact us is refused because its address is taken (confirm disabled); Demo signup is created in the app's `.custom` pair, published, and opens and accepts a submit (`201`). - Studio's `form` list shows the label/title, name, object, address and status columns. - Screenshots: `/mnt/project-files/card-37087/pr1-dogfood/` (seat 3's project files). - Patch round, head `48a01c7ff7` (L2 S2 and S3; the designer's 409 mapping, two tests, one changeset sentence): `PublicFormsDesigner.test.tsx`, `publicFormDesign.test.ts` and `FormPage.recordObject.test.tsx` 3 files, 55 passed; `@object-ui/app-shell` and `@object-ui/console` `type-check` exit 0; `pnpm --dir ui exec vitest run scripts/` 172 passed, 2 skipped. The server's refusal (`formAddressClashRefusal`, `packages/metadata-protocol/src/protocol-form-writes.ts`) carries status 409 and code `FORM_ADDRESS_TAKEN` and names the holder only in its prose, so the editor maps the code to the shipped `addressTaken` key (no structured holder for `addressTakenBy`; no key added). - Live check of a form an action opens (head `48a01c7ff7`, `examples/app-showcase`): on task "Build homepage", the header action Log Time (`showcase_log_time`, type `form`, target `showcase_task.form`) navigates to `/apps/com.example.showcase/forms/showcase_task.form?recordId=…&recordObject=showcase_task`; `GET /api/v1/meta/form/showcase_task.form` answers 200 and no `/meta/view/NAME` is read; the form renders prefilled; Submit sends `PATCH /api/v1/data/showcase_task/…` 200 and the record reads the new title. Screenshots and the network log: `/mnt/project-files/card-37087/pr1-dogfood/s3-*.png`, `s3-network.json`; the live 409 envelope: `s2-envelope-probe.txt` (project files of the seat 5 project). - Dogfood battery (`pnpm --filter @objectstack/dogfood test` under os-verify-lock, closure built as CI does, no shard, no path): head `d5581291b6` · VERDICT exit 0 · Test Files 495 passed, 3 skipped (498) · Tests 4183 passed, 68 skipped (4251) · failures: none. The head moved since by the patch round's four `ui/` files and the changeset only; none is in the dogfood closure. ## Ablation of the no-switch rule (L1-b R1, card Done-when "ablate: build the designer's save from the base's body") Measured at head `d5581291b6`, in a throwaway detached worktree, through `scripts/ablation-replace.mjs` (HEAD-blob restore with hash check), from the `ui/` root under os-verify-lock: `pnpm exec vitest run --maxWorkers=2 --reporter=verbose packages/app-shell/src/views/studio-design/publicForm/PublicFormsDesigner.test.tsx packages/app-shell/src/views/studio-design/publicForm/publicFormDesign.test.ts`. - Ablation (one line, `PublicFormsDesigner.tsx`, the single point where both `save` and `publish` read the sharing through `storedNow`): the sharing is taken from the body as it was opened, `form.base.sharing`, before the effective, draft and code layers. - Baseline: 2 files passed, 43/43 tests (14 + 29). - Ablated: 2 failed, 41 passed. Red: - "has no switch: saves and publishes the form's sharing as it is stored at that time, not as it was when the form was opened" (`PublicFormsDesigner.test.tsx:376`, `expected true to be false` on `sharing.enabled`; the save leg); - "publishes an installed app's form with the switch as stored at the app, after it was switched off" (`PublicFormsDesigner.test.tsx:425`, the publish-time re-save carrying the switched-off sharing never happened; the publish leg). - `publicFormDesign.test.ts` stayed 29/29, as expected (`publicFormItemOf` writes whatever sharing it is handed). - Restored: blob `0e7cb3887b` equals HEAD, `git diff HEAD` empty, 43/43 green again. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L9qibxQiu6MyZ2ngLJtA5Y <!-- signed: repo:objectstack#5 · os-project-manager · session_01FEkQ5nBh856nLqWBYMy29u --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9e5be7b commit e68d23b

51 files changed

Lines changed: 3100 additions & 461 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/console': patch
4+
'@object-ui/i18n': patch
5+
---
6+
7+
feat(console): the console reads and edits forms as `form` items (objectstack#37087, ADR-0159)
8+
9+
- **Setup → Public forms** lists and switches `form` items: the list is the `form` read, a switch saves the `form` item (its body with `sharing.enabled` set, without the `data` an old-shape form is served with), and "Restore package original" resets the `form` override. What the page shows is unchanged: every public form, on and off, its address and preview; a form its installed app ships switched off reads as off. A form whose app's own document cannot be read now offers no switch.
10+
- **Studio's form editor**: the public form designer is the `form` type's editor (`EditPage` and `CreatePage`), with list columns for name, label, object, public address and status. It reads and writes the `form` item, whose body is at the top level, and has no switch: every save and publish writes `sharing.enabled` and `sharing.allowAnonymous` as they are stored at that moment, so a publish never opens a form Setup switched off. A form an installed app ships is saved as a declared override in the app's customization package. When the server refuses a save or publish because another form already uses the address, the editor says the address is taken, not that a draft is pending. The `form` type stays out of Studio's menu for now.
11+
- **The console's own form page** (the signed-in one an action of type `form` opens) reads `GET /api/v1/meta/form/NAME`. The anonymous form route is unchanged.
12+
- New `engine.studio.publicForms.*` and `engine.list.col.publicAddress` / `engine.list.col.publicState` strings in `./namespaces/studio` (en, zh).
13+
14+
Clause-②: yes
15+
Metadata-protocol: none

‎ui/apps/console/src/__tests__/formPageRequiredMarker-10178.test.tsx‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@ const OBJECT_SCHEMA = {
5959
},
6060
};
6161

62-
const VIEW_ENVELOPE = {
62+
const FORM_ITEM = {
6363
name: 'showcase_task.intake',
6464
object: 'showcase_task',
65-
viewKind: 'form',
6665
label: 'Task intake',
67-
config: {
66+
...{
6867
type: 'simple',
6968
sections: [{ label: 'Task', fields: ['title', 'freeform', 'agree', 'optin'] }],
7069
},
@@ -89,7 +88,7 @@ async function renderForm() {
8988
vi.stubGlobal(
9089
'fetch',
9190
stubFetch([
92-
{ match: '/meta/view/', body: VIEW_ENVELOPE },
91+
{ match: '/meta/form/', body: FORM_ITEM },
9392
{ match: '/meta/object/', body: OBJECT_SCHEMA },
9493
]),
9594
);

‎ui/apps/console/src/__tests__/internalFormShell.test.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,8 @@ import { App } from '../App';
146146
const INTERNAL_VIEW = {
147147
name: 'showcase_task.edit',
148148
object: 'showcase_task',
149-
viewKind: 'form',
150149
label: 'Log Time',
151-
config: { type: 'simple', sections: [{ fields: ['title'] }] },
150+
...{ type: 'simple', sections: [{ fields: ['title'] }] },
152151
};
153152
const OBJECT_SCHEMA = { name: 'showcase_task', fields: { title: { type: 'text', label: 'Title' } } };
154153
const PUBLIC_FORM = {
@@ -163,7 +162,7 @@ beforeEach(() => {
163162
vi.stubGlobal(
164163
'fetch',
165164
vi.fn(async (url: string) => {
166-
const body = String(url).includes('/meta/view/')
165+
const body = String(url).includes('/meta/form/')
167166
? INTERNAL_VIEW
168167
: String(url).includes('/meta/object/')
169168
? OBJECT_SCHEMA

‎ui/apps/console/src/components/FormPage.conditionalRules.test.tsx‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,13 @@ function withRules(rules: Record<string, Record<string, unknown>>) {
7676
return { ...BASE_SCHEMA, fields };
7777
}
7878

79-
/** Wrap sections in the `/meta/view/:name` envelope the internal route reads. */
80-
function viewEnvelope(sections: unknown[]) {
79+
/** Wrap sections in the `/meta/form/:name` item the internal route reads. */
80+
function formItem(sections: unknown[]) {
8181
return {
8282
name: 'showcase_task.edit',
8383
object: 'showcase_task',
84-
viewKind: 'form',
8584
label: 'Task',
86-
config: { type: 'simple', sections },
85+
...{ type: 'simple', sections },
8786
};
8887
}
8988

@@ -134,7 +133,7 @@ function renderInternal(sections: unknown[], opts: RenderOpts = {}) {
134133
vi.stubGlobal(
135134
'fetch',
136135
stubFetch([
137-
{ match: '/meta/view/', body: viewEnvelope(sections) },
136+
{ match: '/meta/form/', body: formItem(sections) },
138137
{ match: '/meta/object/', body: opts.objectSchema ?? BASE_SCHEMA },
139138
...(opts.extraRoutes ?? []),
140139
]),

‎ui/apps/console/src/components/FormPage.externalWriteRefusal-30334.test.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ function stubInternal(refusal: { status: number; body: unknown }) {
5656
const view = {
5757
name: 'spare_parts.form',
5858
object: 'spare_parts',
59-
viewKind: 'form',
6059
label: 'Spare part',
61-
config: { type: 'simple', sections: [{ fields: ['name'] }] },
60+
...{ type: 'simple', sections: [{ fields: ['name'] }] },
6261
};
6362
const object = { name: 'spare_parts', label: 'Spare part', fields: FIELDS };
6463
vi.stubGlobal(
@@ -68,7 +67,7 @@ function stubInternal(refusal: { status: number; body: unknown }) {
6867
posts += 1;
6968
return answer(false, refusal.status, refusal.body);
7069
}
71-
if (String(url).includes('/meta/view/')) return answer(true, 200, view);
70+
if (String(url).includes('/meta/form/')) return answer(true, 200, view);
7271
if (String(url).includes('/meta/object/')) return answer(true, 200, object);
7372
throw new Error(`unstubbed fetch: ${url}`);
7473
}),

‎ui/apps/console/src/components/FormPage.fieldSpan-37559.test.tsx‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,12 @@ const OBJECT_SCHEMA = {
4141
},
4242
};
4343

44-
function viewEnvelope(fields: unknown[], columns: number) {
44+
function formItem(fields: unknown[], columns: number) {
4545
return {
4646
name: 'showcase_task.intake',
4747
object: 'showcase_task',
48-
viewKind: 'form',
4948
label: 'Task intake',
50-
config: { type: 'simple', sections: [{ label: 'Task', columns, fields }] },
49+
...{ type: 'simple', sections: [{ label: 'Task', columns, fields }] },
5150
};
5251
}
5352

@@ -72,7 +71,7 @@ function renderForm(fields: unknown[], columns = 2) {
7271
vi.stubGlobal(
7372
'fetch',
7473
stubFetch([
75-
{ match: '/meta/view/', body: viewEnvelope(fields, columns) },
74+
{ match: '/meta/form/', body: formItem(fields, columns) },
7675
{ match: '/meta/object/', body: OBJECT_SCHEMA },
7776
]),
7877
);

‎ui/apps/console/src/components/FormPage.fieldSpec.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* The measurement that chose the route: the console's copy was a strict subset
1616
* — 9 of the shared type's 26 keys, every one of them identical, none of them
1717
* console-only — sitting in a position that describes an **authored document**
18-
* (`FormSectionSpec.fields`, read straight off `/meta/view/:name`), not a
18+
* (`FormSectionSpec.fields`, read straight off `/meta/form/:name`), not a
1919
* narrower thing this app authors. The narrow, renderer-honoured shape is a
2020
* separate type that already exists here, `RenderableField`. So the two names
2121
* were one contract, and the console's copy simply described it wrongly: legal

‎ui/apps/console/src/components/FormPage.formViewChrome-26843.test.tsx‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,24 @@ const OBJECT_SCHEMA = {
3434
},
3535
};
3636

37-
function viewBody(form: Record<string, unknown>) {
38-
return {
39-
name: 'showcase_inquiry.intake',
40-
object: 'showcase_inquiry',
41-
viewKind: 'form',
42-
label: 'Intake',
43-
config: { type: 'simple', sections: [{ fields: ['title', 'channel'] }], ...form },
44-
};
37+
function formBody(form: Record<string, unknown>) {
38+
return { type: 'simple', sections: [{ fields: ['title', 'channel'] }], ...form };
39+
}
40+
41+
/** The `form` item `/meta/form/:name` serves: identity and body at the top level. */
42+
function formItem(form: Record<string, unknown>) {
43+
return { name: 'showcase_inquiry.intake', object: 'showcase_inquiry', label: 'Intake', ...formBody(form) };
4544
}
4645

4746
function stubFetch(form: Record<string, unknown>) {
4847
return vi.fn(async (url: string) => {
4948
const path = String(url);
50-
const body = path.includes('/meta/view/')
51-
? viewBody(form)
49+
const body = path.includes('/meta/form/')
50+
? formItem(form)
5251
: path.includes('/meta/object/')
5352
? OBJECT_SCHEMA
5453
: path.includes('/forms/intake')
55-
? { slug: 'intake', object: 'showcase_inquiry', form: viewBody(form).config, objectSchema: OBJECT_SCHEMA }
54+
? { slug: 'intake', object: 'showcase_inquiry', form: formBody(form), objectSchema: OBJECT_SCHEMA }
5655
: path.includes('/data/showcase_inquiry/r1')
5756
? { record: { id: 'r1', title: 'Stored', channel: 'email' } }
5857
: null;

‎ui/apps/console/src/components/FormPage.inAppShell-13433.test.tsx‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,14 @@ import { appRoutes } from '../AppContent';
3232
vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn() } }));
3333

3434
/** A container's default form: no view label, no form `title` — what Log Time opens. */
35-
const UNLABELLED_VIEW = {
36-
name: 'showcase_task.form',
37-
object: 'showcase_task',
38-
viewKind: 'form',
39-
config: {
40-
type: 'simple',
41-
sections: [{ name: 'task', label: 'Task details', fields: ['title'] }],
42-
},
35+
const UNLABELLED_BODY = {
36+
type: 'simple',
37+
sections: [{ name: 'task', label: 'Task details', fields: ['title'] }],
4338
};
4439

40+
/** A `form` item that names itself nowhere: no `label`, no `title`. */
41+
const UNLABELLED_VIEW = { name: 'showcase_task.form', object: 'showcase_task', ...UNLABELLED_BODY };
42+
4543
const OBJECT_SCHEMA = {
4644
name: 'showcase_task',
4745
label: 'Task',
@@ -65,7 +63,7 @@ function stubFetch(view: unknown = UNLABELLED_VIEW) {
6563
const method = (init?.method ?? 'GET').toUpperCase();
6664
const u = String(url);
6765
let body: unknown;
68-
if (u.includes('/meta/view/')) body = view;
66+
if (u.includes('/meta/form/')) body = view;
6967
else if (u.includes('/meta/object/')) body = OBJECT_SCHEMA;
7068
else if (method === 'GET' && u.includes('/data/showcase_task/task-42')) body = GET_RESPONSE;
7169
else if (method === 'POST' && u.includes('/data/showcase_task')) body = POST_RESPONSE;
@@ -127,14 +125,14 @@ describe('the heading of an internal form (objectui#13433)', () => {
127125
});
128126

129127
it('an authored form `title` heads the form', async () => {
130-
vi.stubGlobal('fetch', stubFetch({ ...UNLABELLED_VIEW, config: { ...UNLABELLED_VIEW.config, title: 'Log time' } }));
128+
vi.stubGlobal('fetch', stubFetch({ ...UNLABELLED_VIEW, title: 'Log time' }));
131129
renderInternal({ url: '/forms/showcase_task.form' });
132130

133131
expect(await screen.findByRole('heading', { level: 1 })).toHaveTextContent(/^Log time$/);
134132
});
135133

136134
it('control: the view’s own label still wins', async () => {
137-
vi.stubGlobal('fetch', stubFetch({ ...UNLABELLED_VIEW, label: 'Quick edit', config: { ...UNLABELLED_VIEW.config, title: 'Log time' } }));
135+
vi.stubGlobal('fetch', stubFetch({ ...UNLABELLED_VIEW, label: 'Quick edit', title: 'Log time' }));
138136
renderInternal({ url: '/forms/showcase_task.form' });
139137

140138
expect(await screen.findByRole('heading', { level: 1 })).toHaveTextContent(/^Quick edit$/);
@@ -191,7 +189,7 @@ describe('Cancel on an internal form (objectui#13433)', () => {
191189
ok: true,
192190
status: 200,
193191
statusText: 'OK',
194-
json: async () => ({ object: 'showcase_task', form: UNLABELLED_VIEW.config, objectSchema: OBJECT_SCHEMA }),
192+
json: async () => ({ object: 'showcase_task', form: UNLABELLED_BODY, objectSchema: OBJECT_SCHEMA }),
195193
text: async () => '',
196194
}) as unknown as Response),
197195
);

‎ui/apps/console/src/components/FormPage.inlineLocaleEntry-13380.test.tsx‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,11 @@ const FORM = {
9898

9999
const PUBLIC_PAYLOAD = { slug: 'support', object: API_NAME, form: FORM, objectSchema: CASE_SCHEMA };
100100

101-
const VIEW_ENVELOPE = {
101+
const FORM_ITEM = {
102102
name: 'support_case.intake',
103103
object: API_NAME,
104-
viewKind: 'form',
105104
label: 'Support',
106-
config: FORM,
105+
...FORM,
107106
};
108107

109108
// ─── Harness ──────────────────────────────────────────────────────────────
@@ -136,7 +135,7 @@ function renderSurface(surface: Surface, lang: Lang) {
136135
surface === 'public'
137136
? [{ match: '/forms/support', body: PUBLIC_PAYLOAD }]
138137
: [
139-
{ match: '/meta/view/', body: VIEW_ENVELOPE },
138+
{ match: '/meta/form/', body: FORM_ITEM },
140139
{ match: '/meta/object/', body: CASE_SCHEMA },
141140
// The signed-in visitor's bundle, answered empty: the authored copy
142141
// is what renders.

0 commit comments

Comments
 (0)