接入编号讲解后端查询
Some checks failed
CI / verify (push) Has been cancelled

- 使用真实讲解编号解析接口替换本地演示映射
- 成功后复用现有详情页并自动播放讲解
- 增加查询状态、业务错误提示和相关测试

Made-with: Proma
This commit is contained in:
lyf
2026-08-25 18:00:52 +08:00
parent 00585a7b48
commit 130f155bdf
13 changed files with 490 additions and 13 deletions

View File

@@ -67,6 +67,51 @@ describe('讲解展厅选择列表', () => {
expect(wrapper.emitted('hallClick')).toEqual([['hall-evolution']])
})
it('展厅阶段可输入讲解编号并保留前导零', async () => {
const wrapper = mount(ExplainHallSelect, {
props: { stage: 'hall' }
})
expect(wrapper.get('.code-entry-title').text()).toBe('编号讲解')
expect(wrapper.get('.hall-section-title').text()).toBe('按展厅选择')
expect(wrapper.find('.code-entry-arrow').exists()).toBe(false)
await wrapper.get('.code-entry-button').trigger('tap')
expect(wrapper.get('.header-title').text()).toBe('编号讲解')
expect(wrapper.find('.code-entry-close').exists()).toBe(false)
expect(wrapper.get('.code-entry-sheet-title').text()).toBe('输入讲解编号')
expect(wrapper.findAll('.code-digit-cell')).toHaveLength(4)
expect(wrapper.text()).toContain('请输入展品标签上的四位编号')
await wrapper.get('.code-entry-native-input').trigger('input', { detail: { value: '02a' } })
expect(wrapper.get('.code-entry-action.primary').attributes('disabled')).toBeDefined()
await wrapper.get('.code-entry-native-input').trigger('confirm')
expect(wrapper.get('.code-entry-error').text()).toBe('请输入完整的 4 位讲解编号')
await wrapper.get('.code-entry-native-input').trigger('input', { detail: { value: '0231' } })
expect(wrapper.findAll('.code-digit-value').map((item) => item.text())).toEqual(['0', '2', '3', '1'])
await wrapper.get('.code-entry-action.primary').trigger('tap')
expect(wrapper.emitted('codeSubmit')).toEqual([['0231']])
expect(wrapper.find('.code-entry-sheet').exists()).toBe(true)
await wrapper.setProps({ codeSubmitting: true })
expect(wrapper.get('.code-entry-native-input').attributes('disabled')).toBeDefined()
expect(wrapper.get('.code-entry-action.primary').text()).toBe('正在查询')
wrapper.vm.showCodeEntryError('未找到该讲解编号,请确认后重试')
await wrapper.vm.$nextTick()
expect(wrapper.get('.code-entry-error').text()).toBe('未找到该讲解编号,请确认后重试')
await wrapper.get('.header-back').trigger('tap')
expect(wrapper.find('.code-entry-sheet').exists()).toBe(false)
expect(wrapper.get('.header-title').text()).toBe('免费讲解')
expect(wrapper.emitted('back')).toBeUndefined()
await wrapper.get('.header-back').trigger('tap')
expect(wrapper.emitted('back')).toEqual([[]])
})
it('展厅阶段使用完整展厅卡片资源', () => {
const wrapper = mount(ExplainHallSelect, {
props: {
@@ -84,9 +129,9 @@ describe('讲解展厅选择列表', () => {
const card = wrapper.get('.hall-overview-card')
expect(wrapper.get('.header-title').text()).toBe('免费讲解')
expect(card.attributes('style')).toContain('--hall-card-color: #d9b06c')
expect(card.attributes('style')).toContain('--hall-card-color: #bb965a')
expect(card.get('.hall-full-card-image').attributes('src'))
.toBe('/static/icons/halls/custom-cards/dinosaur.png')
.toBe('/static/icons/halls/portal-icons/dinosaur.png')
expect(card.find('.hall-overview-copy').exists()).toBe(false)
expect(card.find('.hall-go-entry').exists()).toBe(false)
})