修复展厅列表嵌入返回入口

This commit is contained in:
lyf
2026-07-19 15:46:51 +08:00
parent 215428db90
commit 127461dd60
5 changed files with 109 additions and 6 deletions

View File

@@ -42,6 +42,9 @@ const GuidePageFrameStub = defineComponent({
const ExplainHallSelectStub = defineComponent({
name: 'ExplainHallSelect',
props: {
forceInternalHeader: Boolean
},
emits: ['back'],
template: '<button data-testid="explain-list-back" @click="$emit(\'back\')">返回</button>'
})
@@ -103,6 +106,22 @@ describe('讲解展厅列表返回', () => {
wrapper.unmount()
})
it('独立页在微信嵌入态强制提供 H5 返回,并保留宿主识别参数', async () => {
hostEnvironmentMocks.embeddedInWechatMiniProgram = true
window.location.hash = '#/pages/explain/list?embedded=wechat-mini-program&weapp=1'
window.history.replaceState({}, '', window.location.href)
const wrapper = mountExplainList()
expect(wrapper.getComponent(ExplainHallSelectStub).props('forceInternalHeader')).toBe(true)
await wrapper.get('[data-testid="explain-list-back"]').trigger('click')
expect(uni.navigateBack).not.toHaveBeenCalled()
expect(uni.reLaunch).toHaveBeenCalledWith(expect.objectContaining({
url: '/pages/index/index?tab=guide&embedded=wechat-mini-program&weapp=1'
}))
wrapper.unmount()
})
it('上一页不是首页时使用 reLaunch避免回到不相关页面', async () => {
vi.stubGlobal('getCurrentPages', vi.fn(() => [
{ route: 'pages/search/index', options: {} },