@open-mercato/ui 0.6.8-develop.6915.1.ac6031c503 → 0.6.8-develop.6916.1.f04fff3436
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-mercato/ui",
|
|
3
|
-
"version": "0.6.8-develop.
|
|
3
|
+
"version": "0.6.8-develop.6916.1.f04fff3436",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -155,14 +155,14 @@
|
|
|
155
155
|
"remark-gfm": "^4.0.1"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
|
-
"@open-mercato/shared": "0.6.8-develop.
|
|
158
|
+
"@open-mercato/shared": "0.6.8-develop.6916.1.f04fff3436",
|
|
159
159
|
"react": ">=18.0.0",
|
|
160
160
|
"react-dom": ">=18.0.0",
|
|
161
161
|
"react-is": ">=18.0.0"
|
|
162
162
|
},
|
|
163
163
|
"devDependencies": {
|
|
164
164
|
"@figma/code-connect": "^1.3.4",
|
|
165
|
-
"@open-mercato/shared": "0.6.8-develop.
|
|
165
|
+
"@open-mercato/shared": "0.6.8-develop.6916.1.f04fff3436",
|
|
166
166
|
"@testing-library/dom": "^10.4.1",
|
|
167
167
|
"@testing-library/jest-dom": "^7.0.0",
|
|
168
168
|
"@testing-library/react": "^16.3.1",
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Characterization tests for `buildAdminNav`'s ordering contract.
|
|
3
|
+
*
|
|
4
|
+
* These lock in behavior that already existed — `buildAdminNav` is not modified by #4845. They
|
|
5
|
+
* exist because the nav payload's serialization boundary (`auth/lib/backendChrome.tsx`) now mirrors
|
|
6
|
+
* this precedence (`priority ?? order`, title tiebreak); if it changes here, the two sorts drift and
|
|
7
|
+
* the payload's `order` field stops matching the sequence it ships items in.
|
|
8
|
+
*
|
|
9
|
+
* The regression coverage for #4845 itself lives in
|
|
10
|
+
* `packages/shared/src/modules/__tests__/route-overrides.test.ts` (the override alias normalization)
|
|
11
|
+
* and `packages/core/src/modules/auth/api/__tests__/admin-nav.test.ts` (the serialized field).
|
|
12
|
+
*/
|
|
13
|
+
import { buildAdminNav } from '../nav'
|
|
14
|
+
|
|
15
|
+
type NavModule = Parameters<typeof buildAdminNav>[0][number]
|
|
16
|
+
|
|
17
|
+
const passthroughTranslate = (_key: string | undefined, fallback: string) => fallback
|
|
18
|
+
|
|
19
|
+
function buildNav(modules: NavModule[]) {
|
|
20
|
+
return buildAdminNav(modules, { auth: { roles: [] } }, [], passthroughTranslate, {
|
|
21
|
+
checkFeatures: async (features) => features,
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe('buildAdminNav item ordering', () => {
|
|
26
|
+
it('sorts same-group items by declared order regardless of module registration order', async () => {
|
|
27
|
+
const entries = await buildNav([
|
|
28
|
+
{
|
|
29
|
+
id: 'later_page',
|
|
30
|
+
backendRoutes: [
|
|
31
|
+
{ pattern: '/backend/later/page-b', title: 'Beta page', group: 'Shared', groupKey: 'shared.nav.group', order: 71 },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'earlier_page',
|
|
36
|
+
backendRoutes: [
|
|
37
|
+
{ pattern: '/backend/earlier/page-a', title: 'Alpha page', group: 'Shared', groupKey: 'shared.nav.group', order: 70 },
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
] as NavModule[])
|
|
41
|
+
|
|
42
|
+
expect(entries.map((entry) => entry.href)).toEqual([
|
|
43
|
+
'/backend/earlier/page-a',
|
|
44
|
+
'/backend/later/page-b',
|
|
45
|
+
])
|
|
46
|
+
expect(entries.map((entry) => entry.order)).toEqual([70, 71])
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('sorts nested children by declared order and keeps the parent order intact', async () => {
|
|
50
|
+
const entries = await buildNav([
|
|
51
|
+
{
|
|
52
|
+
id: 'wms',
|
|
53
|
+
backendRoutes: [
|
|
54
|
+
{ pattern: '/backend/wms', title: 'Warehouse', group: 'WMS', groupKey: 'wms.nav.group', order: 95 },
|
|
55
|
+
{ pattern: '/backend/wms/zones', title: 'Zones', group: 'WMS', groupKey: 'wms.nav.group', order: 120 },
|
|
56
|
+
{ pattern: '/backend/wms/inventory', title: 'Inventory', group: 'WMS', groupKey: 'wms.nav.group', order: 100 },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
] as NavModule[])
|
|
60
|
+
|
|
61
|
+
expect(entries).toHaveLength(1)
|
|
62
|
+
expect(entries[0]?.order).toBe(95)
|
|
63
|
+
expect(entries[0]?.children?.map((child) => child.href)).toEqual([
|
|
64
|
+
'/backend/wms/inventory',
|
|
65
|
+
'/backend/wms/zones',
|
|
66
|
+
])
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
it('ranks an explicit priority ahead of the declared order', async () => {
|
|
70
|
+
const entries = await buildNav([
|
|
71
|
+
{
|
|
72
|
+
id: 'reports',
|
|
73
|
+
backendRoutes: [
|
|
74
|
+
{ pattern: '/backend/reports/monthly', title: 'Monthly', group: 'Reports', groupKey: 'reports.nav.group', order: 10 },
|
|
75
|
+
{ pattern: '/backend/reports/daily', title: 'Daily', group: 'Reports', groupKey: 'reports.nav.group', order: 20, priority: 1 },
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
] as NavModule[])
|
|
79
|
+
|
|
80
|
+
expect(entries.map((entry) => entry.href)).toEqual([
|
|
81
|
+
'/backend/reports/daily',
|
|
82
|
+
'/backend/reports/monthly',
|
|
83
|
+
])
|
|
84
|
+
})
|
|
85
|
+
})
|