test: strengthen SGS hall POI smoke coverage
This commit is contained in:
@@ -37,6 +37,9 @@ const isEligiblePublicExhibitionSpace = (space) => {
|
||||
const type = normalizedText(space.type).toLowerCase()
|
||||
const name = normalizedText(space.name)
|
||||
|
||||
// Finding 2: Enforce whitelist first, reject unrelated types before keyword heuristics
|
||||
if (!exhibitionSpaceTypeWhitelist.has(type)) return false
|
||||
|
||||
if (type === 'exhibition_hall') return true
|
||||
if (type === 'theater') return hasExhibitionKeyword(name)
|
||||
if (type === 'education_activity') return hasExhibitionKeyword(name)
|
||||
@@ -157,18 +160,25 @@ const spaces = [
|
||||
{ id: 2, name: '巨幕影院', type: 'theater', floorId: 'L1', center: { x: 30, y: 0, z: 40 } },
|
||||
{ id: 3, name: '博物馆之友活动室', type: 'education_activity', floorId: 'L4', center: { x: 50, y: 0, z: 60 } },
|
||||
{ id: 4, name: '展览坡道', type: 'ramp', floorId: 'L1.5', center: { x: 70, y: 0, z: 80 } },
|
||||
{ id: 5, name: '茶水间', type: 'service', floorId: 'L1', center: { x: 90, y: 0, z: 100 } }
|
||||
{ id: 5, name: '茶水间', type: 'service', floorId: 'L1', center: { x: 90, y: 0, z: 100 } },
|
||||
// Finding 3: unmatched exhibition space with center coordinates emits fallback POI
|
||||
{ id: 6, name: '自然科学展厅', type: 'exhibition_hall', floorId: 'L2', center: { x: 110, y: 0, z: 120 } },
|
||||
// Finding 4: space that will match when entrance has no coordinates
|
||||
{ id: 7, name: '地球科学展厅', type: 'exhibition_hall', floorId: 'L3', center: { x: 130, y: 0, z: 140 } }
|
||||
]
|
||||
|
||||
const places = [
|
||||
{ id: 101, name: '展厅1宇宙厅 出入口 1', ownerName: '展厅1宇宙厅', floorId: 'B2', position: { x: 11, y: 0, z: 21 }, nodeId: 'n101' },
|
||||
{ id: 102, name: '巨幕影院 出入口 1', ownerName: '巨幕影院', floorId: 'L1', position: { x: 31, y: 0, z: 41 }, nodeId: 'n102' }
|
||||
{ id: 102, name: '巨幕影院 出入口 1', ownerName: '巨幕影院', floorId: 'L1', position: { x: 31, y: 0, z: 41 }, nodeId: 'n102' },
|
||||
// Finding 4: entrance with missing coordinates falls back to matched space.center
|
||||
{ id: 104, name: '地球科学展厅 出入口', ownerName: '地球科学展厅', floorId: 'L3' }
|
||||
]
|
||||
|
||||
const result = toHallPois(spaces, places, 'B2')
|
||||
const byName = new Map(result.map((poi) => [poi.name, poi]))
|
||||
|
||||
assert.equal(result.length, 4)
|
||||
// Original coverage
|
||||
assert.equal(result.length, 6)
|
||||
assert.deepEqual(byName.get('展厅1宇宙厅').positionGltf, [11, 0, 21])
|
||||
assert.deepEqual(byName.get('巨幕影院').positionGltf, [31, 0, 41])
|
||||
assert.deepEqual(byName.get('博物馆之友活动室').positionGltf, [50, 0, 60])
|
||||
@@ -176,4 +186,21 @@ assert.deepEqual(byName.get('展览坡道').positionGltf, [70, 0, 80])
|
||||
assert.equal(byName.has('茶水间'), false)
|
||||
assert.equal(byName.get('博物馆之友活动室').sourceConfidence, 'backend-sgs-sdk-space-center')
|
||||
|
||||
// Finding 2: whitelist enforcement prevents unrelated types
|
||||
assert.equal(byName.has('茶水间'), false, 'service type rejected by whitelist')
|
||||
|
||||
// Finding 3: unmatched exhibition space with center emits fallback POI
|
||||
assert.equal(byName.has('自然科学展厅'), true, 'unmatched space-center POI emitted')
|
||||
assert.deepEqual(byName.get('自然科学展厅').positionGltf, [110, 0, 120])
|
||||
assert.equal(byName.get('自然科学展厅').sourceConfidence, 'backend-sgs-sdk-space-center')
|
||||
assert.deepEqual(byName.get('自然科学展厅').entrances, [])
|
||||
|
||||
// Finding 4: entrance with missing coordinates falls back to matched space.center
|
||||
assert.equal(byName.has('地球科学展厅'), true, 'entrance fallback to space.center')
|
||||
assert.deepEqual(byName.get('地球科学展厅').positionGltf, [130, 0, 140])
|
||||
assert.equal(byName.get('地球科学展厅').sourceConfidence, 'backend-sgs-sdk-space-center', 'Finding 5: sourceConfidence from space-center not entrance')
|
||||
// Finding 4: entrance still recorded even with undefined positionGltf (no coordinates)
|
||||
assert.equal(byName.get('地球科学展厅').entrances[0].name, '地球科学展厅 出入口')
|
||||
assert.equal(byName.get('地球科学展厅').entrances[0].positionGltf, undefined)
|
||||
|
||||
console.log('SGS hall POI adapter smoke check passed')
|
||||
|
||||
Reference in New Issue
Block a user