| 1234567891011121314151617181920212223242526272829303132333435 |
- import test from 'node:test'
- import assert from 'node:assert/strict'
- import { resolveWaterHomeRoute } from '../src/router/waterHomeRouteResolver.js'
- test('resolves dedicated water routes by canonical suffix', () => {
- const route = resolveWaterHomeRoute([
- { path: '/subSystem/waterSupply/monitorAlarm/index', meta: { title: '报警管理' } },
- { path: '/subSystem/waterSupply/monitorAlarm/audit', meta: { title: '报警审核' } }
- ], '/monitorAlarm/index')
- assert.equal(route.path, '/subSystem/waterSupply/monitorAlarm/index')
- })
- test('resolves legacy shared alarm menus without changing database routes', () => {
- const routes = [
- { path: '/subSystem/alarm/alarmList', meta: { title: '报警管理' }, query: { rootTypeId: 1 } },
- { path: '/subSystem/alarm/alarmAudit', meta: { title: '报警审核' }, query: { rootTypeId: 1 } }
- ]
- assert.equal(resolveWaterHomeRoute(routes, '/monitorAlarm/index').path, '/subSystem/alarm/alarmList')
- assert.equal(resolveWaterHomeRoute(routes, '/monitorAlarm/audit').path, '/subSystem/alarm/alarmAudit')
- })
- test('does not select an unrelated subsystem route with the same title', () => {
- const routes = [
- { path: '/subSystem/drainage/monitorAlarm/index', meta: { title: '报警管理' } },
- { path: '/subSystem/waterSupply/monitorAlarm/index', meta: { title: '报警管理' }, query: { rootTypeId: 1 } }
- ]
- assert.equal(resolveWaterHomeRoute(routes, '/monitorAlarm/index').path, '/subSystem/waterSupply/monitorAlarm/index')
- })
- test('returns null when the requested entry is not registered', () => {
- assert.equal(resolveWaterHomeRoute([{ path: '/404', meta: { title: '页面不存在' } }], '/monitorAlarm/index'), null)
- })
|