From ec4c3e36cd5abc32f066a2212e3a33e957d6b2ff Mon Sep 17 00:00:00 2001
From: lyf <2514544224@qq.com>
Date: Tue, 14 Jul 2026 11:17:43 +0800
Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E8=AE=B2=E8=A7=A3=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E7=8A=B6=E6=80=81=E6=A0=87=E7=AD=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/explain/ExplainHallSelect.vue | 7 +-
tests/unit/ExplainHallSelect.spec.ts | 78 ++++++++++++++++++++
2 files changed, 80 insertions(+), 5 deletions(-)
create mode 100644 tests/unit/ExplainHallSelect.spec.ts
diff --git a/src/components/explain/ExplainHallSelect.vue b/src/components/explain/ExplainHallSelect.vue
index b7c22ee..89d393d 100644
--- a/src/components/explain/ExplainHallSelect.vue
+++ b/src/components/explain/ExplainHallSelect.vue
@@ -92,9 +92,6 @@
{{ unit.name }}
-
- 业务单元
-
{{ unit.guideStopCount }} 个讲解点
@@ -128,9 +125,9 @@
{{ stop.description }}
-
+
- {{ stop.audioStatus === 'READY' ? '可讲解' : '图文' }}
+ 图文
diff --git a/tests/unit/ExplainHallSelect.spec.ts b/tests/unit/ExplainHallSelect.spec.ts
new file mode 100644
index 0000000..3f324e8
--- /dev/null
+++ b/tests/unit/ExplainHallSelect.spec.ts
@@ -0,0 +1,78 @@
+// @vitest-environment happy-dom
+
+import { mount } from '@vue/test-utils'
+import { describe, expect, it, vi } from 'vitest'
+import ExplainHallSelect from '@/components/explain/ExplainHallSelect.vue'
+
+vi.mock('@/utils/hostEnvironment', () => ({
+ isEmbeddedInWechatMiniProgram: () => false
+}))
+
+describe('讲解展厅选择列表', () => {
+ it('业务单元卡片不显示业务单元标签,并保留讲解点数量和点击事件', async () => {
+ const wrapper = mount(ExplainHallSelect, {
+ props: {
+ stage: 'unit',
+ businessUnits: [
+ {
+ id: 'unit-evolution',
+ name: '生命演化',
+ hallId: 'hall-evolution',
+ guideStopCount: 6
+ },
+ {
+ id: 'unit-dinosaur',
+ name: '恐龙世界',
+ hallId: 'hall-dinosaur',
+ guideStopCount: 4
+ }
+ ]
+ }
+ })
+
+ const cards = wrapper.findAll('.unit-card')
+ expect(cards).toHaveLength(2)
+ expect(wrapper.text()).toContain('生命演化')
+ expect(wrapper.text()).toContain('恐龙世界')
+ expect(wrapper.text()).toContain('6 个讲解点')
+ expect(wrapper.text()).toContain('4 个讲解点')
+ expect(cards.map((card) => card.text()).join('')).not.toContain('业务单元')
+ expect(cards[0]?.find('.floor-badge').exists()).toBe(false)
+
+ await cards[0]?.trigger('tap')
+ expect(wrapper.emitted('businessUnitClick')).toEqual([['unit-evolution']])
+ })
+
+ it('READY 讲解点不显示可讲解标签,非 READY 讲解点保留图文标签和点击事件', async () => {
+ const readyStop = {
+ id: 'stop-ready',
+ name: '生命起源',
+ hallId: 'hall-evolution',
+ audioStatus: 'READY'
+ }
+ const textStop = {
+ id: 'stop-text',
+ name: '化石记录',
+ hallId: 'hall-evolution',
+ audioStatus: 'MISSING'
+ }
+ const wrapper = mount(ExplainHallSelect, {
+ props: {
+ stage: 'stop',
+ guideStops: [readyStop, textStop]
+ }
+ })
+
+ const cards = wrapper.findAll('.stop-card')
+ expect(cards).toHaveLength(2)
+ expect(wrapper.text()).toContain('生命起源')
+ expect(wrapper.text()).toContain('化石记录')
+ expect(wrapper.text()).not.toContain('可讲解')
+ expect(cards[0]?.find('.hall-meta-row').exists()).toBe(false)
+ expect(cards[1]?.find('.floor-badge').text()).toBe('图文')
+
+ await cards[0]?.trigger('tap')
+ await cards[1]?.trigger('tap')
+ expect(wrapper.emitted('guideStopClick')).toEqual([[readyStop], [textStop]])
+ })
+})