Skip to content

Commit f339060

Browse files
feat(ui): New Package offers 「同时创建应用」 / Also create an app, ticked by default (#37338)
Fixes #37134 Clause-②: no Metadata-protocol: none ## 维护者速读 - 在设置的「软件包」页点「新建软件包」,或从「添加应用」菜单、首页等「新建空白应用」入口进到同一个对话框时,名称下面多了一个勾选项「同时创建应用」,默认勾上;勾上时一次确定就同时建好软件包和同名应用,进到 Studio 左上角显示应用名;取消勾选就和以前一样只建软件包。 - 这是 Studio 重构专题的一步:去掉 Studio 首页以后,原来首页上一步建好包和应用的入口没了,这个勾选项把它补回到唯一的新建软件包对话框里。 - 如果应用的名字已被别的应用占用,什么都不会写入,对话框直接说明是哪个应用占用了,可以到「高级」里改命名空间或取消勾选;软件包建好但应用没能上线时会弹提示。只改界面,不改服务器和数据,可以直接撤回。 - 无。 ## What changes - **The create-package dialog offers 「同时创建应用」 / "Also create an app", ticked on every opening.** `PackageFormDialog` in create mode with a `newApp` step now draws the checkbox under the description in the Basics card. Ticked, it runs the step exactly as the Studio home's door did (#36748): reserve a free app name before any write (a taken one refuses the whole confirm, opens Advanced and writes nothing), `POST /api/v1/packages`, then the app's draft under the first-write pin and that one item's publish. Unticked, it posts the package alone, as before. A refused app after the package landed keeps the existing `appFailed` toast. - **The dialog keeps its package face.** `newApp` used to reword the whole dialog for an app (title 「新建应用」, 「应用 ID」, the help rows). That face's only host, the Studio home, was removed by #36908, and the card puts the choice in the package dialog, so the rewording branch (`withAppDoorWording` and the `appDoor` ternaries) is removed. Success with an app now reads "Created package “NAME” and its app." (new key); a 409 and a generic failure read the package dialog's own lines. - **Every door gets it.** `CreatePackageDialog` builds `newAppStep(client, locale)` and passes it; it is the only create-mode mount of `PackageFormDialog` in app-shell. Its doors: Setup → Packages' New Package button (both faces), the `?new=package` door that the console's 「新建空白应用」 entries open (#36908), and ResourceListPage's create-a-package-first prompt. `onCreated` still answers with the package id, so each door lands where it did: Setup's admin face in Studio on the new package (whose header then names the app), the development face on the list, the resource list on `./new?package=…`. - **Strings:** `engine.packages.create.alsoApp`, `engine.packages.create.alsoAppHint` and `engine.packages.create.createdWithApp` in the studio catalogue (en, zh). Additive only; no key removed. - Not touched: the server, and decision 5's fallback for app-less packages (#36899): an installed, older or unticked package still shows its package name in Studio's header. ## Tests - `PackageFormDialog.newAppStep-36748.test.tsx` (the shared harness: real dialog, real `newAppStep`, real metadata client and `StudioDesignSurface` over a stateful fetch stub). New top-level describes, all mounting the real `CreatePackageDialog`: - the box is there and ticked on every opening, in en and zh (unticked, cancelled, reopened: ticked again); - ticked: `POST package` → `PUT app draft` → `POST app publish`, the app is the new package's, the toast, and Studio's header names the app; - unticked: only `POST /api/v1/packages`, no app or draft, the package toast, the header names the package; - ticked with both candidate app names taken: the refusal names the holding app, Advanced opens, nothing is written; unticking clears the refusal and the package alone goes through; - every door: a source read of app-shell finds `CreatePackageDialog` mounted exactly in `PackagesPage.tsx` and `ResourceListPage.tsx`, no other create-mode `PackageFormDialog`, and the wrapper passing `newAppStep(client, locale)`. - The #36748 cases survived #36908's move whole (three cases). Case 1 pinned the app-worded face this card removes; it now pins the package face with the box ticked, plus a CONTROL that a dialog without a step offers no box. Case 2's toast assertion reads the new success line; the rest of it (writes, header, back link) is unchanged. - `PackagesPage.installedAppsUpdates-34722.test.tsx`: the page's dialog stand-in now reports whether it was handed the step; three cases pin it for the admin face's button, the `?new=package` door and the development face's button. <details><summary>Ablations — each one red, then restored by hash</summary> Mutations through `scripts/ablation-replace.mjs` (anchor must hit, on-disk counts printed), restored with `git checkout HEAD -- PATH` and checked by blob hash and an empty `git diff HEAD`. app-shell's tests import the dialog and the page by relative path, so no `dist/` is in the resolution path. | # | Mutation | Red | |:--|:--|:--| | A1 | `appStep` always `undefined` (ticked creates no app) | 4: both "ticked" cases and both "taken" cases | | A2 | `appStep` ignores the box | 2: "unticked" and the taken-then-untick case | | A3 | the taken arm never fires | 2: both "taken" cases | | A4 | the box resets to unticked on open | 8: every case that reads the default | | A5 | `CreatePackageDialog` passes `newApp={undefined}` | 9: the three PackagesPage door cases, every `CreatePackageDialog` case, the wrapper source pin | | A6 | ResourceListPage mounts `PackageFormDialog mode="create"` itself | 2: both door source pins | A5's first attempt used an empty replacement, which the tool refused (nothing landed); it was re-run with `newApp={undefined}`. All six restore lines matched the HEAD blob. </details> ## Acceptance notes - The card's file surface names "the Studio package switcher" as a call site. It no longer exists: the top-bar switcher was removed by #36501 (`PackageSwitcher.tsx` now only exports a toast id), so there is no such door to wire. The doors that exist are listed above. - The app-worded rows (`engine.studio.newApp.title`, `description`, `advancedHint`, `id`, `help.*`, `nsDerived`, `exists`, `failed`) have no reader after this change. They stay, because this card removes no released key; `nameTaken` and `appFailed` are still read. The en catalogue's comment says so. `check:i18n-dead-keys` is report-only. - The submit button stays "Create package" with the box ticked; the checkbox and its hint say an app comes with it. - A Studio-only author who cannot open Setup → Packages still has no New Package door (#36908's note); that is #37139's, not this card's. ## Verification Two-minute check: `pnpm dev`, open Setup → Packages, New Package, type a name, keep 「同时创建应用」 ticked, Create. Expected: the toast "Created package “NAME” and its app.", then Studio on the new package with 「‹ Back to app · NAME」 in the header. Repeat unticked: the package toast, and the header shows the package name. Read first: `PackageFormDialog.tsx` (the `appStep` line in `submit()` and the checkbox in the Basics card), `PackagesPage.tsx` (`CreatePackageDialog`), then the new describes at the end of `PackageFormDialog.newAppStep-36748.test.tsx`. <details><summary>Local runs (head 97fa2d8)</summary> All at head `97fa2d83` unless noted; exit codes captured before any pipe. - vitest, `PackageFormDialog.newAppStep-36748`: Test Files 1 passed (1), Tests 11 passed (11); lock VERDICT command-exit 0. - vitest, `PackageFormDialog*`, `PackagesPage.installedAppsUpdates-34722`, `CreatePackageDialog*` (at `4179e152`, test-only rename since): Test Files 17 passed (17), Tests 195 passed; then `PackagesPage*`, `ResourceListPage*`, `EditPackageDialog*`, `StudioDesignSurface.createApp*`: Test Files 36 passed (36), Tests 313 passed (313). - `pnpm --filter @object-ui/app-shell type-check` (src + `tsconfig.test.json`), after building the `@object-ui/app-shell^...` closure: lock VERDICT command-exit 0, 0 TS errors. - eslint `--no-inline-config` on the six touched source files: exit 0 (warnings only, all pre-existing lines). - `pnpm --dir ui exec vitest run scripts/`: Test Files 172 passed, 2 skipped (174); Tests 5130 passed. The first run on `28a9d57a` failed `check-test-path-roots` on the new test (a local named `path` read as the fetch stub's URL path); fixed by the rename in `97fa2d83`. - `check:test-source-alias` exit 0 · `check:i18n-keys` exit 0 · `scripts/pm/overlap-check.mjs` VERDICT clean exit 0 (merges cleanly with main and #37315, which shares the two studio catalogues). - `dispatch-gates.mjs --commands`: 39 derived families, all run at `97fa2d83`, all exit 0; `--ran` reconciliation: 39 derived, 39 run, 0 NOT-MEASURED (a derived zero: every row carries its exit code). </details> <!-- signed: repo:objectstack#4 · os-justin · session_01QSeKYkkwuF6UuFtu85Yd5H --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent a182fbe commit f339060

7 files changed

Lines changed: 365 additions & 80 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/i18n': patch
4+
---
5+
6+
feat(console): New Package offers "Also create an app", ticked by default
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
The New Package dialog (Setup → Packages, the console's "New blank app" entries that open it, and the resource list's create-a-package-first prompt) now has a checkbox, "Also create an app" (zh: 同时创建应用), ticked each time the dialog opens.
12+
13+
- Ticked: one confirm creates the package and an app with the same name, live at once. The success toast reads "Created package “NAME” and its app." (zh: 已创建软件包「NAME」及其应用。), and Studio's header names the app when you land there. If the app's identifier is already taken, nothing is written and the dialog says which app holds it; change the namespace under Advanced, or untick the box. If the package is created but its app cannot go live, a toast says so and Studio's Create app is the way to try again.
14+
- Unticked: only the package is created, exactly as before, for a package that only holds objects or flows for other packages.
15+
16+
Where the dialog takes you afterwards is unchanged. Packages created before this change, installed packages and other app-less packages still show the package name in Studio's header.
17+
18+
New locale keys in the studio catalogue (en, zh): `engine.packages.create.alsoApp`, `engine.packages.create.alsoAppHint`, `engine.packages.create.createdWithApp`. No key is removed. `PackageFormDialog`'s `newApp` prop now adds the checkbox to the create-package dialog instead of rewording the dialog for an app; no other props or exports change.

‎ui/packages/app-shell/src/views/metadata-admin/PackageFormDialog.newAppStep-36748.test.tsx‎

Lines changed: 214 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
* objectstack#36748 — `PackageFormDialog` handed a `newApp` step
55
* (`newAppStep`, `studio-design/newAppDoor.ts`) ends with an app.
66
*
7-
* 1. The dialog is titled 「新建应用」/"New app" and worded for an app: a
8-
* no-code author reads 「应用」, never 「软件包」, on this door (the
9-
* maintainer's ruling).
7+
* 1. (objectstack#37134) The step is offered as 「同时创建应用」 / "Also
8+
* create an app", ticked by default, on the create-package dialog's own
9+
* face: the app-worded dialog went with the Studio home's 「新建应用」
10+
* door (objectstack#36908), and the one create-package dialog now
11+
* carries the choice.
1012
* 2. One confirm creates the package AND its app: the package `POST`, the
1113
* app's draft under the first-write pin, then that one app's publish
1214
* (objectstack#36511: a human-created item is live at once). The author
@@ -21,6 +23,12 @@
2123
* create mode, `newApp={newAppStep(client, locale)}`, and Studio on the new
2224
* package after save.
2325
*
26+
* objectstack#37134 — the create-package dialog (`CreatePackageDialog`, the
27+
* one every create-package door mounts) hands the dialog that step, so its
28+
* cases below mount the REAL wrapper: ticked creates the package and its app,
29+
* unticked the package alone, and a taken app name surfaces as above. The
30+
* last describe pins that every door mounts that wrapper.
31+
*
2432
* The REAL `PackageFormDialog`, `newAppStep`, metadata client and
2533
* `StudioDesignSurface` over a fetch stub that keeps the server's state:
2634
* packages, published apps and app drafts.
@@ -59,7 +67,11 @@ vi.mock('../studio-design/StudioAiCopilot', () => ({ StudioChatDock: () => null
5967
vi.mock('../../preview/DraftChangesPanel', () => ({ DraftChangesPanel: () => null }));
6068

6169
import { toast } from 'sonner';
70+
import { readFileSync, readdirSync, statSync } from 'node:fs';
71+
import { dirname, join, relative, resolve } from 'node:path';
72+
import { fileURLToPath } from 'node:url';
6273
import { PackageFormDialog } from './PackageFormDialog';
74+
import { CreatePackageDialog } from './PackagesPage';
6375
import { useMetadataClient } from './useMetadata';
6476
import { t, useMetadataLocale } from './i18n';
6577
import { newAppStep } from '../studio-design/newAppDoor';
@@ -206,18 +218,23 @@ const nameInput = (dialog: HTMLElement) =>
206218

207219
const describeWrite = (w: Write) => `${w.method} ${w.path}`;
208220

209-
describe('PackageFormDialog with a new-app step: one dialog worded for an app (objectstack#36748)', () => {
210-
it('titled 「新建应用」, its submit 「创建应用」, and no 「软件包」 anywhere on its face', async () => {
221+
describe('PackageFormDialog with a new-app step: offered as 「同时创建应用」, ticked (objectstack#37134)', () => {
222+
it('the create-package dialog, with 「同时创建应用」 ticked under the name', async () => {
211223
localeFixture = 'zh-CN';
212224
renderDoor();
213225
const dialog = await openNewAppDialog();
214-
expect(within(dialog).getByRole('heading', { name: '新建应用' })).toBeInTheDocument();
226+
expect(within(dialog).getByRole('heading', { name: '新建软件包' })).toBeInTheDocument();
227+
const box = within(dialog).getByRole('checkbox', { name: '同时创建应用' });
228+
expect(box).toHaveAttribute('data-state', 'checked');
215229
fireEvent.change(nameInput(dialog), { target: { value: 'Visits' } });
216-
expect(within(dialog).getByTestId('package-form-submit')).toHaveTextContent('创建应用');
217-
// Advanced opened too: its rows say 「应用 ID」.
218-
fireEvent.click(within(dialog).getByTestId('package-form-advanced-toggle'));
219-
expect(within(dialog).getByText('应用 ID')).toBeInTheDocument();
220-
expect(dialog.textContent).not.toMatch(/软件包/);
230+
expect(within(dialog).getByTestId('package-form-submit')).toHaveTextContent('创建软件包');
231+
});
232+
233+
it('CONTROL: without a step the dialog offers no app', async () => {
234+
render(<PackageFormDialog mode="create" open onOpenChange={() => {}} />);
235+
const dialog = await screen.findByRole('dialog');
236+
expect(within(dialog).queryByTestId('package-form-also-app')).toBeNull();
237+
expect(within(dialog).queryByRole('checkbox')).toBeNull();
221238
});
222239
});
223240

@@ -245,7 +262,8 @@ describe('PackageFormDialog with a new-app step: one confirm creates the package
245262
expect(draft.search.get('mode')).toBe('draft');
246263
expect(draft.body?.label).toBe('Visits');
247264
expect(publish.search.get('package')).toBe(packageId);
248-
expect(toast.success).toHaveBeenCalledWith(expect.stringMatching(/^Created app “Visits”/));
265+
// The package dialog's own voice (objectstack#37134): the package and its app.
266+
expect(toast.success).toHaveBeenCalledWith('Created package “Visits” and its app.');
249267
expect(toast.error).not.toHaveBeenCalled();
250268

251269
// The author lands in the new package's Studio; the header names the app.
@@ -280,3 +298,187 @@ describe('PackageFormDialog with a new-app step: one confirm creates the package
280298
expect(srv.writes).toEqual([]);
281299
});
282300
});
301+
302+
// ---------------------------------------------------------------------------
303+
// objectstack#37134 — the create-package dialog every door mounts
304+
// (`CreatePackageDialog`) offers 「同时创建应用」, ticked by default.
305+
// ---------------------------------------------------------------------------
306+
307+
/** `CreatePackageDialog` as Setup → Packages mounts it: Studio on the new package after create. */
308+
function CreatePackageHost() {
309+
const navigate = useNavigate();
310+
const [open, setOpen] = React.useState(false);
311+
return (
312+
<>
313+
<button type="button" data-testid="open-new-app" onClick={() => setOpen(true)}>
314+
new package
315+
</button>
316+
<CreatePackageDialog open={open} onOpenChange={setOpen} onCreated={(id) => navigate(studioHomePath(id))} />
317+
</>
318+
);
319+
}
320+
321+
function renderCreatePackage() {
322+
return render(
323+
<MemoryRouter initialEntries={['/host']}>
324+
<Routes>
325+
<Route path="/host" element={<CreatePackageHost />} />
326+
<Route path="/studio/:packageId/metadata/*" element={<StudioDesignSurface area="metadata" />} />
327+
<Route path="/studio/:packageId/:tab" element={<StudioDesignSurface />} />
328+
<Route path="/apps/*" element={<RunningApp />} />
329+
</Routes>
330+
</MemoryRouter>,
331+
);
332+
}
333+
334+
const alsoAppBox = (dialog: HTMLElement) =>
335+
within(dialog).getByRole('checkbox', { name: t('engine.packages.create.alsoApp', localeFixture) });
336+
337+
async function nameAndWait(dialog: HTMLElement, name: string) {
338+
fireEvent.change(nameInput(dialog), { target: { value: name } });
339+
await waitFor(() => expect(within(dialog).getByTestId('package-form-submit')).toBeEnabled());
340+
}
341+
342+
describe('CreatePackageDialog: 「同时创建应用」 is offered, ticked by default (objectstack#37134)', () => {
343+
it.each(['en-US', 'zh-CN'] as const)('%s: the box is there and ticked on every opening', async (locale) => {
344+
localeFixture = locale;
345+
renderCreatePackage();
346+
let dialog = await openNewAppDialog();
347+
const label = locale === 'zh-CN' ? '同时创建应用' : 'Also create an app';
348+
expect(within(dialog).getByRole('checkbox', { name: label })).toHaveAttribute('data-state', 'checked');
349+
// Unticked, closed and opened again: ticked again.
350+
fireEvent.click(within(dialog).getByRole('checkbox', { name: label }));
351+
expect(within(dialog).getByRole('checkbox', { name: label })).toHaveAttribute('data-state', 'unchecked');
352+
fireEvent.click(within(dialog).getByRole('button', { name: t('engine.cancel', locale) }));
353+
await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());
354+
dialog = await openNewAppDialog();
355+
expect(within(dialog).getByRole('checkbox', { name: label })).toHaveAttribute('data-state', 'checked');
356+
});
357+
});
358+
359+
describe('CreatePackageDialog: ticked creates the package and its app; unticked only the package (objectstack#37134)', () => {
360+
it('ticked: package, app draft, app publish — then the Studio header names the app', async () => {
361+
renderCreatePackage();
362+
const dialog = await openNewAppDialog();
363+
await nameAndWait(dialog, 'Visits');
364+
fireEvent.click(within(dialog).getByTestId('package-form-submit'));
365+
366+
await waitFor(() => expect(srv.writes).toHaveLength(3), { timeout: 8000 });
367+
const manifest = srv.writes[0].body?.manifest as Record<string, unknown>;
368+
const packageId = String(manifest.id);
369+
const namespace = String(manifest.namespace);
370+
expect(srv.writes.map(describeWrite)).toEqual([
371+
'POST /api/v1/packages',
372+
`PUT /api/v1/meta/app/${namespace}`,
373+
`POST /api/v1/meta/app/${namespace}/publish`,
374+
]);
375+
expect(srv.writes[1].search.get('package')).toBe(packageId);
376+
expect(srv.apps.map((a) => a.name)).toEqual([namespace]);
377+
expect(toast.success).toHaveBeenCalledWith('Created package “Visits” and its app.');
378+
expect(toast.error).not.toHaveBeenCalled();
379+
380+
// Where the wrapper lands does not change (Studio on the new package),
381+
// and with an app the header names it.
382+
const header = await screen.findByTestId('studio-shell-header', undefined, { timeout: 8000 });
383+
await waitFor(
384+
() => expect(within(header).getByTestId('studio-back-app-name')).toHaveAttribute('data-names', 'app'),
385+
{ timeout: 8000 },
386+
);
387+
expect(within(header).getByTestId('studio-back')).toHaveTextContent(/^Back to app·Visits·Studio$/);
388+
});
389+
390+
it('unticked: only the package is created, as before', async () => {
391+
renderCreatePackage();
392+
const dialog = await openNewAppDialog();
393+
await nameAndWait(dialog, 'Shared parts');
394+
fireEvent.click(alsoAppBox(dialog));
395+
expect(alsoAppBox(dialog)).toHaveAttribute('data-state', 'unchecked');
396+
fireEvent.click(within(dialog).getByTestId('package-form-submit'));
397+
398+
await waitFor(() => expect(toast.success).toHaveBeenCalledWith('Created package “Shared parts”.'));
399+
expect(srv.writes.map(describeWrite)).toEqual(['POST /api/v1/packages']);
400+
expect(srv.apps).toEqual([]);
401+
expect(srv.appDrafts).toEqual([]);
402+
// The same landing: Studio on the new package, which has no app to name.
403+
const header = await screen.findByTestId('studio-shell-header', undefined, { timeout: 8000 });
404+
const packageId = String((srv.writes[0].body?.manifest as Record<string, unknown>).id);
405+
expect(await screen.findByTestId('studio-back-app-name', undefined, { timeout: 8000 })).toHaveAttribute(
406+
'data-names',
407+
'package',
408+
);
409+
expect(header).toBeInTheDocument();
410+
expect(packageId).toMatch(/shared-parts$/);
411+
});
412+
413+
it('ticked, an app name already taken refuses the confirm and writes nothing; unticked, the package goes through', async () => {
414+
renderCreatePackage();
415+
const dialog = await openNewAppDialog();
416+
await nameAndWait(dialog, 'Visits');
417+
const namespace = (within(dialog).getByTestId('package-form-derived-summary').textContent ?? '').match(
418+
/will start with (\w+?)_\./,
419+
)?.[1];
420+
expect(namespace, 'the derived namespace is read off the dialog').toBeTruthy();
421+
srv.apps = [
422+
{ name: namespace, label: 'Other visits' },
423+
{ name: `${namespace}_app`, label: 'Other visits app' },
424+
];
425+
fireEvent.click(within(dialog).getByTestId('package-form-submit'));
426+
expect(await within(dialog).findByTestId('package-form-error')).toHaveTextContent(
427+
`The app “Other visits” already uses the identifier “${namespace}”.`,
428+
);
429+
expect(srv.writes).toEqual([]);
430+
// The namespace it names sits behind Advanced, which opened.
431+
expect(within(dialog).getByTestId('package-form-advanced-toggle')).toHaveAttribute('data-state', 'open');
432+
433+
// The author may keep the package and drop the app instead.
434+
fireEvent.click(alsoAppBox(dialog));
435+
expect(within(dialog).queryByTestId('package-form-error')).toBeNull();
436+
fireEvent.click(within(dialog).getByTestId('package-form-submit'));
437+
await waitFor(() => expect(srv.writes.map(describeWrite)).toEqual(['POST /api/v1/packages']));
438+
});
439+
});
440+
441+
// ---------------------------------------------------------------------------
442+
// objectstack#37134 — every create-package door mounts `CreatePackageDialog`,
443+
// so every one of them offers the box. Read off the source: a create-mode
444+
// `PackageFormDialog` mounted anywhere else, or a door that stops mounting
445+
// the wrapper, reds here.
446+
// ---------------------------------------------------------------------------
447+
448+
const HERE = dirname(fileURLToPath(import.meta.url));
449+
const SRC = resolve(HERE, '../..');
450+
451+
function sourceFiles(dir: string): string[] {
452+
return readdirSync(dir).flatMap((entry) => {
453+
const entryFile = join(dir, entry);
454+
if (statSync(entryFile).isDirectory()) return sourceFiles(entryFile);
455+
return /\.tsx?$/.test(entry) && !/\.test\.tsx?$/.test(entry) ? [entryFile] : [];
456+
});
457+
}
458+
459+
/** Every JSX mount of `component` in app-shell's source, as `file: <opening tag>`. */
460+
function mounts(component: string): string[] {
461+
const tag = new RegExp(`<${component}\\b[^>]*>`, 'g');
462+
return sourceFiles(SRC).flatMap((file) =>
463+
[...readFileSync(file, 'utf8').matchAll(tag)].map((m) => `${relative(SRC, file)}: ${m[0].replace(/\s+/g, ' ')}`),
464+
);
465+
}
466+
467+
describe('every create-package door offers 「同时创建应用」 (objectstack#37134)', () => {
468+
it('Setup → Packages (its button and the `?new=package` door) and the resource list mount CreatePackageDialog', () => {
469+
const doors = mounts('CreatePackageDialog').map((m) => m.split(':')[0]);
470+
expect(doors.sort()).toEqual(['views/metadata-admin/PackagesPage.tsx', 'views/metadata-admin/ResourceListPage.tsx']);
471+
});
472+
473+
it('no create-mode PackageFormDialog is mounted outside CreatePackageDialog, and that one passes the step', () => {
474+
const creates = mounts('PackageFormDialog').filter((m) => !/mode="(edit|view)"/.test(m));
475+
expect(creates).toHaveLength(1);
476+
expect(creates[0]).toMatch(/^views\/metadata-admin\/PackagesPage\.tsx: <PackageFormDialog mode="create"/);
477+
const wrapper = readFileSync(join(SRC, 'views/metadata-admin/PackagesPage.tsx'), 'utf8').match(
478+
/export function CreatePackageDialog\([\s\S]*?\n}\n/,
479+
)?.[0];
480+
expect(wrapper, 'CreatePackageDialog is read off PackagesPage.tsx').toBeTruthy();
481+
expect(wrapper).toMatch(/newApp=\{newApp\}/);
482+
expect(wrapper).toMatch(/newAppStep\(client, locale\)/);
483+
});
484+
});

0 commit comments

Comments
 (0)