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

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

@@ -1,14 +1,46 @@
// @vitest-environment happy-dom
import { mount } from '@vue/test-utils'
import { describe, expect, it, vi } from 'vitest'
import { afterEach, describe, expect, it, vi } from 'vitest'
import ExplainHallSelect from '@/components/explain/ExplainHallSelect.vue'
vi.mock('@/utils/hostEnvironment', () => ({
isEmbeddedInWechatMiniProgram: () => false
const hostEnvironmentMocks = vi.hoisted(() => ({
embeddedInWechatMiniProgram: false
}))
vi.mock('@/utils/hostEnvironment', () => ({
isEmbeddedInWechatMiniProgram: () => hostEnvironmentMocks.embeddedInWechatMiniProgram
}))
afterEach(() => {
hostEnvironmentMocks.embeddedInWechatMiniProgram = false
})
describe('讲解展厅选择列表', () => {
it('微信嵌入态独立页面可强制显示 H5 返回入口,且不使用宿主导航布局', async () => {
hostEnvironmentMocks.embeddedInWechatMiniProgram = true
const wrapper = mount(ExplainHallSelect, {
props: {
forceInternalHeader: true
}
})
expect(wrapper.findAll('.explain-page-header')).toHaveLength(1)
expect(wrapper.findAll('.header-back')).toHaveLength(1)
expect(wrapper.classes()).not.toContain('host-navigation')
await wrapper.get('.header-back').trigger('tap')
expect(wrapper.emitted('back')).toEqual([[]])
})
it('微信嵌入态未强制时保留宿主导航布局,保护首页讲解 Tab', () => {
hostEnvironmentMocks.embeddedInWechatMiniProgram = true
const wrapper = mount(ExplainHallSelect)
expect(wrapper.find('.explain-page-header').exists()).toBe(false)
expect(wrapper.classes()).toContain('host-navigation')
})
it('展厅卡片只显示讲解对象数量,不暴露业务单元契约', async () => {
const wrapper = mount(ExplainHallSelect, {
props: {