修复嵌入小程序讲解列表返回导览首页
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-07-19 22:50:28 +08:00
parent 200b54eade
commit e2bf84aec6
2 changed files with 21 additions and 1 deletions

View File

@@ -122,6 +122,25 @@ describe('讲解展厅列表返回', () => {
wrapper.unmount()
})
it('微信嵌入态即使前置页是导览首页也不调用宿主返回', async () => {
hostEnvironmentMocks.embeddedInWechatMiniProgram = true
window.location.hash = '#/pages/explain/list?embedded=wechat-mini-program'
window.history.replaceState({}, '', window.location.href)
vi.stubGlobal('getCurrentPages', vi.fn(() => [
{ route: 'pages/index/index', options: { tab: 'guide' } },
{ route: 'pages/explain/list', options: {} }
]))
const wrapper = mountExplainList()
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'
}))
wrapper.unmount()
})
it('上一页不是首页时使用 reLaunch避免回到不相关页面', async () => {
vi.stubGlobal('getCurrentPages', vi.fn(() => [
{ route: 'pages/search/index', options: {} },