Skip to content

Commit 313b6bf

Browse files
committed
test(app-shell): pin the new dashboard's menu entry under the menu order rule
A new dashboard's entry, held between two entries of a level that carries `order`, is saved numbered in that place, with every entry of the level renumbered in its shown place (objectstack#36591's rule, now applied by prepareAppMenuSave to the create-and-save path as well). Claude-Session: https://claude.ai/code/session_01ADHkmPiTdmLxHXBjakSvJy Co-authored-by: Claude <noreply@anthropic.com>
1 parent 577b034 commit 313b6bf

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

‎ui/packages/app-shell/src/layout/__tests__/designModeMenuCreate-36364.test.ts‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ vi.mock('../../assistant/assistantBus', async (importOriginal) => ({
2121
}));
2222

2323
import { loadHanRomanizer } from '../../views/metadata-admin/romanizeHan';
24-
import type { Menu } from '../designModeMenuModel';
24+
import { inShownOrder, insertEntry, withEntryIds, type Menu } from '../designModeMenuModel';
2525
import type { AppMenuSaveDoors } from '../designModeMenuSave';
2626
import {
2727
freeItemName,
@@ -51,6 +51,7 @@ function doors(opts: {
5151
writable: boolean;
5252
version?: string;
5353
pairWritable?: boolean;
54+
stored?: Menu;
5455
ensure?: () => Promise<never>;
5556
refuse?: (call: Call) => unknown;
5657
}) {
@@ -75,7 +76,7 @@ function doors(opts: {
7576
},
7677
client: {
7778
layered: async () => {
78-
const code = { name: 'crm', label: 'CRM', navigation: SERVED };
79+
const code = { name: 'crm', label: 'CRM', navigation: opts.stored ?? SERVED };
7980
return { code, effective: code };
8081
},
8182
save: (...args) => record(['save', ...args]),
@@ -200,3 +201,24 @@ describe('the new dashboard’s machine name (objectstack#36364)', () => {
200201
await expect(freeItemName('dashboard', 'Payment analysis', [], { get })).rejects.toThrow('read failed');
201202
});
202203
});
204+
205+
describe('the new dashboard’s entry in a menu that carries `order` (objectstack#36364 over objectstack#36591)', () => {
206+
const object = (id: string, label: string, order: number) => ({ id, type: 'object', objectName: `crm_${id}`, label, order });
207+
/** As stored, authored out of `order`; the sidebar reads Customers, Contacts, Opportunities. */
208+
const STORED: Menu = [object('opportunity', 'Opportunities', 2), object('contact', 'Contacts', 1), object('customer', 'Customers', 0)];
209+
210+
it('the entry held between two entries is numbered in that place, and every entry of the level gets its shown place', async () => {
211+
const served = withEntryIds(inShownOrder(STORED));
212+
const navigation = insertEntry(served, null, 1, ENTRY);
213+
const { d, calls } = doors({ writable: true, stored: STORED });
214+
await saveAppMenuWithNewItem({ ...input, served, navigation }, TEXTS, d);
215+
expect(calls.map(([verb, type]) => `${verb} ${type}`)).toEqual(['save dashboard', 'publish dashboard', 'save app', 'publish app']);
216+
const saved = (calls[2][3] as { navigation: Array<{ id: string; order?: number }> }).navigation;
217+
expect(saved.map((e) => [e.id, e.order])).toEqual([
218+
['customer', 0],
219+
['nav_item_1', 1],
220+
['contact', 2],
221+
['opportunity', 3],
222+
]);
223+
});
224+
});

0 commit comments

Comments
 (0)