Skip to content

Commit 2fea6d2

Browse files
fix(plugin-designer, app-shell): app writers save a packaged app at its package (#35151)
<!-- claude-projects-attribution: {"github_login":"os-warren"} --> _Requested by **Warren** · [project thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8AJJJRiYjshMUNgyMZSqBsr)_ Fixes #35115 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:控制台「编辑应用」向导和导航同步(新建/删除页面、仪表盘时自动改应用导航)在保存属于某个软件包的应用时,现在带上该包(`?package=`),与读取时用的是同一个地址;不属于任何包的应用保持原来的无包地址。 - 为什么改:之前读的是包里的那一行,写却落到无包地址,编辑一个包内应用(名称、导航)可能写到错误的层,不在应用所属的包里。 - 风险与回滚:只改两处前端写入的地址;受管包的密封应用(ADR-0131 D6)在任一地址都被服务端拒绝,导航同步也照旧跳过它,没有放宽写入面。回滚即还原本 PR。 - 先看:`ui/packages/app-shell/src/hooks/useNavigationSync.ts`(新增 `appAddress`,读、写、撤销共用它);`ui/packages/plugin-designer/src/pages/EditAppPage.tsx`(保存带 `servedPackageId`);两个 `*-35115` 测试文件。 - 两分钟验证:`pnpm --dir ui exec vitest run packages/plugin-designer/src/__tests__/EditAppPage.packageScope-35115.test.tsx packages/app-shell/src/hooks/__tests__/useNavigationSync.packageScope-35115.test.tsx`,预期 2 个文件、6 个用例全绿。 - 需要你做的:无,席位落地。 ## What changes - [x] **N3.** Both console app writers now read and save an app at the package that owns it. - `EditAppPage` already read the stored app at the served `_packageId`; its save now passes the same package as `{ packageId }` (the SDK sends `?package=`). One `owningPackage` reading decides the address for both the read and the save, the same reading App management's `saveApp` uses: a missing `_packageId` and the server's `sys_metadata` sentinel are package-less, so a package-less app keeps the package-less read and save (a three-argument `saveItem`, byte-identical to before). - `useNavigationSync` gains `appAddress(appName)`: the served app's name and its owning package (`isPackageLessItem` from `studioScope`, the existing package-less predicate). `storedApp` reads at it, and `saveApp` (so every navigation write and every Undo) saves at it. - ADR-0131 D6 holds: the all-apps writes still skip a sealed managed app (`isNavigationSyncableApp`, unchanged), and the server's save door refuses a write onto an artifact-backed app of a type with no overlay channel whether or not the write names its package (`refusePackagedBaseOverride`: `ITEM_LOCKED` when it names the read-only base, `NOT_OVERRIDABLE` otherwise). Naming the package writes nothing the package-less save did not. - [ ] **N1, left unticked.** No existing locale key fits `edit-app-load-failed` ("Application NAME could not be read for editing: REASON"): the `appDesigner.*` group holds wizard chrome only, and `common.*` has no read-failure sentence. `EditAppPage` uses no translation hook at all, and its sibling strings (not found, the success and failure toasts) are hard-coded too. A new key means every locale pack plus the `DESIGNER_DEFAULT_TRANSLATIONS` mirror, which is beyond a copy nit. - [ ] **N2, left unticked; its premise is half gone.** Measured on the code: a *refused* authored read already shows its own message. `getAuthoredItem` rejects with the `MetadataError` its `parseError` builds from the server's `error.message`, and the page's `reason()` passes that `message` through. The "unknown error" comes only from the *empty* read (`getAuthoredItem` answers `null` when no layer holds the app), where `saveApp` throws a bare `Error()` and there is no server sentence to show. Saying something better there needs a new `appManagement.toast.*` key in every pack, so it is left. ## Tests - New pins, one file per writer, named for this card: - `ui/packages/plugin-designer/src/__tests__/EditAppPage.packageScope-35115.test.tsx`: a packaged app is read and saved at its package; a package-less app, and one served with `sys_metadata`, read with `{}` and save with three arguments. - `ui/packages/app-shell/src/hooks/__tests__/useNavigationSync.packageScope-35115.test.tsx`: the same three cases for a navigation write, including the Undo save. - One existing assertion changed: `useNavigationSync.authoredApp-35054.test.tsx` pinned the package-less read of its packaged fixture (`_packageId: 'com.qa.tr'`), the defect this card fixes; it now expects `{ packageId: 'com.qa.tr' }`. ## Acceptance notes - `useNavigationSync` now writes at the served app's `name`, not at the `appName` argument: the two differ only when a caller passes a route segment (a package id), which no in-repo caller does (the all-apps methods pass `app.name`). - The `sys_metadata` sentinel constant now has one more module-local copy (`EditAppPage`, beside `MetadataObjectsPage`, `AppManagementPage`, `studioScope` and `appRoute`); plugin-designer cannot import app-shell's predicate. Not filed: no defect, a consolidation. - The write address was measured at the unit layer (the `saveItem` options the page and hook hand the SDK, and `metaSaveQuery` turning `packageId` into `?package=`); NOT MEASURED live against a booted server. ## Verification All readings at head `338b3971` (tree `objectstack-ai/objectstack`, merge base `aef42cba4`). <details><summary>Tests and type-check</summary> - `pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-designer/src/__tests__/ packages/app-shell/src/hooks/__tests__/ packages/app-shell/src/views/metadata-admin/ResourceEditPage.navigationWrites-28680.test.tsx packages/app-shell/src/preview/__tests__/ apps/console/src/pages/system/__tests__/` (lock VERDICT command-exit 0): Test Files 184 passed (184), Tests 1622 passed (1622). The two new pin files re-run at head: 2 files, 6 tests passed. - `pnpm --filter @object-ui/plugin-designer --filter @object-ui/app-shell run type-check`: both `tsc --noEmit` and `tsc -p tsconfig.test.json` legs exit 0 (the app-shell re-run after a test-only cast fix, lock VERDICT command-exit 0). </details> <details><summary>Ablations (scripts/ablation-replace.mjs, each restored with blob == HEAD and git diff HEAD empty)</summary> Subjects are imported by relative source path, so no build sits between the mutation and the run. 1. `EditAppPage` save without `{ packageId: servedPackageId }`: the packaged case RED (`expected undefined to deeply equal { packageId: 'com.qa.scope' }`), the package-less and sentinel cases GREEN. Blob 844e7d4 to 87b19d7c, restored to 844e7d4. 2. `useNavigationSync` save without `{ packageId: address.packageId }`: the packaged case RED (`expected [ 'app', 'qa_scope_app', undefined ] to deeply equal [ 'app', 'qa_scope_app', …(1) ]`), the other two GREEN. Blob 0b302ec to 9b7f237d, restored to 0b302ec. 3. `useNavigationSync` read without the package: the packaged case RED on `getAuthoredItem` called with the package, the other two GREEN. Blob 0b302ec to 681d055e, restored to 0b302ec. Direction in each: the one predicted in the file headers. </details> <details><summary>Derived gate families</summary> - `node scripts/pm/dispatch-gates.mjs --commands`: 38 commands; all 38 run, each exit 0 (`--ran` reconciliation: 38 derived, 38 run, 0 NOT-MEASURED, 0 UNRUN, all carrying exit codes). The `--ran` run flagged `scripts/check-skill-identifier-liveness.mjs` as changed on origin/main after the merge base; this diff touches no skill, and CI runs the current copy. - `node scripts/pm/overlap-check.mjs`: VERDICT clean exit 0 (merges cleanly with origin/main). - Everything else CI runs (type-check lanes, Test UI shards, the whole-tree and roster families) is left to CI. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent a6cf988 commit 2fea6d2

6 files changed

Lines changed: 317 additions & 21 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@object-ui/plugin-designer': patch
3+
'@object-ui/app-shell': patch
4+
'@object-ui/console': patch
5+
---
6+
7+
fix(plugin-designer, app-shell): a packaged app is saved at its package, not at the package-less address
8+
9+
Clause-②: no
10+
Metadata-protocol: none
11+
12+
The Edit app wizard read a packaged app at its package but saved it with no package, and the navigation sync that adds or removes an entry when a page or dashboard is created or deleted read and saved every app with no package. Both now read and save an app a package owns with `{ packageId }` (sent as `?package=`), the row the console serves, the way App management already saves it. An app no package owns, including one served with the `sys_metadata` sentinel, keeps the package-less address. A managed package's sealed app is still refused by the server at either address, and the navigation sync still skips it.

‎ui/packages/app-shell/src/hooks/__tests__/useNavigationSync.authoredApp-35054.test.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ describe('a navigation write sends the authored app (objectstack#35054)', () =>
105105
const getAuthoredItem = vi.fn(async () => SOURCE);
106106
const saveItem = await addPage(getAuthoredItem);
107107

108-
expect(getAuthoredItem).toHaveBeenCalledWith('app', 'qatr_app');
108+
// Read at the app's package (objectstack#35115), the address the save names.
109+
expect(getAuthoredItem).toHaveBeenCalledWith('app', 'qatr_app', { packageId: 'com.qa.tr' });
109110
expect(saveItem).toHaveBeenCalledTimes(1);
110111
const [type, name, body] = saveItem.mock.calls[0] as [string, string, any];
111112
expect([type, name]).toEqual(['app', 'qatr_app']);
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#35115 — a navigation write reads and saves a packaged app at its
5+
* package.
6+
*
7+
* `useNavigationSync` read the stored app (`getAuthoredItem('app', name)`) and
8+
* saved it (`client.meta.saveItem('app', name, body)`) with no package, so a
9+
* navigation write into an app a package owns went to the package-less
10+
* address (no `?package=`). The read, the save and the Undo now name the
11+
* served app's package (`{ packageId }`, sent as `?package=`); a package-less
12+
* app, and an app served with the server's `sys_metadata` sentinel, keep the
13+
* package-less address.
14+
*
15+
* Direction, written before the run: with the hook left package-less (the
16+
* unmodified tree) the packaged case goes RED on the read's and the save's
17+
* package while the package-less case stays GREEN.
18+
*/
19+
20+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
21+
import React, { useEffect } from 'react';
22+
import { render, waitFor, cleanup } from '@testing-library/react';
23+
import { MetadataCtx, AdapterCtx, type MetadataContextValue } from '@object-ui/react';
24+
import { toast } from 'sonner';
25+
import { useNavigationSync } from '../useNavigationSync';
26+
27+
vi.mock('sonner', () => ({
28+
toast: Object.assign(vi.fn(), { success: vi.fn(), error: vi.fn(), info: vi.fn() }),
29+
}));
30+
31+
/** The app as its author stored it. */
32+
const STORED = {
33+
name: 'qa_scope_app',
34+
label: 'QA Scope App',
35+
navigation: [{ id: 'nav_home', type: 'page', label: 'Home', pageName: 'qa_scope_home' }],
36+
};
37+
38+
function metaValue(apps: Record<string, unknown>[]): MetadataContextValue {
39+
return {
40+
apps,
41+
objects: [],
42+
dashboards: [],
43+
reports: [],
44+
pages: [],
45+
loading: false,
46+
error: null,
47+
refresh: async () => {},
48+
invalidate: () => {},
49+
ensureType: async () => [],
50+
getItem: async () => null,
51+
getItemsByType: () => [],
52+
getTypeStatus: () => 'ready',
53+
} as unknown as MetadataContextValue;
54+
}
55+
56+
/** Add a page to the navigation of every app, the way a page publish does. */
57+
async function addPage(served: Record<string, unknown>) {
58+
const saveItem = vi.fn().mockResolvedValue({});
59+
const getAuthoredItem = vi.fn(async () => STORED);
60+
let done = false;
61+
function Site() {
62+
const { syncPageCreatedAllApps } = useNavigationSync();
63+
useEffect(() => {
64+
void syncPageCreatedAllApps('qa_scope_new_page').then(() => { done = true; });
65+
// Once, on mount: the write is the case.
66+
// eslint-disable-next-line react-hooks/exhaustive-deps
67+
}, []);
68+
return null;
69+
}
70+
const adapter = { getClient: () => ({ meta: { saveItem } }), getAuthoredItem } as unknown as React.ComponentProps<
71+
typeof AdapterCtx.Provider
72+
>['value'];
73+
render(
74+
<AdapterCtx.Provider value={adapter}>
75+
<MetadataCtx.Provider value={metaValue([served])}>
76+
<Site />
77+
</MetadataCtx.Provider>
78+
</AdapterCtx.Provider>,
79+
);
80+
await waitFor(() => expect(done).toBe(true));
81+
return { saveItem, getAuthoredItem };
82+
}
83+
84+
/** Press the success toast's Undo, and wait for its save. */
85+
async function undo(saveItem: ReturnType<typeof vi.fn>) {
86+
const options = vi.mocked(toast.success).mock.calls[0]?.[1] as unknown as { action: { onClick: () => Promise<void> } };
87+
await options.action.onClick();
88+
await waitFor(() => expect(saveItem).toHaveBeenCalledTimes(2));
89+
}
90+
91+
beforeEach(() => vi.clearAllMocks());
92+
afterEach(() => cleanup());
93+
94+
describe('a navigation write addresses the app at its package (objectstack#35115)', () => {
95+
it('a packaged app is read, saved and undone at its package', async () => {
96+
const { saveItem, getAuthoredItem } = await addPage({ ...STORED, _packageId: 'com.qa.scope' });
97+
98+
expect(getAuthoredItem).toHaveBeenCalledWith('app', 'qa_scope_app', { packageId: 'com.qa.scope' });
99+
expect(saveItem).toHaveBeenCalledTimes(1);
100+
const [type, name, body, options] = saveItem.mock.calls[0] as [string, string, any, unknown];
101+
expect([type, name, options]).toEqual(['app', 'qa_scope_app', { packageId: 'com.qa.scope' }]);
102+
// Control: the write's own change is what it carries.
103+
expect(body.navigation).toHaveLength(2);
104+
105+
await undo(saveItem);
106+
expect(saveItem.mock.calls[1]?.[3]).toEqual({ packageId: 'com.qa.scope' });
107+
expect((saveItem.mock.calls[1]?.[2] as any).navigation).toHaveLength(1);
108+
});
109+
110+
it('a package-less app is read, saved and undone with no package', async () => {
111+
const { saveItem, getAuthoredItem } = await addPage({ ...STORED });
112+
113+
expect(getAuthoredItem).toHaveBeenCalledWith('app', 'qa_scope_app');
114+
expect(saveItem).toHaveBeenCalledTimes(1);
115+
expect(saveItem.mock.calls[0]).toHaveLength(3);
116+
expect(saveItem.mock.calls[0]?.slice(0, 2)).toEqual(['app', 'qa_scope_app']);
117+
118+
await undo(saveItem);
119+
expect(saveItem.mock.calls[1]).toHaveLength(3);
120+
});
121+
122+
it('an app served with the sys_metadata sentinel names no package on the read or the save', async () => {
123+
const { saveItem, getAuthoredItem } = await addPage({ ...STORED, _packageId: 'sys_metadata' });
124+
125+
expect(getAuthoredItem).toHaveBeenCalledWith('app', 'qa_scope_app');
126+
expect(saveItem).toHaveBeenCalledTimes(1);
127+
expect(saveItem.mock.calls[0]).toHaveLength(3);
128+
});
129+
});

‎ui/packages/app-shell/src/hooks/useNavigationSync.ts‎

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { useObjectTranslation } from '@object-ui/i18n';
1616
import { useAdapter } from '../providers/AdapterProvider.js';
1717
import { useMetadata } from '../providers/MetadataProvider.js';
1818
import { matchAppBySegment } from '../utils/appRoute.js';
19+
import { isPackageLessItem } from '../views/studio-design/studioScope.js';
1920
import { usePreviewDrafts } from '../preview/PreviewModeContext.js';
2021

2122
// ============================================================================
@@ -274,23 +275,51 @@ export function useNavigationSync(): UseNavigationSyncReturn {
274275
const refreshRef = useRef(refresh);
275276
refreshRef.current = refresh;
276277

277-
/** Persist an updated app schema and refresh metadata. */
278+
/** Find the current app schema from metadata by name. */
279+
const findApp = useCallback(
280+
(appName: string): AppComponentSchema | undefined =>
281+
matchAppBySegment(apps, appName) as AppComponentSchema | undefined,
282+
[apps],
283+
);
284+
285+
/**
286+
* objectstack#35115 — the one address a navigation write reads the app at
287+
* and saves it to: the served app's name, and the package that owns it.
288+
*
289+
* A packaged app is read and saved with `{ packageId }` (`?package=`), the
290+
* row it is served from, the way the console's other app writers name it
291+
* (App management's `saveApp`, objectui#12300). A package-less app (no
292+
* `_packageId`, or the server's `sys_metadata` sentinel) keeps the
293+
* package-less address. A managed package's sealed app (ADR-0131 D6) is
294+
* never targeted by the all-apps writes ({@link isNavigationSyncableApp}),
295+
* and the server refuses a write onto it at either address.
296+
*/
297+
const appAddress = useCallback(
298+
(appName: string): { name: string; packageId?: string } | undefined => {
299+
const served = findApp(appName);
300+
if (!served) return undefined;
301+
const name = typeof served.name === 'string' && served.name ? served.name : appName;
302+
const packageId = (served as { _packageId?: unknown })._packageId;
303+
return !isPackageLessItem(served as { _packageId?: unknown }) && typeof packageId === 'string'
304+
? { name, packageId }
305+
: { name };
306+
},
307+
[findApp],
308+
);
309+
310+
/** Persist an updated app schema at the app's address and refresh metadata. */
278311
const saveApp = useCallback(
279312
async (appName: string, schema: AppComponentSchema) => {
280313
const client = adapterRef.current?.getClient();
281314
if (client) {
282-
await client.meta.saveItem('app', appName, schema);
315+
const address = appAddress(appName) ?? { name: appName };
316+
await (address.packageId
317+
? client.meta.saveItem('app', address.name, schema, { packageId: address.packageId })
318+
: client.meta.saveItem('app', address.name, schema));
283319
}
284320
await refreshRef.current?.();
285321
},
286-
[],
287-
);
288-
289-
/** Find the current app schema from metadata by name. */
290-
const findApp = useCallback(
291-
(appName: string): AppComponentSchema | undefined =>
292-
matchAppBySegment(apps, appName) as AppComponentSchema | undefined,
293-
[apps],
322+
[appAddress],
294323
);
295324

296325
/**
@@ -303,25 +332,28 @@ export function useNavigationSync(): UseNavigationSyncReturn {
303332
* stored the translations as source text, into every app a new page joined.
304333
* The served list only finds the app here; its body comes from the
305334
* untranslated layers (`getAuthoredItem`), read at the address `saveApp`
306-
* writes (no package). An app with nothing stored to read is not written,
307-
* and the failure is said once.
335+
* writes ({@link appAddress}: its package, when it has one). An app with
336+
* nothing stored to read is not written, and the failure is said once.
308337
*/
309338
const storedApp = useCallback(
310339
async (appName: string): Promise<AppComponentSchema | undefined> => {
311-
const served = findApp(appName);
312-
if (!served) return undefined;
313-
const name = typeof served.name === 'string' && served.name ? served.name : appName;
340+
const address = appAddress(appName);
341+
if (!address) return undefined;
314342
try {
315343
const read = adapterRef.current?.getAuthoredItem;
316-
const stored = read ? await read.call(adapterRef.current, 'app', name) : null;
344+
const stored = read
345+
? await (address.packageId
346+
? read.call(adapterRef.current, 'app', address.name, { packageId: address.packageId })
347+
: read.call(adapterRef.current, 'app', address.name))
348+
: null;
317349
if (stored) return stored as unknown as AppComponentSchema;
318350
} catch {
319351
// Said below, as an absent body is.
320352
}
321353
toast.error(t('navigationSync.updateFailed'));
322354
return undefined;
323355
},
324-
[findApp, t],
356+
[appAddress, t],
325357
);
326358

327359
// ------------------------------------------------------------------
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectstack#35115 — the app wizard saves a packaged app at its package.
5+
*
6+
* `EditAppPage` reads the stored app at the package the served app came from
7+
* (`getAuthoredItem('app', name, { packageId })`, objectstack#35054), but its
8+
* save called `client.meta.saveItem('app', name, body)` with no package, so
9+
* the write went to the package-less address (no `?package=`) while the row it
10+
* edited belongs to a package. The save now names the same package
11+
* (`{ packageId }`, sent as `?package=`); a package-less app, and an app
12+
* served with the server's `sys_metadata` sentinel, keep the package-less
13+
* address for both the read and the save.
14+
*
15+
* Direction, written before the run: with the save left package-less (the
16+
* unmodified tree) the packaged case goes RED on the save's options while the
17+
* package-less case stays GREEN.
18+
*/
19+
20+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
21+
import React from 'react';
22+
import { render, screen, cleanup, fireEvent, waitFor } from '@testing-library/react';
23+
24+
const saveItem = vi.fn().mockResolvedValue({});
25+
const getAuthoredItem = vi.fn();
26+
const apps: Record<string, unknown>[] = [];
27+
28+
vi.mock('react-router-dom', () => ({
29+
useParams: () => ({ editAppName: 'qa_scope_app' }),
30+
useNavigate: () => vi.fn(),
31+
}));
32+
33+
vi.mock('@object-ui/react', async (importOriginal) => {
34+
const actual = await importOriginal<Record<string, unknown>>();
35+
return {
36+
...actual,
37+
useAdapter: () => ({ getClient: () => ({ meta: { saveItem } }), getAuthoredItem }),
38+
useMetadata: () => ({ apps, objects: [], refresh: () => Promise.resolve() }),
39+
};
40+
});
41+
42+
vi.mock('sonner', () => ({ toast: { success: vi.fn(), error: vi.fn(), info: vi.fn() } }));
43+
44+
import { EditAppPage } from '../pages/EditAppPage';
45+
46+
/** The app as its author stored it. */
47+
const STORED = { name: 'qa_scope_app', label: 'QA Scope App', icon: 'sparkles', navigation: [] };
48+
49+
const next = () => fireEvent.click(screen.getByTestId('wizard-next'));
50+
51+
/** Open the wizard on the served app, edit the description and complete it. */
52+
async function editAndSave(served: Record<string, unknown>) {
53+
apps.push(served);
54+
getAuthoredItem.mockResolvedValue(STORED);
55+
render(<EditAppPage />);
56+
await screen.findByTestId('edit-app-page');
57+
fireEvent.change(screen.getByTestId('app-description-input'), { target: { value: 'Edited description' } });
58+
next(); // → objects
59+
next(); // → navigation
60+
next(); // → branding
61+
fireEvent.click(screen.getByTestId('wizard-complete'));
62+
await waitFor(() => expect(saveItem).toHaveBeenCalledTimes(1));
63+
return saveItem.mock.calls[0] as unknown[];
64+
}
65+
66+
beforeEach(() => {
67+
saveItem.mockClear();
68+
getAuthoredItem.mockReset();
69+
apps.length = 0;
70+
});
71+
afterEach(() => cleanup());
72+
73+
describe('EditAppPage saves the app at its package (objectstack#35115)', () => {
74+
it('a packaged app is read and saved at its package', async () => {
75+
const call = await editAndSave({ ...STORED, _packageId: 'com.qa.scope' });
76+
expect(getAuthoredItem).toHaveBeenCalledWith('app', 'qa_scope_app', { packageId: 'com.qa.scope' });
77+
expect(call[3]).toEqual({ packageId: 'com.qa.scope' });
78+
// Control: the save is the app, with the edit.
79+
expect(call.slice(0, 2)).toEqual(['app', 'qa_scope_app']);
80+
expect((call[2] as Record<string, unknown>).description).toBe('Edited description');
81+
});
82+
83+
it('a package-less app is read and saved with no package', async () => {
84+
const call = await editAndSave({ ...STORED });
85+
expect(getAuthoredItem).toHaveBeenCalledWith('app', 'qa_scope_app', {});
86+
expect(call).toHaveLength(3);
87+
expect(call.slice(0, 2)).toEqual(['app', 'qa_scope_app']);
88+
});
89+
90+
it('an app served with the sys_metadata sentinel names no package on the read or the save', async () => {
91+
const call = await editAndSave({ ...STORED, _packageId: 'sys_metadata' });
92+
expect(getAuthoredItem).toHaveBeenCalledWith('app', 'qa_scope_app', {});
93+
expect(call).toHaveLength(3);
94+
});
95+
});

0 commit comments

Comments
 (0)