同步小程序讲解页面标题
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-07-28 19:42:33 +08:00
parent b643273470
commit 93bfb7e778
4 changed files with 49 additions and 6 deletions

View File

@@ -11,6 +11,14 @@ const testState = vi.hoisted(() => ({
onShowHandler: null as null | (() => Promise<void> | void)
}))
const hostEnvironmentMocks = vi.hoisted(() => ({
embeddedInWechatMiniProgram: false
}))
const hostNavigationTitleMocks = vi.hoisted(() => ({
syncHostNavigationTitle: vi.fn()
}))
vi.mock('@dcloudio/uni-app', () => ({
onLoad: vi.fn(),
onShow: (handler: () => Promise<void> | void) => {
@@ -19,7 +27,11 @@ vi.mock('@dcloudio/uni-app', () => ({
}))
vi.mock('@/utils/hostEnvironment', () => ({
isEmbeddedInWechatMiniProgram: () => false
isEmbeddedInWechatMiniProgram: () => hostEnvironmentMocks.embeddedInWechatMiniProgram
}))
vi.mock('@/utils/hostNavigationTitle', () => ({
syncHostNavigationTitle: hostNavigationTitleMocks.syncHostNavigationTitle
}))
const modelSource = {
@@ -107,7 +119,9 @@ beforeEach(() => {
testState.threeMapMountCount = 0
testState.threeMapUnmountCount = 0
testState.onShowHandler = null
window.history.replaceState({}, '', '/#/pages/index/index?tab=guide')
hostEnvironmentMocks.embeddedInWechatMiniProgram = false
hostNavigationTitleMocks.syncHostNavigationTitle.mockReset()
window.location.hash = '#/pages/index/index?tab=guide'
vi.stubGlobal('uni', {
navigateTo: vi.fn(),
navigateBack: vi.fn(),
@@ -124,6 +138,16 @@ afterEach(() => {
})
describe('首页启动遮罩与馆内模型生命周期', () => {
it('嵌入小程序打开讲解首页时同步免费讲解标题', async () => {
hostEnvironmentMocks.embeddedInWechatMiniProgram = true
window.location.hash = '#/pages/index/index?tab=explain&embedded=wechat-mini-program'
const wrapper = await mountIndex()
expect(hostNavigationTitleMocks.syncHostNavigationTitle).toHaveBeenCalledWith('免费讲解')
wrapper.unmount()
})
it('12 秒超时后仍保持 indoor且不会挂载 TencentMap', async () => {
const wrapper = await mountIndex()