修复:首页点位讲解入口展示逻辑

This commit is contained in:
cxk
2026-07-20 01:50:14 +08:00
parent e2bf84aec6
commit 5331d6e0af
2 changed files with 95 additions and 62 deletions

View File

@@ -528,7 +528,7 @@ describe('首页搜索与地图闭环', () => {
expect(testState.resetToViewBaselineCalls).toHaveLength(1)
})
it('模型点选展厅的相关讲解进入该展厅的讲解对象列表,并在返回时复位原楼层', async () => {
it('模型点选展厅只显示一个讲解入口,并在返回时复位原楼层', async () => {
testState.halls = [{ id: 'hall-l2', poiId: poi.id, name: '二层展厅' }]
const wrapper = await mountIndex()
const map = wrapper.getComponent(GuideMapShellStub)
@@ -541,9 +541,10 @@ describe('首页搜索与地图闭环', () => {
})
await flushPromises()
const relatedActions = wrapper.findAll('.poi-action')
expect(relatedActions).toHaveLength(2)
await relatedActions[1]!.trigger('tap')
const actions = wrapper.findAll('.poi-action')
expect(actions).toHaveLength(1)
expect(wrapper.text()).not.toContain('相关讲解')
await wrapper.find('.poi-action.primary').trigger('tap')
await flushPromises()
expect(vi.mocked(uni.navigateTo).mock.calls[0]?.[0]?.url).toContain('/pages/explain/guide-stop-list?hallId=hall-l2')
@@ -559,7 +560,54 @@ describe('首页搜索与地图闭环', () => {
expect(wrapper.find('.guide-poi-card').exists()).toBe(false)
})
it('模型点选展厅的相关讲解优先进入讲解对象列表并保留一次性返回上下文', async () => {
it('展厅类型空间没有讲解展厅关联时不显示展厅与讲解按钮', async () => {
testState.halls = [{ id: 'hall-biology', poiId: 'another-poi', name: '生物厅' }]
const wrapper = await mountIndex()
const map = wrapper.getComponent(GuideMapShellStub)
map.vm.$emit('poi-click', {
...poi,
id: 'space-l2-temporary',
name: '生物厅临展空间',
kind: 'space',
hallId: 'space-l2-temporary',
primaryCategory: 'exhibition_hall',
primaryCategoryZh: '展厅'
})
await flushPromises()
expect(wrapper.find('.guide-poi-card').exists()).toBe(true)
expect(wrapper.find('.poi-card-actions').exists()).toBe(false)
expect(wrapper.text()).not.toContain('查看展厅')
expect(wrapper.text()).not.toContain('相关讲解')
})
it('展厅编号名称规范化后仍能关联真实讲解展厅', async () => {
testState.halls = [{ id: 'hall-biology', name: '生物厅' }]
const wrapper = await mountIndex()
const map = wrapper.getComponent(GuideMapShellStub)
map.vm.$emit('poi-click', {
...poi,
id: 'hall-space-biology',
name: '展厅_6生物厅',
kind: 'space',
hallId: 'space-biology',
primaryCategory: 'exhibition_hall',
primaryCategoryZh: '展厅'
})
await flushPromises()
const actions = wrapper.findAll('.poi-action')
expect(actions).toHaveLength(1)
await actions[0]!.trigger('tap')
await flushPromises()
expect(vi.mocked(uni.navigateTo).mock.calls[0]?.[0]?.url).toContain(
'/pages/explain/guide-stop-list?hallId=hall-biology'
)
})
it('模型点选展厅的唯一讲解入口进入讲解对象列表并保留一次性返回上下文', async () => {
testState.halls = [{ id: 'hall-l2', poiId: poi.id, name: '二层展厅' }]
const wrapper = await mountIndex()
const map = wrapper.getComponent(GuideMapShellStub)
@@ -571,7 +619,7 @@ describe('首页搜索与地图闭环', () => {
primaryCategoryZh: '展厅'
})
await flushPromises()
await wrapper.findAll('.poi-action')[1]!.trigger('tap')
await wrapper.find('.poi-action.primary').trigger('tap')
await flushPromises()
expect(vi.mocked(uni.navigateTo).mock.calls[0]?.[0]?.url).toContain('/pages/explain/guide-stop-list?hallId=hall-l2')