44 lines
1.6 KiB
JavaScript
44 lines
1.6 KiB
JavaScript
import { describe, expect, it } from 'vitest'
|
|
import { getNavigationMenu } from './menu'
|
|
|
|
describe('getNavigationMenu', () => {
|
|
it('groups the approved phase-one modules and preserves legacy standalone items', () => {
|
|
const menu = getNavigationMenu({ isAdmin: true })
|
|
|
|
expect(menu.sections.map(section => [
|
|
section.label,
|
|
section.items.map(item => item.label)
|
|
])).toEqual([
|
|
['物料主数据', ['物料', '基础配置']],
|
|
['公司组织', ['组织管理', '用户管理', '角色与权限']],
|
|
['业务伙伴', ['供应商', '制造商', '客户']],
|
|
['库存管理', ['库存查询', '入库管理', '出库管理']]
|
|
])
|
|
expect(menu.sections.flatMap(section => section.items).map(item => item.path)).toEqual([
|
|
'/materials', '/master-data/settings',
|
|
'/organizations', '/users', '/roles',
|
|
'/partners/suppliers', '/partners/manufacturers', '/partners/customers',
|
|
'/stock', '/inbound', '/outbound'
|
|
])
|
|
|
|
expect(menu.standalone).toEqual([
|
|
{ path: '/application', label: '物料申请' },
|
|
{ path: '/approval', label: '申请审批', adminOnly: true },
|
|
{ path: '/logs', label: '日志记录', adminOnly: true }
|
|
])
|
|
})
|
|
|
|
it('keeps the existing non-admin stock and application entries', () => {
|
|
const menu = getNavigationMenu({ isAdmin: false })
|
|
|
|
expect(menu.sections).toEqual([
|
|
{
|
|
key: 'inventory',
|
|
label: '库存管理',
|
|
items: [{ path: '/stock', label: '库存查询' }]
|
|
}
|
|
])
|
|
expect(menu.standalone).toEqual([{ path: '/application', label: '物料申请' }])
|
|
})
|
|
})
|