Skip to content

Commit 0b6a152

Browse files
committed
test(console): the Studio's report entry is the report index, kept on save
Claude-Session: https://claude.ai/code/session_01WGufzhEW5k2a4Vd5KSupfu Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 01ed76a commit 0b6a152

3 files changed

Lines changed: 36 additions & 5 deletions

File tree

‎ui/packages/app-shell/src/views/metadata-admin/previews/AppNavCanvas.navPayload-11776.test.tsx‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,12 @@ describe('navPayloadOf — what a nav save sends (objectui#11776)', () => {
7171
expect(navPayloadOf([entry])).toEqual([entry]);
7272
});
7373

74-
it('only the separator and the group are taken bare; every other branch names a target', () => {
74+
// objectstack#27525 — a bare `report` entry is the app's report index, so
75+
// the spec takes it and the save sends it.
76+
it('only the separator, the group and the report index are taken bare; every other branch names a target', () => {
7577
const takenBare = specNavTypes().filter((type) => NavigationItemSchema.safeParse(bare(type)).success);
76-
expect(takenBare.sort()).toEqual(['group', 'separator']);
78+
expect(takenBare.sort()).toEqual(['group', 'report', 'separator']);
79+
expect(navPayloadOf([bare('report')])).toEqual([bare('report')]);
7780
});
7881

7982
it('a `doc` entry names its target by `doc` OR `book`', () => {
@@ -134,7 +137,7 @@ describe('navPayloadOf — what a nav save sends (objectui#11776)', () => {
134137
const home = { id: 'nav_home', type: 'page', label: 'Home', pageName: 'home' };
135138
const sep = { type: 'separator' };
136139
const accounts = { id: 'nav_accounts', type: 'object', objectName: 'account' };
137-
const editor = [home, { id: 'nav_item_2', type: 'object' }, sep, accounts, { id: 'nav_item_5', type: 'report' }];
140+
const editor = [home, { id: 'nav_item_2', type: 'object' }, sep, accounts, { id: 'nav_item_5', type: 'dashboard' }];
138141
const sent = navPayloadOf(editor);
139142
expect(sent).toEqual([home, sep, accounts]);
140143
// The entries sent ARE the editor's: nothing kept is copied or rewritten.

‎ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.navItemTypes-11790.test.tsx‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ describe('StudioNavItemInspector — the Type choice is the spec nav-item union
309309
const TARGET_CASES: Array<{ type: string; pickIn: string; value: string; written: Record<string, unknown> }> = [
310310
{ type: 'page', pickIn: 'Page', value: 'home', written: { pageName: 'home' } },
311311
{ type: 'dashboard', pickIn: 'Dashboard', value: 'ops_board', written: { dashboardName: 'ops_board' } },
312-
{ type: 'report', pickIn: 'Report', value: 'tasks_by_status', written: { reportName: 'tasks_by_status' } },
313312
{ type: 'action', pickIn: 'Action', value: 'sync_all', written: { actionDef: { actionName: 'sync_all' } } },
314313
{ type: 'component', pickIn: 'Component', value: 'acme:board', written: { componentRef: 'acme:board' } },
315314
{ type: 'doc', pickIn: 'Doc page', value: 'getting_started', written: { doc: 'getting_started' } },
@@ -332,6 +331,30 @@ describe('StudioNavItemInspector — each target-bearing type picks a target and
332331
expect(navPayloadOf([entry])).toEqual([entry]);
333332
});
334333

334+
// objectstack#27525 — a `report` entry with no report chosen is the app's
335+
// report index, not an unbound entry: it parses, a save sends it, and the
336+
// picker's empty face says what it opens.
337+
it('report: born as the report index, kept by a save; a picked report is written, and the index face removes it', async () => {
338+
render(<InspectorHost entry={BORN} />);
339+
fireEvent.click(typeChoice('report'));
340+
expect(entryNow()).toEqual({ id: 'nav_item_3', type: 'report' });
341+
expect(NavigationItemSchema.safeParse(entryNow()).success).toBe(true);
342+
expect(navPayloadOf([entryNow()])).toEqual([entryNow()]);
343+
expect(screen.queryByText(/left out of the saved navigation/)).toBeNull();
344+
expect(screen.getByText(/opens the app's report index/)).toBeInTheDocument();
345+
expect(await offered('Report', /tasks_by_status/)).toEqual(['Report index', 'Tasks by status (tasks_by_status)']);
346+
347+
await pick('Report', 'tasks_by_status');
348+
expect(entryNow()).toEqual({ id: 'nav_item_3', type: 'report', reportName: 'tasks_by_status' });
349+
expect(NavigationItemSchema.safeParse(entryNow()).success).toBe(true);
350+
expect(screen.queryByText(/opens the app's report index/)).toBeNull();
351+
352+
const listbox = await openPicker('Report');
353+
fireEvent.click(within(listbox).getByRole('option', { name: 'Report index' }));
354+
expect(entryNow()).toEqual({ id: 'nav_item_3', type: 'report' });
355+
expect(navPayloadOf([entryNow()])).toEqual([entryNow()]);
356+
});
357+
335358
it('url: the address is typed, and the entry parses', async () => {
336359
render(<InspectorHost entry={BORN} />);
337360
fireEvent.click(typeChoice('url'));

‎ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.sharedSelect-11865.test.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ afterEach(() => {
163163
const OBJECT_PICKER = 'nav-link-object';
164164
const CHOOSE_OBJECT = en('engine.studio.nav.chooseObject');
165165
const CHOOSE = en('engine.inspector.appNav.choose');
166+
const REPORT_INDEX = en('engine.inspector.appNav.reportIndex');
166167
const SAME_TAB = en('engine.inspector.appNav.urlTargetSelf');
167168
const NEW_TAB = en('engine.inspector.appNav.urlTargetBlank');
168169

@@ -212,6 +213,7 @@ const ENTRIES: Record<string, Record<string, unknown>> = {
212213
pageOutside: { id: 'nav_p', type: 'page', pageName: 'ghost_page' },
213214
dashBound: { id: 'nav_d', type: 'dashboard', dashboardName: 'ops_board' },
214215
reportBorn: { id: 'nav_item_3', type: 'report' },
216+
reportBound: { id: 'nav_r', type: 'report', reportName: 'tasks_by_status' },
215217
actionBorn: { id: 'nav_item_3', type: 'action' },
216218
actionBound: { id: 'nav_a', type: 'action', actionDef: { actionName: 'sync_all' } },
217219
compBorn: { id: 'nav_item_3', type: 'component' },
@@ -273,7 +275,10 @@ const NAV_WRITES: ReadonlyArray<readonly [string, string, string, string | null,
273275
['pageOutside', 'Page', 'draft_page', '{"navigation":[{"id":"nav_p","type":"page","pageName":"draft_page"}]}', []],
274276
['dashBound', 'Dashboard', CHOOSE, '{"navigation":[{"id":"nav_d","type":"dashboard"}]}', []],
275277
['dashBound', 'Dashboard', 'Operations (ops_board)', null, []],
276-
['reportBorn', 'Report', CHOOSE, null, []],
278+
// objectstack#27525 — the empty face of a report entry's picker is the
279+
// report index; on a bound entry it removes `reportName`.
280+
['reportBorn', 'Report', REPORT_INDEX, null, []],
281+
['reportBound', 'Report', REPORT_INDEX, '{"navigation":[{"id":"nav_r","type":"report"}]}', []],
277282
['reportBorn', 'Report', 'Tasks by status (tasks_by_status)', '{"navigation":[{"id":"nav_item_3","type":"report","reportName":"tasks_by_status"}]}', []],
278283
['actionBorn', 'Action', CHOOSE, null, []],
279284
['actionBorn', 'Action', 'Sync all (sync_all)', '{"navigation":[{"id":"nav_item_3","type":"action","actionDef":{"actionName":"sync_all"}}]}', []],

0 commit comments

Comments
 (0)