修复讲解列表返回导览首页
This commit is contained in:
@@ -234,6 +234,32 @@ describe('讲解展厅列表返回', () => {
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('根栈页内返回先消费历史标记,再回到导览首页', async () => {
|
||||
let currentHistoryState: Record<string, unknown> = {}
|
||||
vi.spyOn(window.history, 'state', 'get').mockImplementation(() => currentHistoryState)
|
||||
vi.spyOn(window.history, 'pushState').mockImplementation((state) => {
|
||||
currentHistoryState = (state || {}) as Record<string, unknown>
|
||||
})
|
||||
const wrapper = mountExplainList()
|
||||
const historyBack = vi.spyOn(window.history, 'back').mockImplementation(() => {
|
||||
currentHistoryState = {}
|
||||
window.dispatchEvent(new PopStateEvent('popstate', { state: currentHistoryState }))
|
||||
})
|
||||
testState.onLoadHandler?.()
|
||||
|
||||
expect(window.history.state).toMatchObject({ museumGuidePage: 'explain-list' })
|
||||
|
||||
await wrapper.get('[data-testid="explain-list-back"]').trigger('click')
|
||||
await flushPromises()
|
||||
|
||||
expect(historyBack).toHaveBeenCalledTimes(1)
|
||||
expect(uni.reLaunch).toHaveBeenCalledTimes(1)
|
||||
expect(uni.reLaunch).toHaveBeenCalledWith(expect.objectContaining({
|
||||
url: '/pages/index/index?tab=guide'
|
||||
}))
|
||||
wrapper.unmount()
|
||||
})
|
||||
|
||||
it('普通 H5 浏览器返回也会回到导览首页,且不调用 history.back', async () => {
|
||||
const historyBack = vi.spyOn(window.history, 'back')
|
||||
const wrapper = mountExplainList()
|
||||
|
||||
Reference in New Issue
Block a user