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/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.equal( getSubsystemHomePath('waterSupply'), '/subSystem/waterSupply/index', 'water fallback navigation must target the backend route namespace' ) console.log('sidebarRouteUtils tests passed')