1
This commit is contained in:
@@ -41,7 +41,7 @@ test('keeps the confirmed top-level sequence from the client workbench prototype
|
||||
)
|
||||
})
|
||||
|
||||
test('keeps the confirmed navigation groups and leaf order', () => {
|
||||
test('keeps only implemented navigation groups visible', () => {
|
||||
assert.deepEqual(
|
||||
clientNavigation.map((node) => ({
|
||||
title: node.title,
|
||||
@@ -51,23 +51,7 @@ test('keeps the confirmed navigation groups and leaf order', () => {
|
||||
{ title: '业务总览', children: undefined },
|
||||
{
|
||||
title: '头程物流',
|
||||
children: ['头程下单', '一键导入', '快速下单'],
|
||||
},
|
||||
{
|
||||
title: '出海下单',
|
||||
children: ['海外采购', '美国本土卡', '美本土散板'],
|
||||
},
|
||||
{
|
||||
title: '海外仓',
|
||||
children: ['贴标申请', '退货入库', '退货换标', '退货出库'],
|
||||
},
|
||||
{
|
||||
title: '订单管理',
|
||||
children: ['我的订单', '入库订单列表', '派送订单列表'],
|
||||
},
|
||||
{
|
||||
title: '财务结算',
|
||||
children: ['应付账单'],
|
||||
children: ['头程下单'],
|
||||
},
|
||||
{
|
||||
title: '企业管理',
|
||||
@@ -78,7 +62,7 @@ test('keeps the confirmed navigation groups and leaf order', () => {
|
||||
)
|
||||
})
|
||||
|
||||
test('provides icons and unique keys recursively for every prototype item', () => {
|
||||
test('provides icons and unique keys recursively for every visible item', () => {
|
||||
const nodes = collectNavigationNodes(clientNavigation)
|
||||
|
||||
for (const node of nodes) {
|
||||
@@ -87,26 +71,13 @@ test('provides icons and unique keys recursively for every prototype item', () =
|
||||
assert.equal(new Set(nodes.map((node) => node.key)).size, nodes.length)
|
||||
})
|
||||
|
||||
test('flattens the complete prototype tree with unique paths', () => {
|
||||
test('flattens visible leaves with unique paths', () => {
|
||||
const leaves = getNavigationLeaves(clientNavigation)
|
||||
const paths = leaves.map((leaf) => leaf.path)
|
||||
|
||||
assert.deepEqual(paths, [
|
||||
'/',
|
||||
'/orders/first-leg',
|
||||
'/first-leg/import',
|
||||
'/first-leg/quick-order',
|
||||
'/cross-border/procurement',
|
||||
'/cross-border/domestic-trucking',
|
||||
'/cross-border/pallet-shipping',
|
||||
'/overseas-warehouse/labeling',
|
||||
'/overseas-warehouse/return-inbound',
|
||||
'/overseas-warehouse/return-relabel',
|
||||
'/overseas-warehouse/return-outbound',
|
||||
'/orders/my',
|
||||
'/orders/inbound',
|
||||
'/orders/delivery',
|
||||
'/finance/payables',
|
||||
'/company/profile',
|
||||
'/organization/members',
|
||||
'/organization/roles',
|
||||
@@ -114,39 +85,23 @@ test('flattens the complete prototype tree with unique paths', () => {
|
||||
'/account/profile',
|
||||
])
|
||||
assert.equal(new Set(paths).size, paths.length)
|
||||
assert.ok(leaves.filter((leaf) => leaf.permission).every((leaf) => leaf.permission?.trim().length > 0))
|
||||
assert.ok(leaves.every((leaf) => leaf.permission.trim().length > 0))
|
||||
})
|
||||
|
||||
test('filters inaccessible leaves and empty navigation groups', () => {
|
||||
const visible = filterNavigationByPermissions(clientNavigation, ['account:profile:view', 'order:first-leg:list'])
|
||||
|
||||
assert.deepEqual(getNavigationLeaves(visible).map((item) => item.path), [
|
||||
'/orders/first-leg',
|
||||
'/first-leg/import',
|
||||
'/first-leg/quick-order',
|
||||
'/cross-border/procurement',
|
||||
'/cross-border/domestic-trucking',
|
||||
'/cross-border/pallet-shipping',
|
||||
'/overseas-warehouse/labeling',
|
||||
'/overseas-warehouse/return-inbound',
|
||||
'/overseas-warehouse/return-relabel',
|
||||
'/overseas-warehouse/return-outbound',
|
||||
'/orders/my',
|
||||
'/orders/inbound',
|
||||
'/orders/delivery',
|
||||
'/finance/payables',
|
||||
'/account/profile',
|
||||
])
|
||||
assert.deepEqual(visible.map((item) => item.title), ['头程物流', '出海下单', '海外仓', '订单管理', '财务结算', '我的信息'])
|
||||
assert.deepEqual(getNavigationLeaves(visible).map((item) => item.path), ['/orders/first-leg', '/account/profile'])
|
||||
assert.deepEqual(visible.map((item) => item.title), ['头程物流', '我的信息'])
|
||||
assert.equal(getFirstAccessiblePath(['account:profile:view']), '/account/profile')
|
||||
assert.equal(getFirstAccessiblePath([]), '/forbidden')
|
||||
})
|
||||
|
||||
test('excludes entries marked for manual hiding without affecting other visible items', () => {
|
||||
const visible = filterNavigationByPermissions([
|
||||
{ key: 'shown', title: '显示入口', icon: LayoutGrid, path: '/shown' },
|
||||
{ key: 'hidden', title: '隐藏入口', icon: LayoutGrid, path: '/hidden', hidden: true },
|
||||
], [])
|
||||
{ key: 'shown', title: '显示入口', icon: LayoutGrid, path: '/shown', permission: 'shown:view' },
|
||||
{ key: 'hidden', title: '隐藏入口', icon: LayoutGrid, path: '/hidden', permission: 'hidden:view', hidden: true },
|
||||
], ['shown:view', 'hidden:view'])
|
||||
|
||||
assert.deepEqual(getNavigationLeaves(visible).map((item) => item.path), ['/shown'])
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user