Skip to content

Commit c48f06c

Browse files
feat(app-shell): every metadata list on ObjectGrid; 新建 on a read-only base lands in its .custom pair (#36978)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwB2BRcLs2zJH6mZWG94VVuew)_ Fixes #36897 Part of #36890 Clause-②: yes (widening) Metadata-protocol: none The widening: `ObjectGridComponentProps`, exported from `@object-ui/plugin-grid`'s entry, gains two optional members, `hostCells` and `rowTint`. Nothing existing is narrowed, and no metadata an author writes changes. ## 维护者速读 - 用户能看到什么变化:设置和工作室「全部元数据」里每种元数据的列表都换成同一张表格(排序、分页跟着地址走,「修改时间」列也在其中);在只读的安装应用(如 HotCRM)上点「新建」,对象和流程会建到它配套的定制包里。 - 为什么做:这是「工作室统一列表」专题的列表一侧,让所有类型的列表长一个样,并让只读应用也能直接新建定制内容。 - 出错会怎样:管理员可能看到列表排序或分页不对、或在只读应用上新建失败并看到原因;改动只在界面层,撤回本次合并即可恢复原表格。 - 要你做什么:无。 ## What changes - **`@object-ui/plugin-grid`** — two generic host props on `ObjectGrid`'s table view: `hostCells` (a host draws a column's cells, keyed by the column's field) and `rowTint` (a palette name per row; it wins over `rowColor`, and only palette names tint — `rowTintClass` in `useRowColor.ts`). No product-named component. - **The metadata list is an `ObjectGrid`** (`ResourceListPage.tsx`, adapter `metadataListGrid.ts`): - the grid gets a schema DECLARED from the list's columns (`MetadataListSource` answers it; nothing is guessed from the first row), and each row is only its key plus its column values — the item, its package, lock and diagnostics are looked up by that key, never selected through the grid; - rows reach the grid already filtered and sorted by `applyListState` (the one implementation `orderedListNames` reads), in host mode (`data` + `manualPagination` + `rowCount` + `onPageChange`), so the grid never re-sorts and its visible order IS the detail's ‹ › order (pinned); - header sort → the list's `sort` param (only the API-name/label column sorts; a label-first identity column sorts by label), page → a `page` param, cleared on every list-state write; - diagnostics tint (`rowTint` red/amber), the lock, identity cell, served/console-rendered columns, the Active switch (with its holder confirmation, `CatalogActiveCell` unchanged) and sharing-rule Clone are the page's host cells. Active and Clone share ONE right-pinned controls column, because the grid gives every right-pinned column `sticky right-0`; - the grid's search box, selection, inline edit, column resize/reorder (so no personal column layout) and export are off for this list. - **List 「新建」 on a read-only base lands in the paired `.custom` package** (ADR-0146 D3): - new module `MetadataListCreateDialog.tsx`: object (with the organization-wide sharing default; joins its package's app menu only when NOT in a pair, as the Data pillar does) and flow (starting-point presets, Advanced trigger list, born off). On a read-only base both ask `ensureCustomizationPackage` and write to the answered package/namespace; a quick submit reads the namespace first instead of writing unprefixed; - `StudioMetadataArea`: `AreaCreate` on a read-only base with a customization opens the pair's create (ensure once, then `/studio/PAIR/metadata/TYPE/new`; a refusal is shown in place); the area tells the list `host.pairCreate` exactly where it does that, so the list never offers a dead 「新建」. A walled door offers none, as today; - `StudioDesignSurface.tsx` and the pillar files split out of it are untouched (helpers imported from standalone studio-design modules only). Dashboard/report 「新建」 is not here. - `builtinComponents.tsx`, `anchors.ts`, `servedListColumns.tsx` are read only. ### Since the first version of this body (head `1137895` → `f1f10706`) - **Kernel packages get no list create.** A kernel package (manifest scope `system` or `cloud`) has no pair: the ensure door refuses it (409, ADR-0146 D3). The area now reads that scope from the listed manifests. It sets `host.pairCreate` only for a read-only, non-kernel base whose door is not walled. `AreaCreate` opens the pair's create only under that same flag, so a kernel package's `/new` lands on the list. Pinned in `StudioMetadataArea.routes-28561.test.tsx`; it was CI's red on `Test UI (7/16)`, `StudioDesignSurface.metadataArea-28561`. - **The create-dialog enumeration test.** `CreateItemDialog.oneLabel-11787.test.ts` enumerates every `CreateItemDialog` site from source. An object and a flow are now created from their pillar AND from the list, so its CONTROL now asks that each live title is reached by one site or more, instead of exactly once. This was CI's red on `Test UI (2/16)`. - **Merge of #36977** (one detail header and tool tabs). It conflicted in `StudioMetadataArea.tsx`; the resolution keeps its `AreaHistoryRedirect` and this PR's `AreaCreate` side by side. - **#36898 re-hosted on the grid table.** After #36983 merged, its 「修改时间」 cell (`ListChangedCell`, `listChangedAt`, `listDraftMarks`) is a page column (`__changed`) drawn by a host cell. It sits before Source, keeps the item's change time and its 「有未发布的改动」 mark (person vs AI), and looks up the bundle member by row key. - The page's own columns are now drawn under their place in the column list, not by index arithmetic. - The Modified header sorts by the list's `changed` key. A new pin in `ResourceListPage.changedColumn-36898.test.tsx` checks that a header click orders oldest first with the code-shipped item last. Its existing cases read the grid's DOM, reaching the row by `closest('tr')`. - The ‹ › order pin is unchanged: the rows still come from `applyListState`, which now also sorts by `changed`. - **`metadataAreaHost.customizations-28568`** waited for the "only customizations" filter and then read rows synchronously. The grid draws its rows once its table is ready ("Loading grid…" first), so the test now awaits the row before reading its marks (3 cases). ## Tests Final local run at `00e524f13`. `f1f10706` after it changes only the changeset's `Clause-②` line. <details><summary>Every suite naming ResourceListPage + the #36898 helpers + adapter + create + area + grid + the enumeration test — 43 files / 508 tests pass; type-check green</summary> ``` pnpm --dir ui exec vitest run --maxWorkers=2 FILES (the 36 test files `git grep -l ResourceListPage` names, plus listChangedAt-36898, listDraftMarks-36898, metadataListGrid, MetadataListCreateDialog.pairCreate-36897, rowAdornment-13330, CreateItemDialog.oneLabel-11787) Test Files 43 passed (43) Tests 508 passed (508) pnpm --filter @object-ui/app-shell --filter @object-ui/plugin-grid type-check ui/packages/plugin-grid type-check: Done ui/packages/app-shell type-check: Done os-verify-lock: VERDICT command-exit 0 ``` </details> The earlier runs on this branch, kept for the record. Run at `490aad241`: <details><summary>ResourceListPage family + adapter + create + area + grid — 72 files / 544 tests pass</summary> ``` pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/views/metadata-admin/ResourceListPage packages/app-shell/src/views/metadata-admin/metadataListGrid packages/app-shell/src/views/metadata-admin/MetadataListCreateDialog packages/app-shell/src/views/metadata-admin/metadataAreaHost packages/app-shell/src/views/studio-design/StudioMetadataArea packages/plugin-grid/src/__tests__/rowAdornment packages/plugin-grid/src/__tests__/ObjectGrid Test Files 72 passed (72) Tests 544 passed (544) os-verify-lock: VERDICT command-exit 0 ``` Earlier on this branch the whole `plugin-grid/src` tree ran green with the metadata-admin suites (329 files). </details> <details><summary>type-check — app-shell + plugin-grid green</summary> ``` pnpm --filter @object-ui/app-shell --filter @object-ui/plugin-grid type-check ui/packages/plugin-grid type-check: Done ui/packages/app-shell type-check: Done os-verify-lock: VERDICT command-exit 0 ``` </details> New pins: - `metadataListGrid.test.ts` — the declared schema (a stray first-row key is not a field), the grid flags off, sortable only where the list sorts, sort round-trip, page clamp. - `ResourceListPage.listStateInUrl-36896.test.tsx` (new describe) — the rows the table draws, in order, equal the detail's ‹ › names; a Label header click writes `sort=label` and the detail follows; `page=2` of 53 rows shows the last 3, a new search returns to page 1. - `MetadataListCreateDialog.pairCreate-36897.test.tsx` — read-only base: ensure asked, pair package + pair namespace written, OWD carried, no menu join; CONTROL writable package: no ensure, menu join; flow preset into the pair, born off; a preset needing an object writes nothing. - `ResourceListPage.pairCreate-36897.test.tsx` — 新建 offered on a read-only base (object/flow dialog, other type → area create), none without `pairCreate`; CONTROL Setup unchanged. - `StudioMetadataArea.routes-28561.test.tsx` (new describe) — the pair's create opens from the ensure answer, a refusal shows in place, a walled door never asks, `pairCreate` set exactly then. - `rowAdornment-13330.test.tsx` (new describe) — a host cell replaces its column only; `rowTint` tints palette names only; CONTROL without either prop. - Changed only where a test pinned the old table's DOM: the row test id now sits on the identity cell (`closest('tr')` reaches the row) in 5 suites; the declared-sharing-rules pins read the one shared controls cell; the nightly live spec `declared-sharing-rules-reach-13091` reads the grid's `data-table-scroll-box` and its seam shadow (measured on the booted app below: Clone and Active inside the 1440 px viewport and box, overflow 1588/1390, shadow drawn). ## Acceptance notes - **Size** (against `origin/main`, at `00e524f13`): 2195 changed lines (1771+, 424-): - src 1509, tests 673, changeset 13, generated 0; - merging #36898 and re-hosting it on the grid added 68 of them (2127 before); - this is the card's only PR, under the 2500 stop line. - **Largest type under `~all`** (HotCRM booted, `GET /api/v1/meta/TYPE` for all 34 types): `object` **136** rows (then `email_template` 128, `view` 125, `hook` 88, `flow` 54). The grid holds them in memory and pages 50 at a time — `/studio/~all/metadata/object?page=3` shows 36 rows, "Page 3 of 3". - On the booted HotCRM the list showed "Couldn't read customizations: … answered a body its declaration refuses" — the server is the published `@objectstack/cli` 18.6.0 HotCRM pins, the console is this tree's `ui/` (version skew between a released server and `main`'s reader); the create path itself does not read it. - `ObjectGrid` gives every `pinned: 'right'` column `sticky right-0`, so two right-pinned columns overlap; this list pins one. Noted, not filed (no second producer measured). - The live HotCRM run made no approvals/lock API calls (network log of both creates: ensure → PUT draft → POST publish → user-preference PATCH only). **Declared deviations.** - The screenshots live on a no-PR, images-only branch, `claude/issue-36897-list-objectgrid-shots` (`3c488ba2`), and are embedded below by raw URL. The relay has no attachment upload. - HotCRM was verified with its pinned published server (`@objectstack/cli` 18.6.0) and this tree's console on Vite, the dogfood skill's authoritative-console route. The screenshots predate the #36898 re-host, so they show no 「修改时间」 column. - Most of the 39 locally derived gate families ran at `2c60bdf3a`. The ratchet subset re-ran later (`test-source-alias`, `type-check-debt`, `type-check-coverage`, `undeclared-dep-imports`, `cross-package-test-inputs`, `published-files`, `nul-bytes`), and CI runs the farm on the head. - One push went out while `overlap-check` reported conflicts with the then-open PRs #36983 and #36977, not with main. Both have since merged into this branch. ## Verification Booted HotCRM (`objectstack dev --seed-admin -p 4517`, its own DB) with this tree's console on Vite (`VITE_SERVER_URL`), Chromium at deviceScaleFactor 2: | | | |---|---| | Object list on HotCRM (read-only base) — grid, 新建 offered | ![object list](https://raw.githubusercontent.com/objectstack-ai/objectstack/3c488ba27808fafe6ead8655bfef05212a81bc14/issue-36897/hotcrm-object-list.png) | | New object on HotCRM — saved as `crm_custom_site_visit`, OWD picker | ![create dialog](https://raw.githubusercontent.com/objectstack-ai/objectstack/3c488ba27808fafe6ead8655bfef05212a81bc14/issue-36897/hotcrm-object-create-dialog.png) | | Landed: "In app.objectstack.hotcrm.custom" (`POST …/hotcrm/ensure-customization 201`, `PUT /meta/object/crm_custom_site_visit?package=app.objectstack.hotcrm.custom`) | ![object created](https://raw.githubusercontent.com/objectstack-ai/objectstack/3c488ba27808fafe6ead8655bfef05212a81bc14/issue-36897/hotcrm-object-created.png) | | New flow on HotCRM — presets | ![flow dialog](https://raw.githubusercontent.com/objectstack-ai/objectstack/3c488ba27808fafe6ead8655bfef05212a81bc14/issue-36897/hotcrm-flow-create-dialog.png) | | Landed: flow in `app.objectstack.hotcrm.custom`, switched off, Start = manual | ![flow created](https://raw.githubusercontent.com/objectstack-ai/objectstack/3c488ba27808fafe6ead8655bfef05212a81bc14/issue-36897/hotcrm-flow-created.png) | | Sharing rules under `~all`: Active switch + Clone in the pinned controls column | ![sharing rules](https://raw.githubusercontent.com/objectstack-ai/objectstack/3c488ba27808fafe6ead8655bfef05212a81bc14/issue-36897/all-sharing-rule-list.png) | | `~all` objects, page 3 of 3 (136 rows) | ![page 3](https://raw.githubusercontent.com/objectstack-ai/objectstack/3c488ba27808fafe6ead8655bfef05212a81bc14/issue-36897/all-object-list-page3.png) | | Self-built package `com.acme.fieldops`: object `fops_work_order` and flow `dispatch_tech` written to it (no ensure call) | ![self-built object](https://raw.githubusercontent.com/objectstack-ai/objectstack/3c488ba27808fafe6ead8655bfef05212a81bc14/issue-36897/selfbuilt-object-created.png) ![self-built flow](https://raw.githubusercontent.com/objectstack-ai/objectstack/3c488ba27808fafe6ead8655bfef05212a81bc14/issue-36897/selfbuilt-flow-created.png) | Read first (by risk): `ResourceListPage.tsx` (the host cells + `cellDrawsRef` — the table keeps columns as state, so cells must be stable and read the latest draw through a ref), `ObjectGrid.tsx` (`hostCelledColumns`, `rowClassName`), `MetadataListCreateDialog.tsx` (`createTarget`). Two-minute check: `pnpm --dir ui exec vitest run --maxWorkers=2 packages/app-shell/src/views/metadata-admin/ResourceListPage.listStateInUrl-36896.test.tsx` — expect 11 passed, including "the rows the table draws, in order, are the names the detail steps through". CI on `00e524f13`: 40 success, 13 skipped, mergeable `clean`. Local gates: the 39 families `dispatch-gates --commands` derives all exit 0 (`--ran`: 39 derived, 39 run, 0 NOT-MEASURED, derived zero); `check:test-source-alias` was red once on this branch and fixed by paying the `@objectstack/lint` / `@object-ui/plugin-detail` loads at collection in 6 suites; the vitest `scripts/` family was OOM-killed once beside the booted app and re-ran green (172 files). CI runs the farm. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufzgNtKtppbRbXmHGH8x <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzgNtKtppbRbXmHGH8x --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 30778f3 commit c48f06c

23 files changed

Lines changed: 1771 additions & 424 deletions
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@object-ui/plugin-grid': patch
3+
'@object-ui/app-shell': patch
4+
---
5+
6+
feat(app-shell): every metadata type's list is drawn by ObjectGrid, and its New on a read-only base creates in the base's paired `.custom` package
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
- `@object-ui/plugin-grid`: `ObjectGrid` takes two generic host props for its table view — `hostCells` (a host draws a column's cells) and `rowTint` (a palette name per row, over `rowColor`).
12+
- `@object-ui/app-shell`: the metadata list (Setup and Studio's All metadata area) is an `ObjectGrid` fed a declared schema and the page's rows in the list's own order; diagnostics tint, lock, the Active switch, Clone, the served columns and the 「修改时间」 column (its time, its unpublished-changes mark and its `changed` sort, objectstack#36898) are the page's cells; sort, search and page live in the address. The grid's personal columns, export, selection and inline edit are off for it.
13+
- On a read-only base in Studio, the list's New creates in the paired `.custom` package (ADR-0146 D3): an object (with its organization-wide sharing default) and a flow (from a starting point) open the list's create dialog; another type opens the area's create in the pair. Under the customization wall no New is offered.

‎ui/e2e/live/declared-sharing-rules-reach-13091.spec.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { test, expect, type Locator } from '@playwright/test';
1010
* - the first Clone button and the first Active switch both lie wholly inside
1111
* the viewport AND inside the visible box of the table's scroller, with the
1212
* table not scrolled at all;
13-
* - when the table is wider than its box, the box says so
14-
* (`data-overflow-right`, which drives the seam shadow on the pinned cells).
13+
* - when the table is wider than its box, the grid draws its seam shadow at
14+
* the pinned cells (objectstack#36897: the list is drawn by ObjectGrid).
1515
*
1616
* The unit pins for the same page are in
1717
* `ResourceListPage.declaredSharingRules-12982.test.tsx`.
@@ -30,9 +30,10 @@ test.use({ viewport: { width: 1440, height: 1000 } });
3030

3131
test('at 1440 px, Clone and the Active switch are inside the viewport and the table box', async ({ page }) => {
3232
await page.goto(LIST);
33-
// The table's own scroll box, found by structure rather than by a test id,
34-
// so the measurement reads the same element before and after the fix.
35-
const scroller = page.locator('table').first().locator('xpath=..');
33+
// The table's own scroll box. objectstack#36897 — the list is drawn by
34+
// ObjectGrid, whose table box marks itself (`data-table-scroll-box`); the
35+
// table's parent is no longer the element that scrolls.
36+
const scroller = page.locator('[data-table-scroll-box]').first();
3637
await expect(scroller).toBeVisible();
3738
const clone = page.locator('[data-testid^="catalog-clone-"]').first();
3839
const active = page.locator('[data-testid^="catalog-active-"]').first();
@@ -50,9 +51,9 @@ test('at 1440 px, Clone and the Active switch are inside the viewport and the ta
5051
expect(b.x + b.width, `${what} ends inside the table box`).toBeLessThanOrEqual(frame.x + frame.width + 0.5);
5152
}
5253

53-
// The box reports its overflow, which is what draws the seam shadow.
54+
// While columns remain to the right, the grid draws its seam shadow.
5455
const widths = await scroller.evaluate((el) => ({ scroll: el.scrollWidth, client: el.clientWidth }));
5556
if (widths.scroll > widths.client + 1) {
56-
await expect(scroller).toHaveAttribute('data-overflow-right', 'true');
57+
await expect(page.getByTestId('data-table-scroll-shadow-right').first()).toBeVisible();
5758
}
5859
});
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#36897 — the metadata list's 「新建」 for an object and a flow.
5+
*
6+
* - On a read-only base the item is written to the pair the ensure door
7+
* answers (ADR-0146 D3), never to the base, and an object does not try to
8+
* join an app menu (the pair has no app). On a writable package — the
9+
* control — the door is never knocked on, the item is written to the list's
10+
* package and the object joins the menu.
11+
* - The object carries the organization-wide default it was given.
12+
* - A flow is created from a starting point; one that watches an object
13+
* writes nothing until it has one.
14+
*/
15+
16+
// Paid at collection, not inside a case's clock (check:test-source-alias).
17+
import '@objectstack/lint';
18+
import '@testing-library/jest-dom/vitest';
19+
import * as React from 'react';
20+
import { afterEach, describe, expect, it, vi } from 'vitest';
21+
import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';
22+
23+
const save = vi.fn(async (..._args: unknown[]) => ({}));
24+
vi.mock('./useMetadata', async (importOriginal) => ({
25+
...(await importOriginal<Record<string, unknown>>()),
26+
useMetadataClient: () => ({ save }),
27+
}));
28+
29+
const ensure = vi.fn(async (baseId: string) => ({
30+
basePackageId: baseId,
31+
packageId: `${baseId}.custom`,
32+
namespace: 'hrx',
33+
created: true,
34+
writable: true,
35+
}));
36+
vi.mock('../studio-design/packages-io.js', async (importOriginal) => ({
37+
...(await importOriginal<Record<string, unknown>>()),
38+
ensureCustomizationPackage: (baseId: string) => ensure(baseId),
39+
fetchPackages: async () => [
40+
{ id: 'com.vendor.hr', namespace: 'hr' },
41+
{ id: 'com.example.crm', namespace: 'crm' },
42+
],
43+
}));
44+
const publish = vi.fn(async () => ({ ok: true }));
45+
vi.mock('../studio-design/studioSaveBar.js', async (importOriginal) => ({
46+
...(await importOriginal<Record<string, unknown>>()),
47+
publishSavedItem: (...args: unknown[]) => publish(...(args as [])),
48+
}));
49+
vi.mock('../studio-design/StudioPillarKit.js', async (importOriginal) => ({
50+
...(await importOriginal<Record<string, unknown>>()),
51+
findTakenIdentifier: async () => null,
52+
}));
53+
const joinMenu = vi.fn(async () => ({ kind: 'joined' }));
54+
vi.mock('../studio-design/newObjectJoinsAppMenu.js', async (importOriginal) => ({
55+
...(await importOriginal<Record<string, unknown>>()),
56+
addNewObjectToAppMenu: (...args: unknown[]) => joinMenu(...(args as [])),
57+
}));
58+
59+
import { MetadataListCreateDialog } from './MetadataListCreateDialog';
60+
import { t } from './i18n';
61+
62+
afterEach(() => {
63+
cleanup();
64+
vi.clearAllMocks();
65+
});
66+
67+
const L = 'en-US' as const;
68+
69+
function open(type: 'object' | 'flow', packageId: string, inPair: boolean) {
70+
const onCreated = vi.fn();
71+
render(
72+
<MetadataListCreateDialog
73+
type={type}
74+
open
75+
onOpenChange={() => {}}
76+
packageId={packageId}
77+
inPair={inPair}
78+
locale={L}
79+
onCreated={onCreated}
80+
/>,
81+
);
82+
return onCreated;
83+
}
84+
85+
function fill(labelKey: string, idKey: string, label: string, id: string) {
86+
fireEvent.change(screen.getByLabelText(t(labelKey, L)), { target: { value: label } });
87+
fireEvent.change(screen.getByLabelText(t(idKey, L)), { target: { value: id } });
88+
fireEvent.click(screen.getByRole('button', { name: t('engine.studio.createLive', L) }));
89+
}
90+
91+
describe('list 「新建」 lands in the paired .custom package on a read-only base (objectstack#36897)', () => {
92+
it('an object on a read-only base: the ensure door is asked, the pair is written, its namespace names it, no menu join', async () => {
93+
const onCreated = open('object', 'com.vendor.hr', true);
94+
fireEvent.keyDown(screen.getByTestId('create-object-owd'), { key: 'ArrowDown' });
95+
fireEvent.click(await screen.findByRole('option', { name: t('engine.studio.settings.sharingPublicRead', L) }));
96+
fill('engine.studio.data.nameLabel', 'engine.studio.data.idLabel', 'Leave request', 'leave_request');
97+
await waitFor(() => expect(onCreated).toHaveBeenCalled());
98+
expect(ensure).toHaveBeenCalledWith('com.vendor.hr');
99+
expect(save).toHaveBeenCalledTimes(1);
100+
const [type, name, body, opts] = save.mock.calls[0] as unknown as [string, string, any, any];
101+
expect([type, name]).toEqual(['object', 'hrx_leave_request']);
102+
expect(opts).toMatchObject({ mode: 'draft', packageId: 'com.vendor.hr.custom', ifNoneMatch: '*' });
103+
expect(body).toHaveProperty('sharingModel', 'public_read');
104+
expect(publish).toHaveBeenCalledWith(expect.anything(), { type: 'object', name: 'hrx_leave_request', packageId: 'com.vendor.hr.custom' }, false);
105+
expect(onCreated).toHaveBeenCalledWith({ name: 'hrx_leave_request', packageId: 'com.vendor.hr.custom' });
106+
expect(joinMenu).not.toHaveBeenCalled();
107+
});
108+
109+
it('CONTROL — an object in a writable package: no ensure, the list package is written and the object joins its menu', async () => {
110+
const onCreated = open('object', 'com.example.crm', false);
111+
fill('engine.studio.data.nameLabel', 'engine.studio.data.idLabel', 'Lead', 'lead');
112+
await waitFor(() => expect(onCreated).toHaveBeenCalledWith({ name: 'crm_lead', packageId: 'com.example.crm' }));
113+
expect(ensure).not.toHaveBeenCalled();
114+
expect(save.mock.calls[0]?.[3]).toMatchObject({ packageId: 'com.example.crm' });
115+
await waitFor(() => expect(joinMenu).toHaveBeenCalledTimes(1));
116+
});
117+
118+
it('a flow on a read-only base: from a starting point, written to the pair, born off', async () => {
119+
const onCreated = open('flow', 'com.vendor.hr', true);
120+
fireEvent.click(screen.getByTestId('create-flow-preset-manual'));
121+
fill('engine.studio.auto.nameLabel', 'engine.studio.auto.idLabel', 'Escalate', 'escalate');
122+
await waitFor(() => expect(onCreated).toHaveBeenCalledWith({ name: 'escalate', packageId: 'com.vendor.hr.custom' }));
123+
expect(ensure).toHaveBeenCalledWith('com.vendor.hr');
124+
const [type, , body, opts] = save.mock.calls[0] as unknown as [string, string, any, any];
125+
expect(type).toBe('flow');
126+
expect(opts).toMatchObject({ packageId: 'com.vendor.hr.custom' });
127+
expect(body.status).toBe('obsolete');
128+
expect(JSON.stringify(body)).toContain('"triggerType":"manual"');
129+
});
130+
131+
it('a starting point that watches an object writes nothing until it has one', async () => {
132+
const onCreated = open('flow', 'com.vendor.hr', true);
133+
fireEvent.click(screen.getByTestId('create-flow-preset-record_created'));
134+
fill('engine.studio.auto.nameLabel', 'engine.studio.auto.idLabel', 'On hire', 'on_hire');
135+
expect(await screen.findByText(t('engine.studio.auto.preset.needsObject', L))).toBeInTheDocument();
136+
expect(ensure).not.toHaveBeenCalled();
137+
expect(save).not.toHaveBeenCalled();
138+
expect(onCreated).not.toHaveBeenCalled();
139+
});
140+
});

0 commit comments

Comments
 (0)