Repository navigation
Expand file tree
/
Copy pathDesignModeMenu-36363.test.tsx
More file actions
1607 lines (1489 loc) · 74.2 KB
/
Copy pathDesignModeMenu-36363.test.tsx
File metadata and controls
1607 lines (1489 loc) · 74.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
/**
* The app's menu under the design mode (objectstack#36363), drawn by its
* editor under the shell's mode and saved through the mode's 「Save」.
*
* Real subjects: `DesignModeMenu`, `useDesignModeController`,
* `DesignModeProvider`, `DesignModeBar`, `saveAppMenu`. The metadata client
* and the package doors are fakes that record what is written; the
* deployment's languages (`GET /api/v1/i18n/locales`) are a stubbed fetch.
* `DndContext` is the real one, its `onDragStart` and `onDragEnd` kept so
* that a drag can be played without the pointer geometry jsdom does not have.
*/
import '@testing-library/jest-dom/vitest';
import * as React from 'react';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { act, cleanup, fireEvent, render, screen, within } from '@testing-library/react';
import { MemoryRouter, useLocation, useNavigate } from 'react-router-dom';
import { SidebarProvider } from '@object-ui/components';
import { NavigationRenderer } from '@object-ui/layout';
import type { NavigationItem } from '@object-ui/types';
const session = vi.hoisted(() => ({ language: 'en', defaultLocale: 'en', sourceLocale: undefined as string | undefined }));
vi.mock('@object-ui/i18n', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useObjectTranslation: () => ({
t: (k: string, o?: Record<string, unknown>) =>
String(o?.defaultValue ?? k).replace(/\{\{(\w+)\}\}/g, (_hole, name: string) => String(o?.[name] ?? '')),
language: session.language,
}),
}));
const dragEnd = vi.hoisted(() => ({ current: null as null | ((event: unknown) => void) }));
const dragStart = vi.hoisted(() => ({ current: null as null | ((event: unknown) => void) }));
/** objectstack#36538 — the editor's cancel handler, its collision rule, and every drag start dnd-kit itself reported. */
const dragCancel = vi.hoisted(() => ({ current: null as null | ((event: unknown) => void) }));
const collisionRule = vi.hoisted(() => ({ current: null as null | ((args: unknown) => unknown[]) }));
const dragStarts = vi.hoisted(() => [] as unknown[]);
vi.mock('@dnd-kit/core', async (importOriginal) => {
const real = await importOriginal<typeof import('@dnd-kit/core')>();
const { createElement } = await import('react');
return {
...real,
DndContext: (props: React.ComponentProps<typeof real.DndContext>) => {
dragEnd.current = props.onDragEnd as never;
dragStart.current = props.onDragStart as never;
dragCancel.current = props.onDragCancel as never;
collisionRule.current = props.collisionDetection as never;
const onDragStart: typeof props.onDragStart = (event) => {
dragStarts.push(event);
props.onDragStart?.(event);
};
return createElement(real.DndContext, { ...props, onDragStart });
},
};
});
const toastError = vi.hoisted(() => vi.fn());
vi.mock('sonner', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
toast: { error: toastError, success: vi.fn() },
}));
const written = vi.hoisted(() => [] as Array<[string, ...unknown[]]>);
const listed = vi.hoisted(() => ({
object: [
{ name: 'crm_lead', label: 'Leads' },
{ name: 'crm_account', label: 'Accounts' },
{ name: 'crm_case', label: 'Cases' },
],
view: [{ name: 'crm_lead.hot', label: 'Hot leads' }],
dashboard: [],
report: [{ name: 'pipeline', label: 'Pipeline' }],
page: [
{ name: 'welcome', label: 'Welcome' },
{ name: 'crm_lead_record', label: 'Lead record', type: 'record' },
],
}) as Record<string, Array<Record<string, unknown>>>);
/** objectstack#36364 — names the server holds (`type/name`), and a refusal of the app's save. */
const server = vi.hoisted(() => ({ held: new Set<string>(), appSave: null as Error | null, appPublish: null as Error | null }));
/** The app's menu as served (`null`: `NAVIGATION`). */
const servedNav = vi.hoisted(() => ({ current: null as unknown[] | null }));
/**
* The app's menu as stored (`null`: as served). objectstack#36538: `missing`
* answers every layered read as `MetadataClient.layered` answers a 404;
* `gate` holds the next read until it settles; `overlayVersion` is served
* when set.
*/
const storedNav = vi.hoisted(() => ({
current: null as unknown[] | null,
failReads: 0,
missing: false,
gate: null as Promise<void> | null,
overlayVersion: undefined as string | undefined,
}));
const client = vi.hoisted(() => ({
list: async (type: string) => listed[type] ?? [],
layered: async (type?: string) => {
// objectstack#36504: no menu translation item is stored yet.
if (type === 'translation') return { code: null, overlay: null, overlayScope: null, effective: null };
const gate = storedNav.gate;
storedNav.gate = null;
if (gate) await gate;
if (storedNav.failReads > 0) {
storedNav.failReads -= 1;
throw new Error('layered read failed');
}
if (storedNav.missing) return { code: null, overlay: null, overlayScope: null, effective: null };
const code = { name: 'crm', label: 'CRM', navigation: storedNav.current ?? servedNav.current ?? NAVIGATION };
return { code, effective: code, ...(storedNav.overlayVersion ? { overlayVersion: storedNav.overlayVersion } : {}) };
},
get: async (type: string, name: string) => (server.held.has(`${type}/${name}`) ? { name } : null),
save: async (...args: unknown[]) => {
written.push(['save', ...args]);
if (args[0] === 'app' && server.appSave) throw server.appSave;
return {};
},
publish: async (...args: unknown[]) => {
written.push(['publish', ...args]);
if (args[0] === 'app' && server.appPublish) throw server.appPublish;
return {};
},
reset: async (...args: unknown[]) => {
written.push(['reset', ...args]);
return {};
},
}));
vi.mock('../../views/metadata-admin/useMetadata', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
useMetadataClient: () => client,
}));
vi.mock('../../views/studio-design/packages-io', async (importOriginal) => ({
...(await importOriginal<Record<string, unknown>>()),
fetchListedPackageManifests: async () =>
new Map([['com.acme.crm', { id: 'com.acme.crm', name: 'CRM', writable: true, manifest: { version: '1.0.0' } }]]),
ensureCustomizationPackage: async () => {
throw new Error('not expected');
},
}));
vi.mock('../../utils/getIcon', () => ({ getIcon: () => () => null }));
import { DesignModeProvider, useDesignMode, useDesignModeController, useHoldDesignModeOut } from '../designMode';
import { useDesignModeArrival } from '../useDesignModeArrival';
import { designModeAddDashboardArrival } from '../designModeArrival';
import { DesignModeBar } from '../DesignModeBar';
import DesignModeMenu from '../DesignModeMenu';
import { closestCenter, type CollisionDetection } from '@dnd-kit/core';
import { confirmUnsavedLeave } from '../../chrome/unsavedEdits';
import { __resetDefaultLocale } from '../designModeMenuSave';
const NAVIGATION = [
{ id: 'home', type: 'report', reportName: 'pipeline', label: 'Home' },
{
id: 'sales',
type: 'group',
label: 'Sales',
children: [
{ id: 'leads', type: 'object', objectName: 'crm_lead', label: 'Leads' },
{ id: 'accounts', type: 'object', objectName: 'crm_account', label: 'Accounts' },
],
},
{ id: 'insights', type: 'group', label: 'Insights', children: [] },
];
/** The console's answer for an entry without a label: its object's label. */
const OBJECT_LABELS: Record<string, string> = { crm_lead: 'Leads', crm_account: 'Accounts', crm_case: 'Cases' };
function Harness() {
const mode = useDesignModeController({ appName: 'crm', appBasePath: '/apps/crm', enabled: true });
return (
<DesignModeProvider value={mode}>
{mode.active && <DesignModeBar mode={mode} />}
<Enter />
<SwitchApp />
<SidebarProvider>
{mode.active && (
<DesignModeMenu
app={{ name: 'crm', navigation: servedNav.current ?? NAVIGATION, _packageId: 'com.acme.crm' }}
basePath="/apps/crm"
resolveTargetLabel={(target) => (target.kind === 'object' ? OBJECT_LABELS[target.objectName] : undefined)}
/>
)}
</SidebarProvider>
</DesignModeProvider>
);
}
function Where() {
return <span data-testid="where">{useLocation().pathname}</span>;
}
function Enter() {
const mode = useDesignMode();
return (
<button type="button" onClick={mode?.enter}>
enter
</button>
);
}
/** The app menu's switch, as the sidebar wires it: `confirmUnsavedLeave` around the change of app. */
const switchedTo = vi.hoisted(() => [] as string[]);
function SwitchApp() {
return (
<button type="button" onClick={() => confirmUnsavedLeave(() => switchedTo.push('hr'))}>
switch to hr
</button>
);
}
const flush = () => act(async () => { await new Promise((r) => setTimeout(r, 0)); });
const entry = (id: string) => screen.getByTestId(`design-menu-entry-${id}`);
/** The link the entry `id` is drawn as (dnd-kit gives it the role of a button). */
const linkOf = (id: string) => entry(id).querySelector('a')!;
/** The entries of the group `id` (the top level for `null`), in order. */
function order(): unknown[] {
const list = screen.getByTestId('design-mode-menu').querySelector('ul')!;
const read = (ul: Element): unknown[] =>
[...ul.children].flatMap((li): unknown[] => {
const testid = li.getAttribute('data-testid') ?? '';
if (testid.startsWith('design-menu-entry-')) return [testid.slice('design-menu-entry-'.length)];
if (testid.startsWith('design-menu-group-')) return [[testid.slice('design-menu-group-'.length), read(li.querySelector('ul')!)]];
if (testid === 'design-menu-placeholder') return ['…'];
return [];
});
return read(list);
}
/** Opens the 「⋮」 menu of the entry `id` and picks `item`. */
async function act_on(id: string, item: string) {
const trigger = within(entry(id)).getByTestId('design-menu-actions');
fireEvent.pointerDown(trigger, { button: 0, pointerType: 'mouse' });
await flush();
fireEvent.click(await screen.findByRole('menuitem', { name: item }));
await flush();
}
beforeEach(() => {
written.length = 0;
switchedTo.length = 0;
toastError.mockReset();
session.language = 'en';
session.defaultLocale = 'en';
session.sourceLocale = undefined;
storedNav.current = null;
storedNav.failReads = 0;
storedNav.missing = false;
storedNav.gate = null;
storedNav.overlayVersion = undefined;
dragStarts.length = 0;
server.held.clear();
server.appSave = null;
server.appPublish = null;
servedNav.current = null;
__resetDefaultLocale();
vi.stubGlobal(
'fetch',
vi.fn(async (url: string) => {
if (String(url).endsWith('/api/v1/i18n/locales')) {
const locales = ['en', 'zh-CN'].map((code) => ({ code, label: code, isDefault: code === session.defaultLocale }));
const sourceLocale = session.sourceLocale ? { sourceLocale: session.sourceLocale } : {};
return new Response(JSON.stringify({ success: true, data: { locales, ...sourceLocale } }), { status: 200 });
}
throw new Error(`unexpected fetch ${url}`);
}),
);
});
afterEach(() => {
cleanup();
vi.unstubAllGlobals();
});
function start() {
render(
<MemoryRouter initialEntries={['/apps/crm']}>
<Harness />
</MemoryRouter>,
);
fireEvent.click(screen.getByText('enter'));
}
describe('the menu under the design mode (objectstack#36363)', () => {
it('each group and the top level end with 「Add menu item」; each entry has a 「⋮」 menu', () => {
start();
expect(order()).toEqual(['home', ['sales', ['leads', 'accounts']], ['insights', []]]);
for (const at of ['sales', 'insights', 'top']) expect(screen.getByTestId(`design-menu-add-${at}`)).toHaveTextContent('Add menu item');
expect(within(entry('leads')).getByRole('button', { name: 'Actions for Leads' })).toBeInTheDocument();
});
it('「⋮ → Move up」 is staged, and 「Save」 writes the app with the new menu and publishes it', async () => {
start();
await act_on('accounts', 'Move up');
expect(order()).toEqual(['home', ['sales', ['accounts', 'leads']], ['insights', []]]);
expect(written).toEqual([]);
fireEvent.click(screen.getByTestId('design-mode-save'));
await flush();
await flush();
const [save, publish] = written;
expect(save[0]).toBe('save');
expect((save[3] as { navigation: Array<{ children?: Array<{ id: string }> }> }).navigation[1].children!.map((c) => c.id)).toEqual([
'accounts',
'leads',
]);
expect(save[4]).toEqual({ mode: 'draft', packageId: 'com.acme.crm', ifNoneMatch: '*' });
expect(publish).toEqual(['publish', 'app', 'crm', { packageId: 'com.acme.crm' }]);
expect(screen.queryByTestId('design-mode-bar')).toBeNull();
});
it('「Move to group」 lists the other groups and moves the entry to the end of the one picked', async () => {
start();
const trigger = within(entry('leads')).getByTestId('design-menu-actions');
fireEvent.pointerDown(trigger, { button: 0, pointerType: 'mouse' });
await flush();
const sub = await screen.findByRole('menuitem', { name: 'Move to group' });
fireEvent.keyDown(sub, { key: 'ArrowRight' });
await flush();
const groups = (await screen.findAllByRole('menuitem')).map((m) => m.textContent);
expect(groups).toEqual(expect.arrayContaining(['Top level', 'Insights']));
expect(groups).not.toContain('Sales');
fireEvent.click(screen.getByRole('menuitem', { name: 'Insights' }));
await flush();
expect(order()).toEqual(['home', ['sales', ['accounts']], ['insights', ['leads']]]);
});
it('「Add menu item」 holds a dashed row there, and the picker offers only what exists and is not in the menu', async () => {
start();
fireEvent.click(screen.getByTestId('design-menu-add-insights'));
expect(order()).toEqual(['home', ['sales', ['leads', 'accounts']], ['insights', ['…']]]);
const picker = await screen.findByTestId('design-menu-picker');
fireEvent.click(within(picker).getByRole('button', { name: 'Objects' }));
await flush();
expect(within(picker).getAllByRole('button').map((b) => b.textContent)).toEqual(expect.arrayContaining(['Cases']));
expect(within(picker).queryByRole('button', { name: 'Leads' })).toBeNull();
fireEvent.click(within(picker).getByRole('button', { name: 'Cases' }));
await flush();
expect(screen.queryByTestId('design-menu-picker')).toBeNull();
expect(order()).toEqual(['home', ['sales', ['leads', 'accounts']], ['insights', ['nav_item_1']]]);
expect(screen.getByTestId('design-mode-menu')).toHaveTextContent('Cases');
});
it('the search runs over every kind; a record page is never offered', async () => {
start();
fireEvent.click(screen.getByTestId('design-menu-add-top'));
const picker = await screen.findByTestId('design-menu-picker');
fireEvent.change(within(picker).getByTestId('design-menu-picker-search'), { target: { value: 'e' } });
await flush();
const rows = within(within(picker).getByTestId('design-menu-picker-rows')).getAllByRole('button').map((b) => b.textContent);
expect(rows).toEqual(expect.arrayContaining(['CasesObjects', 'Hot leadsViews', 'WelcomePages']));
expect(rows.join()).not.toContain('Lead record');
// Pipeline is in the menu (Home opens it).
expect(rows.join()).not.toContain('Pipeline');
});
it('「Remove from menu」 takes the entry off, and the picker offers it again', async () => {
start();
await act_on('leads', 'Remove from menu');
expect(order()).toEqual(['home', ['sales', ['accounts']], ['insights', []]]);
fireEvent.click(screen.getByTestId('design-menu-add-sales'));
const picker = await screen.findByTestId('design-menu-picker');
fireEvent.click(within(picker).getByRole('button', { name: 'Objects' }));
await flush();
expect(within(picker).getByRole('button', { name: 'Leads' })).toBeInTheDocument();
});
it('「Rename and icon」 renames the entry in the menu', async () => {
start();
await act_on('leads', 'Rename and icon');
const dialog = await screen.findByTestId('design-menu-rename');
const name = within(dialog).getByLabelText('Name');
fireEvent.change(name, { target: { value: 'Prospects' } });
fireEvent.change(within(dialog).getByLabelText('Icon'), { target: { value: 'user-plus' } });
fireEvent.click(within(dialog).getByRole('button', { name: 'Done' }));
await flush();
expect(entry('leads')).toHaveTextContent('Prospects');
});
// objectstack#36504 relaxes ruling (4) on review 7081226692: a name is changed in any language,
// and lands where that language reads it.
it('under zh-CN over an English source, the name is changed: the rename says it is a zh-CN name, and the save writes the translation and keeps the stored label', async () => {
session.language = 'zh-CN';
session.defaultLocale = 'zh-CN';
session.sourceLocale = 'en';
start();
await flush();
await act_on('leads', 'Rename and icon');
const dialog = await screen.findByTestId('design-menu-rename');
const name = within(dialog).getByLabelText('Name');
expect(name).toBeEnabled();
expect(within(dialog).getByTestId('design-menu-rename-translation')).toHaveTextContent(/The new name is shown in .+\. The app's other languages keep their names\./);
fireEvent.change(name, { target: { value: '潜在客户' } });
fireEvent.change(within(dialog).getByLabelText('Icon'), { target: { value: 'user-plus' } });
fireEvent.click(within(dialog).getByRole('button', { name: 'Done' }));
await flush();
expect(entry('leads')).toHaveTextContent('潜在客户');
fireEvent.click(screen.getByTestId('design-mode-save'));
await flush();
await flush();
await flush();
expect(written.map(([verb, type]) => `${verb} ${type}`)).toEqual(['save translation', 'publish translation', 'save app', 'publish app']);
expect(written[0][3]).toEqual({ name: 'crm_menu_zh_cn', locale: 'zh-CN', apps: { crm: { navigation: { leads: { label: '潜在客户' } } } } });
const leads = (written[2][3] as { navigation: Array<{ children?: Array<Record<string, unknown>> }> }).navigation[1].children![0];
expect(leads).toEqual({ id: 'leads', type: 'object', objectName: 'crm_lead', label: 'Leads', icon: 'user-plus' });
});
it('in the source language, an entry shown under a label other than its stored one is renamed in that language\'s translation', async () => {
storedNav.current = NAVIGATION.map((e) => (e.id === 'home' ? { ...e, label: 'apps.crm.home' } : e));
start();
await flush();
await act_on('home', 'Rename and icon');
const dialog = await screen.findByTestId('design-menu-rename');
expect(within(dialog).getByLabelText('Name')).toBeEnabled();
expect(within(dialog).getByTestId('design-menu-rename-translation')).toBeInTheDocument();
fireEvent.change(within(dialog).getByLabelText('Name'), { target: { value: 'Start' } });
fireEvent.click(within(dialog).getByRole('button', { name: 'Done' }));
await flush();
fireEvent.click(screen.getByTestId('design-mode-save'));
await flush();
await flush();
expect(written.map(([verb, type]) => `${verb} ${type}`)).toEqual(['save translation', 'publish translation']);
expect(written[0][3]).toMatchObject({ name: 'crm_menu_en', locale: 'en', apps: { crm: { navigation: { home: { label: 'Start' } } } } });
});
it('in the source language, over the stored label, the rename says nothing of a translation and writes the stored label', async () => {
start();
await flush();
await act_on('leads', 'Rename and icon');
const dialog = await screen.findByTestId('design-menu-rename');
expect(within(dialog).queryByTestId('design-menu-rename-translation')).toBeNull();
fireEvent.change(within(dialog).getByLabelText('Name'), { target: { value: 'Prospects' } });
fireEvent.click(within(dialog).getByRole('button', { name: 'Done' }));
await flush();
fireEvent.click(screen.getByTestId('design-mode-save'));
await flush();
await flush();
expect(written.map(([verb, type]) => `${verb} ${type}`)).toEqual(['save app', 'publish app']);
});
it("another package's entry (served, not in the stored menu) says where it is changed, and is not moved or removed here", async () => {
storedNav.current = NAVIGATION.map((e) =>
e.id === 'sales' ? { ...e, children: (e.children ?? []).filter((c) => c.id !== 'accounts') } : e,
);
start();
await flush();
const trigger = within(entry('accounts')).getByTestId('design-menu-actions');
fireEvent.pointerDown(trigger, { button: 0, pointerType: 'mouse' });
await flush();
expect(await screen.findByTestId('design-menu-contributed')).toHaveTextContent('Another package adds this item');
for (const name of ['Move up', 'Rename and icon', 'Remove from menu']) {
expect(screen.getByRole('menuitem', { name })).toHaveAttribute('aria-disabled', 'true');
}
expect(screen.getByRole('menuitem', { name: 'Add an item after' })).not.toHaveAttribute('aria-disabled');
});
it("no entry is moved past another package's entry: 「Move down」 above it is off, and a drop on it does nothing", async () => {
storedNav.current = NAVIGATION.map((e) =>
e.id === 'sales' ? { ...e, children: (e.children ?? []).filter((c) => c.id !== 'accounts') } : e,
);
start();
await flush();
const trigger = within(entry('leads')).getByTestId('design-menu-actions');
fireEvent.pointerDown(trigger, { button: 0, pointerType: 'mouse' });
await flush();
expect(await screen.findByRole('menuitem', { name: 'Move down' })).toHaveAttribute('aria-disabled', 'true');
fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' });
await flush();
act(() => dragEnd.current!({ active: { id: 'home' }, over: { id: 'accounts' } }));
expect(order()).toEqual(['home', ['sales', ['leads', 'accounts']], ['insights', []]]);
});
it("when the stored menu could not be read on entry, a move of another package's entry still writes none of it", async () => {
storedNav.current = NAVIGATION.map((e) =>
e.id === 'sales' ? { ...e, children: (e.children ?? []).filter((c) => c.id !== 'accounts') } : e,
);
storedNav.failReads = 1; // the editor's read on entry; the save's read answers
start();
await flush();
await act_on('accounts', 'Move up');
expect(order()).toEqual(['home', ['sales', ['accounts', 'leads']], ['insights', []]]);
fireEvent.click(screen.getByTestId('design-mode-save'));
await flush();
await flush();
const nav = (written[0][3] as { navigation: Array<{ id: string; children?: Array<{ id: string }> }> }).navigation;
expect(nav[1].children!.map((c) => c.id)).toEqual(['leads']);
});
// L1-e review 7083961269 (1): contributions are appended when the app is
// served, so an own entry put at or past them is drawn before them.
const ACCOUNTS_CONTRIBUTED = () =>
NAVIGATION.map((e) => (e.id === 'sales' ? { ...e, children: (e.children ?? []).filter((c) => c.id !== 'accounts') } : e));
it("「Add menu item」 at the end of a group that ends with another package's entries holds the row, and puts the pick, before them", async () => {
storedNav.current = ACCOUNTS_CONTRIBUTED();
start();
await flush();
fireEvent.click(screen.getByTestId('design-menu-add-sales'));
expect(order()).toEqual(['home', ['sales', ['leads', '…', 'accounts']], ['insights', []]]);
const picker = await screen.findByTestId('design-menu-picker');
fireEvent.click(within(picker).getByRole('button', { name: 'Objects' }));
await flush();
fireEvent.click(within(picker).getByRole('button', { name: 'Cases' }));
await flush();
expect(order()).toEqual(['home', ['sales', ['leads', 'nav_item_1', 'accounts']], ['insights', []]]);
fireEvent.click(screen.getByTestId('design-mode-save'));
await flush();
await flush();
const nav = (written[0][3] as { navigation: Array<{ id: string; children?: Array<{ id: string }> }> }).navigation;
expect(nav[1].children!.map((c) => c.id)).toEqual(['leads', 'nav_item_1']);
});
it("「Add an item after」 on another package's entry, and 「Move to group」 into its group, land before it", async () => {
storedNav.current = ACCOUNTS_CONTRIBUTED();
start();
await flush();
await act_on('accounts', 'Add an item after');
expect(order()).toEqual(['home', ['sales', ['leads', '…', 'accounts']], ['insights', []]]);
fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' });
await flush();
const trigger = within(entry('home')).getByTestId('design-menu-actions');
fireEvent.pointerDown(trigger, { button: 0, pointerType: 'mouse' });
await flush();
fireEvent.click(await screen.findByRole('menuitem', { name: 'Move to group' }));
await flush();
fireEvent.click(await screen.findByRole('menuitem', { name: 'Sales' }));
await flush();
expect(order()).toEqual([['sales', ['leads', 'home', 'accounts']], ['insights', []]]);
});
it("dropped on the end of a group that ends with another package's entries, an entry lands before them", async () => {
storedNav.current = ACCOUNTS_CONTRIBUTED();
start();
await flush();
act(() => dragEnd.current!({ active: { id: 'home' }, over: { id: 'design-menu-end:sales' } }));
expect(order()).toEqual([['sales', ['leads', 'home', 'accounts']], ['insights', []]]);
});
// L1-e review 7083961269 (2): the browser's own drag of an entry's link
// would, dropped where the editor does not move it, open the link as a new
// document; and the click a drag ends with is no click.
it("an entry's link is not dragged by the browser, and the click a drag ends with opens nothing", async () => {
storedNav.current = ACCOUNTS_CONTRIBUTED();
render(
<MemoryRouter initialEntries={['/apps/crm']}>
<Harness />
<Where />
</MemoryRouter>,
);
fireEvent.click(screen.getByText('enter'));
await flush();
const leads = linkOf('leads');
expect(leads).toHaveAttribute('draggable', 'false');
expect(fireEvent.dragStart(leads)).toBe(false); // the native drag is refused
expect(fireEvent.dragStart(linkOf('accounts'))).toBe(false);
// Control: a plain click opens the entry's page, in the app.
fireEvent.click(linkOf('home'));
const opened = screen.getByTestId('where').textContent;
expect(opened).not.toBe('/apps/crm');
// A drag of leads refused on another package's entry, then the click it ends with.
act(() => dragStart.current!({ active: { id: 'leads' } }));
act(() => dragEnd.current!({ active: { id: 'leads' }, over: { id: 'accounts' } }));
fireEvent.click(leads);
expect(screen.getByTestId('where').textContent).toBe(opened);
expect(order()).toEqual(['home', ['sales', ['leads', 'accounts']], ['insights', []]]);
expect(screen.getByTestId('design-mode-bar')).toBeInTheDocument();
});
// L1-e review 7084606001: on the real event order. dnd-kit's pointer sensor,
// once a drag is active, stops the click that follows in the document's
// capture phase without cancelling it, so a handler on React's root never
// sees it and the link's default (a full navigation) would run.
it('the click a real pointer drag ends with is cancelled before dnd-kit stops it', async () => {
storedNav.current = ACCOUNTS_CONTRIBUTED();
render(
<MemoryRouter initialEntries={['/apps/crm']}>
<Harness />
<Where />
</MemoryRouter>,
);
fireEvent.click(screen.getByText('enter'));
await flush();
const leads = linkOf('leads');
const pointer = (type: string, target: EventTarget, x: number) => {
const event = new MouseEvent(type, { bubbles: true, cancelable: true, clientX: x, clientY: 10, button: 0, buttons: 1 });
Object.defineProperty(event, 'isPrimary', { value: true });
Object.defineProperty(event, 'pointerType', { value: 'mouse' });
act(() => {
target.dispatchEvent(event);
});
};
let stoppedInDocument = false;
const watch = () => {
stoppedInDocument = true;
};
pointer('pointerdown', leads, 10);
pointer('pointermove', document, 30); // past the 5 px activation distance
pointer('pointermove', document, 40);
pointer('pointerup', document, 40);
const released = linkOf('leads'); // the link under the pointer when it is released
document.addEventListener('click', watch); // bubble: reached only if dnd-kit did not stop it
const click = new MouseEvent('click', { bubbles: true, cancelable: true, button: 0 });
act(() => {
released.dispatchEvent(click);
});
document.removeEventListener('click', watch);
// dnd-kit takes its click listener off 50 ms after the drag; wait before
// asserting, so a failure here leaves no listener to the next case.
await act(async () => {
await new Promise((r) => setTimeout(r, 350));
});
expect(stoppedInDocument).toBe(false); // dnd-kit stopped it, as in the browser
expect(click.defaultPrevented).toBe(true); // and its default is cancelled
// A plain click afterwards is a click again: it opens the entry's page.
const before = screen.getByTestId('where').textContent;
fireEvent.click(linkOf('leads'));
expect(screen.getByTestId('where').textContent).not.toBe(before);
expect(screen.getByTestId('design-mode-bar')).toBeInTheDocument();
});
// Review 7085270448 S3: dnd-kit reports a drag's start at 5 px but its end
// only after the start has rendered, so a flick released first can end with
// no end reported. The release itself ends it: links open again.
it('a drag whose end dnd-kit never reports (a fast flick) does not leave the links shut', async () => {
render(
<MemoryRouter initialEntries={['/apps/crm']}>
<Harness />
<Where />
</MemoryRouter>,
);
fireEvent.click(screen.getByText('enter'));
await flush();
act(() => dragStart.current!({ active: { id: 'leads' } })); // started, and no end reported
fireEvent.pointerUp(window);
await act(async () => {
await new Promise((r) => setTimeout(r, 350));
});
fireEvent.click(linkOf('home'));
expect(screen.getByTestId('where').textContent).not.toBe('/apps/crm');
});
it('adding and moving stay open under zh-CN', async () => {
session.language = 'zh-CN';
start();
await flush();
await act_on('accounts', 'Move up');
expect(order()).toEqual(['home', ['sales', ['accounts', 'leads']], ['insights', []]]);
fireEvent.click(screen.getByTestId('design-menu-add-insights'));
expect(await screen.findByTestId('design-menu-picker')).toBeInTheDocument();
});
// N4 on review 7081253549: the drop's wiring, to another group.
it('an entry dropped on another group\'s end moves there; dropped on an entry elsewhere, it takes that place', async () => {
start();
act(() => dragEnd.current!({ active: { id: 'leads' }, over: { id: 'design-menu-end:insights' } }));
expect(order()).toEqual(['home', ['sales', ['accounts']], ['insights', ['leads']]]);
act(() => dragEnd.current!({ active: { id: 'accounts' }, over: { id: 'home' } }));
expect(order()).toEqual(['accounts', 'home', ['sales', []], ['insights', ['leads']]]);
act(() => dragEnd.current!({ active: { id: 'home' }, over: { id: 'design-menu-end:' } }));
expect(order()).toEqual(['accounts', ['sales', []], ['insights', ['leads']], 'home']);
fireEvent.click(screen.getByTestId('design-mode-save'));
await flush();
await flush();
const nav = (written[0][3] as { navigation: Array<{ id: string; children?: Array<{ id: string }> }> }).navigation;
expect(nav.map((e) => [e.id, e.children?.map((c) => c.id)])).toEqual([
['accounts', undefined],
['sales', []],
['insights', ['leads']],
['home', undefined],
]);
});
it('「Cancel」 after three edits leaves the menu as it was, and writes nothing', async () => {
start();
await act_on('accounts', 'Move up');
await act_on('home', 'Remove from menu');
await act_on('leads', 'Move down');
fireEvent.click(screen.getByTestId('design-mode-cancel'));
fireEvent.click(screen.getByText('enter'));
expect(order()).toEqual(['home', ['sales', ['leads', 'accounts']], ['insights', []]]);
expect(written).toEqual([]);
});
// Card comment 7079728193: unsaved menu changes ask before the app is left,
// in the shell's one unsaved-changes prompt (stay, or leave and drop them).
it('a moved entry not yet saved: switching app asks first; staying keeps the change, leaving goes on', async () => {
const confirmSpy = vi.fn((_message?: string): boolean => false);
vi.stubGlobal('confirm', confirmSpy);
start();
await act_on('accounts', 'Move up');
expect(order()).toEqual(['home', ['sales', ['accounts', 'leads']], ['insights', []]]);
fireEvent.click(screen.getByText('switch to hr'));
expect(confirmSpy).toHaveBeenCalledWith('Leave Design mode? Your unsaved changes will be lost.');
expect(switchedTo).toEqual([]);
expect(screen.getByTestId('design-mode-bar')).toBeInTheDocument();
expect(order()).toEqual(['home', ['sales', ['accounts', 'leads']], ['insights', []]]);
expect(written).toEqual([]);
confirmSpy.mockReturnValue(true);
fireEvent.click(screen.getByText('switch to hr'));
expect(switchedTo).toEqual(['hr']);
expect(written).toEqual([]);
});
it('a reload or a tab close is held while a menu change is unsaved, and not once it is saved', async () => {
const held = () => {
const unload = new Event('beforeunload', { cancelable: true });
window.dispatchEvent(unload);
return unload.defaultPrevented;
};
start();
expect(held()).toBe(false);
await act_on('accounts', 'Move up');
expect(held()).toBe(true);
fireEvent.click(screen.getByTestId('design-mode-save'));
await flush();
await flush();
expect(held()).toBe(false);
});
it('with nothing changed, switching app asks nothing', () => {
const confirmSpy = vi.fn((_message?: string): boolean => false);
vi.stubGlobal('confirm', confirmSpy);
start();
fireEvent.click(screen.getByText('switch to hr'));
expect(confirmSpy).not.toHaveBeenCalled();
expect(switchedTo).toEqual(['hr']);
});
});
/** objectstack#36364 — where the page went, and the navigation state it went with. */
function Landing() {
const location = useLocation();
return <span data-testid="landing">{`${location.pathname} ${JSON.stringify(location.state)}`}</span>;
}
function startWithLanding() {
render(
<MemoryRouter initialEntries={['/apps/crm']}>
<Harness />
<Landing />
</MemoryRouter>,
);
fireEvent.click(screen.getByText('enter'));
}
/** 「Add menu item」 under Insights, then 「Dashboards」: the picker's dashboard list. */
async function openDashboards() {
fireEvent.click(screen.getByTestId('design-menu-add-insights'));
const picker = await screen.findByTestId('design-menu-picker');
fireEvent.click(within(picker).getByRole('button', { name: 'Dashboards' }));
await flush();
return picker;
}
describe('a new dashboard from 「Add menu item」 (objectstack#36364)', () => {
it('「Dashboards」 lists 「New dashboard…」 first, above the dashboards not in the menu yet', async () => {
listed.dashboard = [{ name: 'revenue', label: 'Revenue' }];
try {
start();
const picker = await openDashboards();
const rows = within(within(picker).getByTestId('design-menu-picker-rows')).getAllByRole('button').map((b) => b.textContent);
expect(rows).toEqual(['New dashboard…', 'Revenue']);
// Another kind has no such row.
fireEvent.click(within(picker).getByRole('button', { name: 'Dashboards' }));
fireEvent.click(within(picker).getByRole('button', { name: 'Reports' }));
await flush();
expect(within(picker).queryByText('New dashboard…')).toBeNull();
} finally {
listed.dashboard = [];
}
});
it('「Cancel」 at the name writes nothing and leaves nothing in the menu', async () => {
start();
const picker = await openDashboards();
fireEvent.click(within(picker).getByTestId('design-menu-picker-new-dashboard'));
const naming = await screen.findByTestId('design-menu-new-dashboard');
fireEvent.change(within(naming).getByTestId('design-menu-new-name'), { target: { value: 'Payment analysis' } });
fireEvent.click(within(naming).getByTestId('design-menu-new-cancel'));
await flush();
expect(screen.queryByTestId('design-menu-new-dashboard')).toBeNull();
expect(order()).toEqual(['home', ['sales', ['leads', 'accounts']], ['insights', []]]);
expect(written).toEqual([]);
expect(screen.getByTestId('design-mode-save')).toBeDisabled();
});
it('「Create」: the dashboard, then the menu with its entry in the held place and every other staged edit; the mode is left and the dashboard opens for editing', async () => {
server.held.add('dashboard/payment_analysis'); // a dashboard of another app holds the plain name
startWithLanding();
await act_on('accounts', 'Move up'); // another staged edit, saved with it
const picker = await openDashboards();
fireEvent.click(within(picker).getByTestId('design-menu-picker-new-dashboard'));
const naming = await screen.findByTestId('design-menu-new-dashboard');
fireEvent.change(within(naming).getByTestId('design-menu-new-name'), { target: { value: 'Payment analysis' } });
expect(written).toEqual([]);
fireEvent.click(within(naming).getByTestId('design-menu-new-create'));
await flush();
await flush();
await flush();
expect(written.map(([verb, type, name]) => `${verb} ${type} ${name}`)).toEqual([
'save dashboard payment_analysis_2',
'publish dashboard payment_analysis_2',
'save app crm',
'publish app crm',
]);
expect(written[0][3]).toEqual({ name: 'payment_analysis_2', label: 'Payment analysis', widgets: [] });
const navigation = (written[2][3] as { navigation: Array<{ id: string; children?: unknown[] }> }).navigation;
expect(navigation[1].children!.map((c) => (c as { id: string }).id)).toEqual(['accounts', 'leads']);
expect(navigation[2].children).toEqual([{ id: 'nav_item_1', type: 'dashboard', dashboardName: 'payment_analysis_2' }]);
expect(screen.queryByTestId('design-mode-bar')).toBeNull();
expect(screen.getByTestId('landing')).toHaveTextContent(
'/apps/crm/dashboard/payment_analysis_2 {"designModeNewDashboard":"payment_analysis_2"}',
);
});
it('a refused menu removes the new dashboard; the mode, the held place and the other staged edits stay', async () => {
server.appSave = new Error('the app was refused');
startWithLanding();
await act_on('accounts', 'Move up');
const picker = await openDashboards();
fireEvent.click(within(picker).getByTestId('design-menu-picker-new-dashboard'));
const naming = await screen.findByTestId('design-menu-new-dashboard');
fireEvent.change(within(naming).getByTestId('design-menu-new-name'), { target: { value: 'Payment analysis' } });
fireEvent.click(within(naming).getByTestId('design-menu-new-create'));
await flush();
await flush();
await flush();
expect(written.map(([verb, type, name, opt]) => `${verb} ${type} ${name} ${JSON.stringify(opt)}`)).toEqual([
'save dashboard payment_analysis {"name":"payment_analysis","label":"Payment analysis","widgets":[]}',
'publish dashboard payment_analysis {"packageId":"com.acme.crm"}',
expect.stringMatching(/^save app crm /),
'reset dashboard payment_analysis {"packageId":"com.acme.crm"}',
]);
expect(toastError).toHaveBeenCalledWith('Some changes were not saved: the app was refused');
expect(screen.getByTestId('design-mode-bar')).toBeInTheDocument();
expect(screen.getByTestId('design-menu-new-dashboard')).toBeInTheDocument();
expect(order()).toEqual(['home', ['sales', ['accounts', 'leads']], ['insights', ['…']]]);
expect(screen.getByTestId('landing')).toHaveTextContent('/apps/crm null');
});
});
/** 「Add menu item」 under Insights, then 「Reports」. */
async function openReports() {
fireEvent.click(screen.getByTestId('design-menu-add-insights'));
const picker = await screen.findByTestId('design-menu-picker');
fireEvent.click(within(picker).getByRole('button', { name: 'Reports' }));
await flush();
return picker;
}
/**
* objectstack#36692 — the design mode stops hosting the report builder (the
* maintainer's 「照 Twenty 分开」): 「Reports」 only links reports that exist;
* a new report is made from the reports index, with its own Save.
*/
describe('「Reports」 links existing reports only (objectstack#36692)', () => {
it('lists the reports not in the menu yet, and no 「New report…」 row', async () => {
listed.report = [
{ name: 'pipeline', label: 'Pipeline' },
{ name: 'revenue_by_month', label: 'Revenue by month' },
];
try {
start();
const picker = await openReports();
const rows = within(within(picker).getByTestId('design-menu-picker-rows')).getAllByRole('button').map((b) => b.textContent);
// The report the menu already opens (Home → pipeline) is not offered again.
expect(rows).toEqual(['Revenue by month']);
expect(within(picker).queryByTestId('design-menu-picker-new-report')).toBeNull();
expect(within(picker).queryByText('New report…')).toBeNull();
} finally {
listed.report = [{ name: 'pipeline', label: 'Pipeline' }];
}
});
it('picking one links it in the held place, staged with the mode; nothing is written, nothing navigates', async () => {
listed.report = [{ name: 'revenue_by_month', label: 'Revenue by month' }];
try {
startWithLanding();
const picker = await openReports();
fireEvent.click(within(picker).getByRole('button', { name: 'Revenue by month' }));
await flush();
expect(screen.queryByTestId('design-menu-picker')).toBeNull();
expect(order()).toEqual(['home', ['sales', ['leads', 'accounts']], ['insights', ['nav_item_1']]]);
expect(written).toEqual([]);
expect(screen.getByTestId('landing')).toHaveTextContent('/apps/crm null');
expect(screen.getByTestId('design-mode-save')).toBeEnabled();
} finally {
listed.report = [{ name: 'pipeline', label: 'Pipeline' }];
}
});
});
// ── objectstack#36591 ─────────────────────────────────────────────────────────
/**
* objectstack#36591 — the design mode's menu reads, and saves, in the order
* the sidebar draws it.
*
* The sidebar sorts each level by `order` (`byNavOrder`, internal to
* `@object-ui/layout`); the editor read and saved array order, so a move in an
* app whose entries carry `order` (an AI-built app's do) was saved and changed
* nothing on screen. The sidebar here is the real one (`NavigationRenderer`),
* drawn over what the save wrote, so these pins state no sort of their own.
*/
describe('the design-mode menu in the sidebar order (objectstack#36591)', () => {
const object = (id: string, objectName: string, label: string, order?: number) => ({
id,
type: 'object',
objectName,
label,
...(order === undefined ? {} : { order }),
});
/** Authored out of `order`: the sidebar reads Customers, Contacts, Opportunities, Reports (Follow-ups, Pipeline). */
const ORDERED = () => [
object('opps', 'crm_opportunity', 'Opportunities', 2),
object('customers', 'crm_customer', 'Customers', 0),
{
id: 'reports',
type: 'group',
label: 'Reports',
order: 3,
expanded: true,
children: [
{ id: 'pipeline', type: 'report', reportName: 'pipeline', label: 'Pipeline', order: 1 },
object('followups', 'crm_follow_up', 'Follow-ups', 0),
],
},
object('contacts', 'crm_contact', 'Contacts', 1),
];
const LABELS = ['Customers', 'Contacts', 'Opportunities', 'Reports', 'Follow-ups', 'Pipeline', 'Cases', 'Leads', 'Accounts', 'Home', 'Sales', 'Insights'];
/** The labels `el` shows, in the order it shows them; each must show once. */
function labelsIn(el: Element): string[] {
const text = el.textContent ?? '';
const shown = LABELS.filter((l) => text.includes(l));
for (const l of shown) expect(text.indexOf(l)).toBe(text.lastIndexOf(l));
return shown.sort((a, b) => text.indexOf(a) - text.indexOf(b));
}
/** The running app's sidebar over `nav`. */
function sidebarOrder(nav: unknown): string[] {
const { container, unmount } = render(
<MemoryRouter initialEntries={['/apps/crm']}>
<SidebarProvider defaultOpen>
<NavigationRenderer
items={nav as NavigationItem[]}
basePath="/apps/crm"
resolveTargetLabel={(target) => (target.kind === 'object' ? OBJECT_LABELS[target.objectName] : undefined)}
/>
</SidebarProvider>
</MemoryRouter>,
);
const shown = labelsIn(container);
unmount();
return shown;
}
/** The design mode's menu, as it reads. */
const editorOrder = () => labelsIn(screen.getByTestId('design-mode-menu'));
async function save(): Promise<Array<Record<string, unknown>>> {
fireEvent.click(screen.getByTestId('design-mode-save'));
await flush();
await flush();
expect(written.map(([verb]) => verb)).toEqual(['save', 'publish']);
return (written[0][3] as { navigation: Array<Record<string, unknown>> }).navigation;
}
/** Every `order` key of `nav`, at every depth. */
const orderKeys = (nav: unknown): unknown[] =>
(nav as Array<Record<string, unknown>>).flatMap((e) => [
...('order' in e ? [e.order] : []),
...(Array.isArray(e.children) ? orderKeys(e.children) : []),
]);
it('an app whose entries carry `order` reads in the design mode as in the sidebar', () => {
servedNav.current = ORDERED();
start();
expect(editorOrder()).toEqual(['Customers', 'Contacts', 'Opportunities', 'Reports', 'Follow-ups', 'Pipeline']);
cleanup();
expect(sidebarOrder(ORDERED())).toEqual(['Customers', 'Contacts', 'Opportunities', 'Reports', 'Follow-ups', 'Pipeline']);
});
it('「Move up」 on Contacts, saved: the sidebar reads Contacts, Customers, …, and the design mode reads the same again', async () => {
servedNav.current = ORDERED();
start();
await act_on('contacts', 'Move up');
const shown = editorOrder();
expect(shown).toEqual(['Contacts', 'Customers', 'Opportunities', 'Reports', 'Follow-ups', 'Pipeline']);
const saved = await save();