接入编号讲解后端查询
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

@@ -68,6 +68,58 @@ describe('DefaultAudioPlayInfoRepository unified stop detail', () => {
expect(request).toHaveBeenCalledTimes(2)
})
it('resolves a museum code through info-by-code and preserves the code string', async () => {
const requestUrls: string[] = []
vi.stubGlobal('uni', {
request: ({ url, success }: { url: string, success: (response: unknown) => void }) => {
requestUrls.push(url)
success({
statusCode: 200,
data: {
code: 0,
data: {
available: true,
targetType: 'STOP',
targetId: '865546652298080256',
resolvedStopId: '865546652298080256',
lang: 'zh-CN',
title: '手持折射望远镜',
imageStatus: 'READY',
playTargetType: 'STOP',
playTargetId: '865546652298080256',
hasAudio: true,
supportedLanguages: ['zh-CN', 'yue-HK'],
audioStatus: 'READY'
}
}
})
}
})
const repository = new DefaultAudioPlayInfoRepository()
const result = await repository.getStopInfoByCode('0101', 'zh-CN')
expect(requestUrls).toEqual([
'/app-api/gis/guide/stop/info-by-code?code=0101&lang=zh-CN'
])
expect(result.resolvedStopId).toBe('865546652298080256')
expect(result.title).toBe('手持折射望远镜')
})
it('preserves info-by-code business error codes', async () => {
vi.stubGlobal('uni', {
request: ({ success }: { success: (response: unknown) => void }) => {
success({ statusCode: 200, data: { code: 1020007001, msg: '馆方讲解点编号不存在', data: null } })
}
})
const repository = new DefaultAudioPlayInfoRepository()
await expect(repository.getStopInfoByCode('9999')).rejects.toMatchObject({
message: '馆方讲解点编号不存在',
code: 1020007001
})
})
it('surfaces a business missing-detail response as a detail error', async () => {
vi.stubGlobal('uni', {
request: ({ success }: { success: (response: unknown) => void }) => {