| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import assert from 'node:assert/strict'
- let selectSidebarRoutes
- let getSubsystemHomePath
- try {
- ({ selectSidebarRoutes, getSubsystemHomePath } = await import('../src/router/sidebarRouteUtils.js'))
- } catch {
- // The first RED run intentionally reaches this branch before the helper exists.
- }
- assert.equal(typeof selectSidebarRoutes, 'function', 'sidebar routing must be selected by a shared route helper')
- assert.equal(typeof getSubsystemHomePath, 'function', 'subsystem fallback navigation must use canonical route prefixes')
- const routes = [
- { path: '/index' },
- { path: '/system' },
- { path: '/subSystem/gas' },
- { path: '/subSystem/pipeNetwork' },
- { path: '/subSystem/waterSupply' },
- { path: '/waterSupply' },
- { path: '/pipeNetwork' }
- ]
- assert.deepEqual(
- selectSidebarRoutes('/system/menu', routes).map(route => route.path),
- ['/index', '/system'],
- 'admin pages must not display subsystem routes, including legacy aliases'
- )
- assert.deepEqual(
- selectSidebarRoutes('/subSystem/waterSupply/whome', routes).map(route => route.path),
- ['/subSystem/waterSupply'],
- 'the water subsystem must display only its own dynamic route tree'
- )
- assert.deepEqual(
- selectSidebarRoutes('/subSystem/pipeNetwork/index', routes).map(route => route.path),
- ['/subSystem/pipeNetwork'],
- 'the pipe network subsystem must display only its own dynamic route tree'
- )
- assert.equal(
- getSubsystemHomePath('waterSupply'),
- '/subSystem/waterSupply/index',
- 'water fallback navigation must target the backend route namespace'
- )
- assert.equal(
- getSubsystemHomePath('pipeNetwork'),
- '/subSystem/pipeNetwork/index',
- 'pipe network fallback navigation must target the backend route namespace'
- )
- console.log('sidebarRouteUtils tests passed')
|