优化搜索点位详情页面切换体验
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-07-14 10:00:30 +08:00
parent abaeda189e
commit ef59570b0e
4 changed files with 95 additions and 51 deletions

View File

@@ -143,6 +143,26 @@ afterEach(() => {
})
describe('点位详情实际渲染与返回闭环', () => {
it('解析目标楼层和点位后才挂载地图,避免默认楼层中间帧', async () => {
const wrapper = mountDetail()
expect(wrapper.find('[data-testid="guide-map-shell"]').exists()).toBe(false)
expect(wrapper.get('[data-testid="facility-map-loading"]').text()).toContain('正在准备位置预览')
await loadDetail({
id: encodeURIComponent(facilityPoi.id),
target: encodeURIComponent(facilityPoi.name),
floorId: facilityPoi.floorId,
floorLabel: facilityPoi.floorLabel
})
expect(wrapper.getComponent(GuideMapShellStub).props('activeFloor')).toBe('floor-l2')
expect(wrapper.getComponent(GuideMapShellStub).props('targetFocusRequest')).toMatchObject({
poiId: facilityPoi.id,
floorId: facilityPoi.floorId
})
})
it('只展示真实详情字段,并向地图发送正确楼层与点位定位请求', async () => {
const wrapper = mountDetail()

View File

@@ -202,7 +202,7 @@ describe('首页搜索与地图闭环', () => {
expect(map.props('visiblePoiIds')).toEqual(categoryContext.visiblePoiIds)
})
it('分类结果进入详情并返回后收起搜索、清空 marker但保留目标焦点与楼层', async () => {
it('分类结果进入详情时不触发首页地图,返回后才恢复目标焦点与楼层', async () => {
const wrapper = await mountIndex()
const search = wrapper.getComponent(PoiSearchPanelStub)
const map = wrapper.getComponent(GuideMapShellStub)
@@ -215,13 +215,7 @@ describe('首页搜索与地图闭环', () => {
search.vm.$emit('result-tap', poi, categoryContext)
await flushPromises()
expect(map.props('activeFloor')).toBe('L2')
expect(map.props('targetFocusRequest')).toMatchObject({
poiId: poi.id,
floorId: 'L2',
floorLabel: '2F',
positionGltf: poi.positionGltf
})
expect(map.props('targetFocusRequest')).toBeNull()
const navigateTo = vi.mocked(uni.navigateTo)
const detailUrl = navigateTo.mock.calls[0]?.[0]?.url as string
@@ -298,7 +292,7 @@ describe('首页搜索与地图闭环', () => {
expect(testState.searchCollapseAfterDetailCount).toBe(0)
expect(testState.searchRestoreCount).toBe(1)
expect(map.props('visiblePoiIds')).toEqual(categoryContext.visiblePoiIds)
expect(map.props('targetFocusRequest')).toMatchObject({ poiId: poi.id })
expect(map.props('targetFocusRequest')).toBeNull()
})
it('地图点位卡隐藏首页 dock 时仍保留搜索组件,关闭后可继续使用原列表', async () => {
@@ -342,7 +336,7 @@ describe('首页搜索与地图闭环', () => {
const detailUrl = vi.mocked(uni.navigateTo).mock.calls[0]?.[0]?.url as string
expect(new URLSearchParams(detailUrl.split('?')[1]).get('resultCount')).toBe('1')
expect(map.props('targetFocusRequest')).not.toBeNull()
expect(map.props('targetFocusRequest')).toBeNull()
search.vm.$emit('cancel')
await wrapper.vm.$nextTick()