修复馆内预览状态与点位展示
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-07-19 14:05:54 +08:00
parent 58887d928a
commit 215428db90
11 changed files with 280 additions and 35 deletions

View File

@@ -2,7 +2,7 @@
import { defineComponent } from 'vue'
import { mount } from '@vue/test-utils'
import { describe, expect, it } from 'vitest'
import { describe, expect, it, vi } from 'vitest'
import GuideMapShell from '@/components/navigation/GuideMapShell.vue'
const ThreeMapStub = defineComponent({
@@ -26,6 +26,10 @@ const ThreeMapStub = defineComponent({
}
},
emits: ['floor-change', 'target-focus'],
setup(_, { expose }) {
expose({ switchFloor: vi.fn() })
return {}
},
template: '<div data-testid="three-map"></div>'
})
@@ -104,4 +108,27 @@ describe('GuideMapShell 点位过滤契约', () => {
expect(renderer.props('initialFloorId')).toBe('L2')
expect(renderer.props('initialView')).toBe('overview')
})
it('外观状态点击当前业务楼层仍请求渲染器,且等待 floor-change 才提交业务视图', async () => {
const wrapper = mount(GuideMapShell, {
props: {
mapType: 'indoor',
indoorModelSource: modelSource,
floors: [{ id: 'L2', label: '2F' }],
activeFloor: 'L2',
indoorView: 'overview',
indoorInitialView: 'overview'
},
global: { stubs: { ThreeMap: ThreeMapStub } }
})
const renderer = wrapper.getComponent(ThreeMapStub)
await (wrapper.vm as any).switchFloor('L2')
expect((renderer.vm as any).switchFloor).toHaveBeenCalledWith('L2')
expect(wrapper.emitted('indoorViewChange')).toBeUndefined()
renderer.vm.$emit('floor-change', 'L2')
await wrapper.vm.$nextTick()
expect(wrapper.emitted('indoorViewChange')).toEqual([['floor']])
})
})

View File

@@ -334,6 +334,9 @@ describe('首页搜索与地图闭环', () => {
await guideAction.trigger('tap')
await flushPromises()
expect(map.props('indoorView')).toBe('overview')
map.vm.$emit('floor-change', 'L1')
await flushPromises()
expect(map.props('indoorView')).toBe('floor')
expect(wrapper.findAll('.guide-quick-action')[0]?.text()).toBe('导览')

View File

@@ -0,0 +1,35 @@
import { describe, expect, it } from 'vitest'
import type { MuseumPoi } from '@/domain/museum'
import { createVisitorPoiPresentations } from '@/view-models/visitorPoiPresentation'
const poi = (id: string, name: string, floorLabel = '1F', hallName?: string): MuseumPoi => ({
id,
name,
floorId: floorLabel === '1F' ? 'L1' : 'L2',
floorLabel,
hallName,
accessible: false,
primaryCategory: { id: 'facility', label: '服务设施' },
categories: []
})
describe('VisitorPoiPresentation', () => {
it.each([
['展厅 7生态厅', '生态厅'],
['男卫生间00', '男卫生间 00'],
['贵宾卫生间', '贵宾卫生间']
])('规范游客展示名 %s', (rawName, displayName) => {
const result = createVisitorPoiPresentations([poi('p1', rawName)])
expect(result.get('p1')?.displayName).toBe(displayName)
})
it('用真实楼层或展厅区分重复设施', () => {
const result = createVisitorPoiPresentations([
poi('p1', '无障碍卫生间', '1F', '恐龙厅'),
poi('p2', '无障碍卫生间', '2F', '生态厅')
])
expect(result.get('p1')?.displayName).toBe('无障碍卫生间 · 1F · 恐龙厅 · 服务设施')
expect(result.get('p2')?.displayName).toBe('无障碍卫生间 · 2F · 生态厅 · 服务设施')
})
})