This commit is contained in:
52
tests/unit/NavigationScene.spec.ts
Normal file
52
tests/unit/NavigationScene.spec.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { compileNavigationScene } from '@/domain/navigationScene'
|
||||
import type { GuideRouteResult } from '@/domain/museum'
|
||||
|
||||
const route = (floorIds: string[]): GuideRouteResult => ({
|
||||
id: 'route-1',
|
||||
distanceMeters: 42,
|
||||
nodeIds: [],
|
||||
points: [],
|
||||
connectorPoints: [],
|
||||
start: {
|
||||
poiId: 'start', name: '起点', floorId: floorIds[0], floorLabel: floorIds[0], position: [0, 0, 0]
|
||||
},
|
||||
end: {
|
||||
poiId: 'end', name: '终点', floorId: floorIds[floorIds.length - 1] || '', floorLabel: floorIds[floorIds.length - 1] || '', position: [1, 0, 1]
|
||||
},
|
||||
floorSegments: floorIds.map((floorId, index) => ({
|
||||
floorId,
|
||||
floorLabel: floorId,
|
||||
points: [{ nodeId: `${floorId}-${index}`, floorId, position: [index, 0, index] as [number, number, number] }]
|
||||
}))
|
||||
})
|
||||
|
||||
describe('compileNavigationScene', () => {
|
||||
it('keeps a same-floor route in its normal floor scene', () => {
|
||||
expect(compileNavigationScene(route(['L1']))).toMatchObject({
|
||||
kind: 'single-floor',
|
||||
floorIds: ['L1'],
|
||||
transitionCount: 0
|
||||
})
|
||||
})
|
||||
|
||||
it('uses an expanded route scene for a vertical cross-floor route', () => {
|
||||
expect(compileNavigationScene(route(['L1', 'L2']))).toMatchObject({
|
||||
kind: 'multi-floor',
|
||||
floorIds: ['L1', 'L2'],
|
||||
transitionCount: 1
|
||||
})
|
||||
})
|
||||
|
||||
it('uses the declared L1 plus exterior composite only for its exact coverage', () => {
|
||||
const assets = [{
|
||||
role: 'same-ground-composite' as const,
|
||||
modelUrl: '/models/l1-exterior.glb',
|
||||
coverageFloorCodes: ['L1', 'EXTERIOR'],
|
||||
coverageFloorIds: ['L1', 'EXTERIOR']
|
||||
}]
|
||||
|
||||
expect(compileNavigationScene(route(['L1', 'EXTERIOR']), assets).kind).toBe('same-ground-composite')
|
||||
expect(compileNavigationScene(route(['L1', 'L2', 'EXTERIOR']), assets).kind).toBe('multi-floor')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user