- 使用真实讲解编号解析接口替换本地演示映射 - 成功后复用现有详情页并自动播放讲解 - 增加查询状态、业务错误提示和相关测试 Made-with: Proma
This commit is contained in:
@@ -33,11 +33,28 @@ const createUseCase = (detail: GuideStopDetail) => {
|
||||
getExhibitById: vi.fn().mockResolvedValue(null),
|
||||
listExplainExhibits: vi.fn().mockResolvedValue([])
|
||||
} as unknown as ExplainRepository
|
||||
const audio = { getStopDetail: vi.fn().mockResolvedValue(detail) } as unknown as AudioPlayInfoRepository
|
||||
const audio = {
|
||||
getStopDetail: vi.fn().mockResolvedValue(detail),
|
||||
getStopInfoByCode: vi.fn().mockResolvedValue({
|
||||
available: true,
|
||||
resolvedStopId: 'resolved-stop-1',
|
||||
playTargetId: 'resolved-stop-1',
|
||||
targetId: 'resolved-stop-1'
|
||||
})
|
||||
} as unknown as AudioPlayInfoRepository
|
||||
return { useCase: new ExplainUseCase(explain, audio), explain, audio }
|
||||
}
|
||||
|
||||
describe('ExplainUseCase unified stop detail', () => {
|
||||
it('resolves the museum code to the backend stop ID', async () => {
|
||||
const { useCase, audio } = createUseCase(createDetail())
|
||||
|
||||
const result = await useCase.resolveExplainCode('1001', 'zh-CN')
|
||||
|
||||
expect(audio.getStopInfoByCode).toHaveBeenCalledWith('1001', 'zh-CN')
|
||||
expect(result).toEqual({ code: '1001', stopId: 'resolved-stop-1' })
|
||||
})
|
||||
|
||||
it('uses stopId once in remote mode without requesting a catalog fallback', async () => {
|
||||
const originalMode = dataSourceConfig.explainContentMode
|
||||
Object.assign(dataSourceConfig, { explainContentMode: 'remote' })
|
||||
|
||||
Reference in New Issue
Block a user