Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit d3fd5e4

Browse files
fix(app-shell): page scope collects the missed object arms; interface list reuses the package scope (objectui#12980) (#13003)
Part of #12980 Clause-②: no Part 5 of #12980: part 1's object-scope leftovers 2 and 3 (ACCEPT `6253365954`, contract review `6253321662` items ① 7 and ① 9). This PR does not close the card. Its leftover 1 (the chrome hooks in a package-less app) and the card's items 2 and 3 are not addressed here. ## What changed **Leftover 2: the object arms the page derivation missed.** `pageObjectNames` (`packages/app-shell/src/console/appObjectScope.ts`) now also collects each arm below. Each one was checked against the renderer that reads it: | Arm | Renderer read | Collected | |---|---|---| | `data.object` when `data.provider === 'object'` (the `ViewDataSchema` object arm on `object-grid` / `object-map` / the other view-data blocks) | `resolveRecordSourceObjectName` in `@object-ui/core`, the record source every view-data block resolves first | yes | | `element:metadata_viewer` `properties.object` | `StateMachineView` reads it with `useMetadataItem('object', object)`. `FlowView` and `PermissionView` do not read it | yes, only when `properties.type === 'state_machine'` | | `record:line_items` `properties.childObject` | `LineItemsPanel`: `find(childObject)` / `getObjectSchema(childObject)` | yes | | `record:line_items` `properties.parentObject` | `LineItemsPanel`: the parent leg of the save batch (`buildMasterDetailEditBatch`) | yes | | `parentDataSource.object` (`record:related_list`'s parent binding) | `ParentRecordBinding` resolves it on render | yes (bounded in-place fix, see Acceptance notes) | | `addPicker.object` as the card spells it, i.e. `record:related_list` `add.picker.object` | `RelatedList` reads it only once the user opens the picker (`pickerOpen` gate), through the data adapter | **no**: it is never read while the page renders, and collecting it would hold the route on a read the open does not use | The derivation reads only string values. An expression envelope, a non-string, a `data` array of pre-fetched records (the `object-calendar` arm) and any other `data` provider bind nothing. The per-block arms live in a `Map` keyed by block type, so a prototype key such as `toString` cannot match. `PageView` needs no change because it reads the same derivation through `readPageObjectScope`. **Leftover 3: `InterfaceListPage`'s second read.** The list page now finds the app the same way `nav:menu` does (`useParams().appName`, else `useNavigationContext().currentAppName`, matched over the active apps). It reads its source as `readObjectScope({ packageId, names: [source] })` when the app names a package, and as `{ names: [source] }` otherwise. `readObjectScope` itself is unchanged. ## Premises, measured - **P1 (leftover 2).** With the new arm collection removed (the ablation below, i.e. main's derivation), a page that binds objects only through these arms draws first with each arm object unknown. `recordHref` returns `''` for each one, so the object is read by name on demand. None of the arms was already collected some other way. - **P2 (leftover 3).** Yes, it is a second request. In a package app the route's `object?package=app.crm` already returned the source. Without the `packageId` pass, the list page then issues `object/crm_account` again. The cause: the names-only scope is a separate scope entry, and the package list does not fill the provider's by-name cache. ## Pins - (a) `packages/app-shell/src/console/__tests__/AppContent.pageScopeArms-12980.test.tsx` runs the real `MetadataProvider`, `AppContent` and `PageView`. A page binds five objects of another package, and only through the new arms. Every arm object is known on the page's first render. Each one is read once, by name, beside the package list, and there is no whole-registry `meta/object`. - (a) `packages/app-shell/src/console/__tests__/pageObjectNames.arms-12980.test.ts` is a unit pin for each arm. It also pins what is not collected: `add.picker.object`, a non-state-machine viewer, expression envelopes, non-strings, the `value` arm, a `data` array, and a prototype-key block type. - (b) and (c) are in `packages/app-shell/src/views/__tests__/InterfaceListPage.packageScope-12980.test.tsx`, which uses the real `MetadataProvider` with the real `readPageObjectScope` as the route's half. (b) In a package app, the object calls are exactly `object?package=app.crm`. (c) CONTROL: in an app with no package, the call is exactly `object/crm_account`, once. - (c) CONTROL: the #12811 app-route call set in `AppContent.pageRouteObjects-12980` is unchanged (green, including during ablation A). ## Ablations (one per half; restore proven by blob hash) Both ablations ran through `ablation-replace.mjs` in wrap mode, under the shared verify lock: - **A: new arm collection dropped** (`appObjectScope.ts` back to main's `dataSource`-only lines). Anchor 1 to 0, blob `8c64252eae8c` to `c37798f6a25d`. Result: (a) red (the first-render hrefs were all `''`), 4 of the 6 unit pins red (the 2 negative pins stay green, as expected), and the `pageRouteObjects-12980` CONTROL green. Restored: blob `8c64252eae8c` == HEAD, `git diff HEAD` empty. - **B: `packageId` pass dropped** (`InterfaceListPage.tsx` back to `{ names: [cfg.source] }`). Blob `3b887aa20866` to `1f1156780f8e`. Result: (b) red (it received the extra `object/crm_account`), (c) CONTROL green. Restored: blob `3b887aa20866` == HEAD, `git diff HEAD` empty. ## Gates (at `3c48263b22`) - Closure build `turbo run build --filter='@object-ui/app-shell^...' --concurrency=2`: 28/28 tasks, exit 0. - `pnpm --filter @object-ui/app-shell type-check` (`tsc --noEmit && tsc -p tsconfig.test.json`): exit 0. The three new test files are in the test project (`--listFilesOnly`). - Targeted vitest (`--maxWorkers=1`) over the new and edited tests plus every test file naming `pageObjectNames`, `appObjectScope`, `pageRouteObjects-12980`, `pageObjectReads-12980`, `InterfaceListPage` or `namesOnlyScope`: 39 files, 611 tests passed. **The whole `packages/app-shell/` directory is declared to CI** and was not run locally. - Lint, narrowed to the 11 changed `.ts`/`.tsx` files with `eslint --no-inline-config --format json`: 11 files, 0 errors, 110 warnings (`no-explicit-any` and the like, the files' existing style). Type-aware linting is not enabled in `eslint.config.js` (no `parserOptions.project` / `projectService`), so this diff cannot move any untouched file's verdict. - Pre-tsc battery, each exit 0: `check:phantom-deps`, `check:self-import`, `check:unreferenced-sources`, `check:doc-example-readers`, `check:handler-key-reads`, `check:side-effects-array`, `check:element-data-source-declaration`, `check:spec-symbols`, `check:action-forward-parity`, `check:designer-field-key-parity`, `check:icon-record-names`, `check:i18n-keys`, `check:i18n-drift`, `check:i18n-designer-parity`, `check:control-bytes`, `check-hand-rolled-comment-mask.mjs`. - `check-changeset-fixed.mjs`, `check-changeset-presence.mjs`, `check-changeset-no-major.mjs` and `check:new-line-citations` (0 new citations): exit 0. ## Acceptance notes - **Bounded in-place fix: `parentDataSource.object`.** It is not on the order's list. It is the same defect class (an `ElementDataSourceSchema` object arm the derivation skipped), the fix is mechanical (one key added beside `dataSource`), it is in the same claimed file, and the same pins cover it. Evidence: `ParentRecordBinding` resolves it on render, and the unit pin and pin (a) bind it. - **Not collected: `add.picker.object`.** See the table. The card's spelling `addPicker.object` does not exist in `@objectstack/spec` or in any renderer; the real key is `add.picker.object`. If the seat prefers to collect it anyway, it is a one-entry addition to `BLOCK_OBJECT_ARMS`. - **Six test files beside `InterfaceListPage.tsx` were edited**: their hand-written `react-router-dom` mocks now name `useParams` (one line each). Before that, 31 tests in those six files failed with `No "useParams" export is defined on the "react-router-dom" mock`. - The order's lock section says no whole-package-directory runs, while its gates section says to run each touched package's directory under the lock. I followed the lock section and declared the directory to CI. --- _Generated by [Claude Code](https://claude.ai/code/session_01XVp19E1MYUTFM3dnkwz8gB)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0d97642 commit d3fd5e4

12 files changed

Lines changed: 572 additions & 14 deletions
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
---
4+
5+
A page route reads more of the objects its page binds in its own scope read, and an interface list page inside a package app no longer reads its source object a second time (objectui#12980, part 5).
6+
7+
- **The object arms a page can bind.** Part 1 derived a page's objects from its `object`, `interfaceConfig.source`, every `objectName` and every `dataSource.object`. The derivation now also collects `data.object` on the `ViewDataSchema` object arm (`data: { provider: 'object', object }`, the record source the `object-*` blocks resolve first), `parentDataSource.object` (`record:related_list`'s parent binding), `element:metadata_viewer`'s `object` when its view is `state_machine`, and `record:line_items`' `childObject` and `parentObject`. Such an object is read beside the page's other objects before the page draws, instead of by name once a block asks for it. Only string values count; an expression envelope binds nothing. `record:related_list`'s `add.picker.object` is not collected: the list reads it only when the user opens the picker.
8+
- **The interface list page's source.** Inside an app that names a package, the list page reads its source through the app's scope, as `nav:menu`'s capability gate does, so the page route's scope read, which already holds the source, is reused. Before, a source the app's package holds was requested again by name. Outside a package app it still reads the source by name.
9+
10+
Nothing is added to a package entry: no export, prop or type member.
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectui#12980 — a page that binds an object only through one of the arms
5+
* part 1's derivation missed has it in the page route's scope read, so the
6+
* page draws with it known: no on-demand by-name read once a block asks.
7+
*
8+
* The arms (`pageObjectNames`): `data.object` on the `ViewDataSchema` object
9+
* arm, `element:metadata_viewer`'s `object` (state-machine view),
10+
* `record:line_items`' `childObject` / `parentObject`, and
11+
* `record:related_list`'s `parentDataSource.object`. Each binds an object of
12+
* another package, so the route reads it by name beside the app's package list.
13+
*
14+
* The harness is `AppContent.pageRouteObjects-12980.test.tsx`'s: the REAL
15+
* `MetadataProvider` under the real `AppContent` and the real `PageView`, with
16+
* a client double that records each call as its URL would read. The page's
17+
* blocks are a stand-in that asks the page's record navigator, on its FIRST
18+
* render, for a record link of each arm's object, as a lookup cell does: an
19+
* object in the route's scope answers at once; one outside it answers `''`
20+
* and is read by name on demand.
21+
*
22+
* The CONTROL (the #12811 app-route call set, a page that binds none) stays
23+
* in `AppContent.pageRouteObjects-12980.test.tsx`.
24+
*/
25+
26+
import '@testing-library/jest-dom/vitest';
27+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
28+
import React, { useEffect } from 'react';
29+
import { cleanup, render, screen, waitFor } from '@testing-library/react';
30+
import { MemoryRouter, Routes, Route, useNavigate, type NavigateFunction } from 'react-router-dom';
31+
import { AuthProvider, ActiveOrganizationStorage } from '@object-ui/auth';
32+
import type { AuthClient, AuthOrganization } from '@object-ui/auth';
33+
34+
vi.mock('@object-ui/plugin-designer', async (importOriginal) => ({
35+
...(await importOriginal<typeof import('@object-ui/plugin-designer')>()),
36+
CreateAppPage: () => null,
37+
EditAppPage: () => null,
38+
DashboardDesignPage: () => null,
39+
}));
40+
// The chrome: what the sidebar's capability gate asks, and the list it is handed.
41+
vi.mock('../../layout/ConsoleLayout', async () => {
42+
const { useNavMemberGates } = await import('../../hooks/useNavMemberGates');
43+
return {
44+
ConsoleLayout: ({ children, objects }: { children?: React.ReactNode; objects: Array<{ name: string }> }) => {
45+
const gates = useNavMemberGates();
46+
return (
47+
<div data-testid="console-layout" data-chrome-objects={objects.map((o) => o.name).join(',')}>
48+
<span data-testid="cloud-only-entry">{String(gates.checkCapability('object', 'cloud_only'))}</span>
49+
{children}
50+
</div>
51+
);
52+
},
53+
};
54+
});
55+
vi.mock('../../chrome/CommandPalette', () => ({ CommandPalette: () => null }));
56+
// The page's Studio affordance asks the package catalog; this open asks for no Studio button.
57+
vi.mock('../../hooks/useStudioDesignGate', () => ({ useStudioDesignGate: () => null }));
58+
vi.mock('../../chrome/KeyboardShortcutsDialog', () => ({ KeyboardShortcutsDialog: () => null }));
59+
vi.mock('../../chrome/OnboardingWalkthrough', () => ({ OnboardingWalkthrough: () => null }));
60+
vi.mock('../../views/ObjectView', () => ({
61+
ObjectView: ({ objects }: { objects: Array<{ name: string }> }) => (
62+
<div data-testid="object-view">{objects.map((o) => o.name).join(',')}</div>
63+
),
64+
}));
65+
vi.mock('@object-ui/i18n', async (importOriginal) => ({
66+
...(await importOriginal<Record<string, unknown>>()),
67+
useObjectTranslation: () => ({
68+
t: (key: string, options?: Record<string, unknown>) => String(options?.defaultValue ?? key),
69+
}),
70+
useObjectLabel: () => ({ objectLabel: ({ label }: { label?: string }) => label, objectPluralLabel: () => '' }),
71+
}));
72+
73+
const dataSourceStub = {
74+
onConnectionStateChange: () => () => {},
75+
getConnectionState: () => 'connected',
76+
};
77+
vi.mock('../../providers/AdapterProvider', async (importOriginal) => ({
78+
...(await importOriginal<Record<string, unknown>>()),
79+
useAdapter: () => dataSourceStub,
80+
}));
81+
82+
const actionRunnerStub = { registerHandler: vi.fn(), getContext: () => ({}) };
83+
const probe = vi.hoisted(() => ({
84+
armObjects: ['svc_case', 'svc_ticket', 'svc_line', 'svc_order', 'svc_account'],
85+
first: null as Record<string, string> | null,
86+
}));
87+
vi.mock('@object-ui/react', async (importOriginal) => {
88+
const actual = await importOriginal<typeof import('@object-ui/react')>();
89+
return {
90+
...actual,
91+
useActionRunner: () => ({ execute: vi.fn(), runner: actionRunnerStub }),
92+
useGlobalUndo: () => {},
93+
useMutationInvalidationBridge: () => {},
94+
// Stands in for the page's blocks: on its first render it asks the record
95+
// navigator the page publishes for a link to a record of each arm's object.
96+
SchemaRenderer: () => {
97+
const navigator = actual.useRelatedRecordActions();
98+
if (!probe.first) {
99+
probe.first = Object.fromEntries(
100+
probe.armObjects.map((name) => [name, navigator?.recordHref?.(name, 'r1') ?? '']),
101+
);
102+
}
103+
return <div data-testid="page-blocks" />;
104+
},
105+
};
106+
});
107+
108+
import { AppContent } from '../AppContent';
109+
import { MetadataProvider } from '../../providers/MetadataProvider';
110+
import { useActionModal } from '../../hooks/useActionModal';
111+
112+
const CRM = 'app.crm';
113+
const SERVICE = 'app.service';
114+
const OBJECTS = [
115+
{ name: 'crm_account', _packageId: CRM, fields: {} },
116+
{ name: 'svc_case', _packageId: SERVICE, fields: {} },
117+
{ name: 'svc_ticket', _packageId: SERVICE, fields: {} },
118+
{ name: 'svc_line', _packageId: SERVICE, fields: {} },
119+
{ name: 'svc_order', _packageId: SERVICE, fields: {} },
120+
{ name: 'svc_account', _packageId: SERVICE, fields: {} },
121+
];
122+
123+
/** A page whose blocks bind objects only through the arms part 1's derivation missed. */
124+
const ARMS_PAGE = {
125+
name: 'service_board',
126+
label: 'Service board',
127+
type: 'app',
128+
regions: [
129+
{
130+
name: 'main',
131+
components: [
132+
{ type: 'object-grid', properties: { data: { provider: 'object', object: 'svc_case' } } },
133+
{ type: 'element:metadata_viewer', properties: { type: 'state_machine', name: 'lifecycle', object: 'svc_ticket' } },
134+
{ type: 'record:line_items', properties: { childObject: 'svc_line', parentObject: 'svc_order' } },
135+
{
136+
type: 'record:related_list',
137+
properties: { objectName: 'crm_account', relationshipField: 'account', parentDataSource: { object: 'svc_account' } },
138+
},
139+
],
140+
},
141+
],
142+
};
143+
const PAGES = [ARMS_PAGE];
144+
const NAVIGATION = [{ id: 'n1', type: 'object', label: 'Accounts', objectName: 'crm_account' }];
145+
146+
interface Server {
147+
calls: string[];
148+
apps: unknown[];
149+
pages: unknown[];
150+
holdByName: boolean;
151+
release: () => void;
152+
}
153+
const server: Server = { calls: [], apps: [], pages: [], holdByName: false, release: () => {} };
154+
155+
function makeAdapter() {
156+
const held: Array<() => void> = [];
157+
server.release = () => held.splice(0).forEach((go) => go());
158+
return {
159+
clearCache: vi.fn(),
160+
getClient: () => ({
161+
meta: {
162+
getItems: (type: string, options?: { packageId?: string }) => {
163+
server.calls.push(options?.packageId ? `${type}?package=${options.packageId}` : type);
164+
const all = type === 'object' ? OBJECTS : type === 'app' ? server.apps : type === 'page' ? server.pages : [];
165+
const items = options?.packageId ? all.filter((o: any) => o._packageId === options.packageId) : all;
166+
return Promise.resolve({ type, items: structuredClone(items) });
167+
},
168+
getItem: (type: string, name: string) => {
169+
server.calls.push(`${type}/${name}`);
170+
const item = (type === 'object' ? OBJECTS : []).find((o) => o.name === name);
171+
const answer = () =>
172+
item ? Promise.resolve({ type, name, item: structuredClone(item) }) : Promise.reject(new Error('404'));
173+
if (!server.holdByName) return answer();
174+
return new Promise((resolve, reject) => held.push(() => answer().then(resolve, reject)));
175+
},
176+
},
177+
}),
178+
} as unknown as Parameters<typeof MetadataProvider>[0]['adapter'];
179+
}
180+
181+
const USER = 'u_12980';
182+
const ORG: AuthOrganization = { id: 'org_a', name: 'Org A', slug: 'a' };
183+
184+
function authClient(): AuthClient {
185+
return {
186+
getSession: vi.fn(async () => ({
187+
// An admin by position: the workspace-admin verdict needs no member row.
188+
user: { id: USER, name: 'Ada', email: 'ada@test.com', role: 'admin', positions: ['admin'] },
189+
session: { token: 'tok-12980', activeOrganizationId: ORG.id },
190+
})),
191+
signOut: vi.fn(async () => undefined),
192+
getConfig: vi.fn(async () => ({ features: {} })),
193+
listOrganizations: vi.fn(async () => [ORG]),
194+
getActiveOrganization: vi.fn(async () => ORG),
195+
setActiveOrganization: vi.fn(async () => ORG),
196+
getActiveMember: vi.fn(async () => ({ id: 'm1', organizationId: ORG.id, userId: USER, role: 'owner' })),
197+
} as unknown as AuthClient;
198+
}
199+
200+
/** `ConsoleShell` mounts `useActionModal` at the console root. */
201+
function ActionModalHost() {
202+
const { modalElement } = useActionModal(dataSourceStub);
203+
return <>{modalElement}</>;
204+
}
205+
206+
const nav: { current: NavigateFunction | null } = { current: null };
207+
function NavProbe() {
208+
const navigate = useNavigate();
209+
useEffect(() => { nav.current = navigate; });
210+
return null;
211+
}
212+
213+
function boot(url: string) {
214+
render(
215+
<AuthProvider authUrl="/api/auth" client={authClient()}>
216+
<MetadataProvider adapter={makeAdapter()}>
217+
<MemoryRouter initialEntries={[url]}>
218+
<NavProbe />
219+
<ActionModalHost />
220+
<Routes>
221+
<Route path="/apps/:appName/*" element={<AppContent />} />
222+
</Routes>
223+
</MemoryRouter>
224+
</MetadataProvider>
225+
</AuthProvider>,
226+
);
227+
}
228+
229+
const objectCalls = () => server.calls.filter((c) => c === 'object' || c.startsWith('object?') || c.startsWith('object/'));
230+
231+
beforeEach(() => {
232+
probe.first = null;
233+
server.calls = [];
234+
server.holdByName = false;
235+
server.apps = [{ name: 'crm', label: 'CRM', _packageId: CRM, navigation: NAVIGATION }];
236+
server.pages = PAGES;
237+
localStorage.clear();
238+
sessionStorage.clear();
239+
ActiveOrganizationStorage.clear();
240+
});
241+
242+
afterEach(() => {
243+
cleanup();
244+
ActiveOrganizationStorage.clear();
245+
});
246+
247+
248+
describe('a page bound through the missed object arms reads them in the route scope (objectui#12980)', () => {
249+
it('(a) every arm object is known on the page\'s first render, read by name beside the package list, never the whole registry', async () => {
250+
boot('/apps/crm/page/service_board');
251+
await waitFor(() => expect(screen.getByTestId('page-blocks')).toBeInTheDocument());
252+
253+
// Known on the first render: the route held the page until they answered,
254+
// so no block's ask had to start an on-demand read.
255+
expect(probe.first).toEqual(
256+
Object.fromEntries(probe.armObjects.map((name) => [name, `/apps/crm/${name}/record/r1`])),
257+
);
258+
expect(objectCalls()).not.toContain('object');
259+
expect(objectCalls()[0]).toBe(`object?package=${CRM}`);
260+
for (const name of probe.armObjects) expect(objectCalls()).toContain(`object/${name}`);
261+
// Each asked once: the scope's read is the only one.
262+
expect(objectCalls().filter((c) => c.startsWith('object/')).length).toBe(probe.armObjects.length);
263+
});
264+
});
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectui#12980 — `pageObjectNames` collects every object arm a block's
5+
* renderer reads, so an object a page binds through one of them is in the
6+
* page route's scope read rather than read by name on demand.
7+
*
8+
* The arms, each measured against its renderer:
9+
*
10+
* - `data: { provider: 'object', object }` — the `ViewDataSchema` object arm,
11+
* the record source the `object-*` blocks resolve first
12+
* (`resolveRecordSourceObjectName` in `@object-ui/core`).
13+
* - `element:metadata_viewer`'s `object` — read by the state-machine view
14+
* only (`useMetadataItem('object', object)`).
15+
* - `record:line_items`'s `childObject` and `parentObject`.
16+
* - `parentDataSource.object` — `record:related_list`'s parent binding,
17+
* read by `ParentRecordBinding`.
18+
*
19+
* And what is NOT collected: an arm no renderer reads while the page renders
20+
* (`add.picker.object`, read on picker open), a metadata viewer whose view
21+
* does not read `object`, a `data` array of pre-fetched records, and any value
22+
* that is not a string (an expression envelope included).
23+
*/
24+
25+
import { describe, it, expect } from 'vitest';
26+
import { pageObjectNames } from '../appObjectScope';
27+
28+
const page = (components: unknown[]) => ({
29+
name: 'p',
30+
type: 'app',
31+
regions: [{ name: 'main', components }],
32+
});
33+
34+
describe('pageObjectNames collects the object arms a block renderer reads (objectui#12980)', () => {
35+
it('collects data.object on the ViewDataSchema object arm', () => {
36+
expect(
37+
pageObjectNames(page([{ type: 'object-grid', properties: { data: { provider: 'object', object: 'crm_case' } } }])),
38+
).toEqual(['crm_case']);
39+
expect(
40+
pageObjectNames(page([{ type: 'object-map', properties: { data: { provider: 'object', object: 'crm_site' } } }])),
41+
).toEqual(['crm_site']);
42+
});
43+
44+
it("collects element:metadata_viewer's object for the state-machine view only", () => {
45+
expect(
46+
pageObjectNames(
47+
page([{ type: 'element:metadata_viewer', properties: { type: 'state_machine', name: 'lifecycle', object: 'crm_ticket' } }]),
48+
),
49+
).toEqual(['crm_ticket']);
50+
expect(
51+
pageObjectNames(page([{ type: 'element:metadata_viewer', properties: { type: 'flow', name: 'f', object: 'crm_ticket' } }])),
52+
).toEqual([]);
53+
});
54+
55+
it("collects record:line_items' childObject and parentObject", () => {
56+
expect(
57+
pageObjectNames(
58+
page([{ type: 'record:line_items', properties: { childObject: 'crm_order_line', parentObject: 'crm_order' } }]),
59+
).sort(),
60+
).toEqual(['crm_order', 'crm_order_line']);
61+
});
62+
63+
it("collects record:related_list's parentDataSource.object", () => {
64+
expect(
65+
pageObjectNames(
66+
page([
67+
{
68+
type: 'record:related_list',
69+
properties: { objectName: 'crm_contact', relationshipField: 'account', parentDataSource: { object: 'crm_account' } },
70+
},
71+
]),
72+
).sort(),
73+
).toEqual(['crm_account', 'crm_contact']);
74+
});
75+
76+
it('does not collect add.picker.object, which the related list reads only on picker open', () => {
77+
expect(
78+
pageObjectNames(
79+
page([
80+
{
81+
type: 'record:related_list',
82+
properties: { objectName: 'crm_contact', relationshipField: 'account', add: { picker: { object: 'crm_tag' } } },
83+
},
84+
]),
85+
),
86+
).toEqual(['crm_contact']);
87+
});
88+
89+
it('reads only strings: no expression envelope, no non-string, no other data arm, no array of records', () => {
90+
expect(
91+
pageObjectNames(
92+
page([
93+
{ type: 'object-grid', properties: { data: { provider: 'object', object: { $expr: 'params.object' } } } },
94+
{ type: 'object-grid', properties: { data: { provider: 'object', object: 42 } } },
95+
{ type: 'object-grid', properties: { data: { provider: 'value', items: [] } } },
96+
{ type: 'object-calendar', properties: { data: [{ provider: 'object', object: 'crm_record_field' }] } },
97+
{ type: 'element:metadata_viewer', properties: { type: 'state_machine', object: { $expr: 'x' } } },
98+
{ type: 'record:line_items', properties: { childObject: ['crm_order_line'], parentObject: '' } },
99+
{ type: 'toString', properties: { type: 'state_machine', object: 'crm_ticket' } },
100+
]),
101+
),
102+
).toEqual([]);
103+
});
104+
});

0 commit comments

Comments
 (0)