适配H5讲解统一详情接口
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-08-05 14:52:36 +08:00
parent c287ef3a2a
commit 2edb6bd9f2
25 changed files with 946 additions and 1148 deletions

View File

@@ -10,7 +10,10 @@ const installRequest = (handler: (url: string) => unknown) => {
}
describe('BackendExplainContentProvider hall stop paging', () => {
afterEach(() => vi.unstubAllGlobals())
afterEach(() => {
vi.restoreAllMocks()
vi.unstubAllGlobals()
})
it('uses the paged hall endpoint and maps independent pages without outlines', async () => {
const requests: string[] = []
@@ -23,8 +26,8 @@ describe('BackendExplainContentProvider hall stop paging', () => {
data: {
total: 30,
list: pageNo === '1'
? [{ stopId: 'stop-1', name: '对象一', imageStatus: 'READY', coverImageUrl: '/one.jpg', playTargetType: 'STOP', playTargetId: 'target-1' }]
: [{ stopId: 'stop-2', name: '对象二', imageStatus: 'MISSING', playTargetType: 'STOP', playTargetId: 'target-2' }]
? [{ stopId: 'stop-1', name: '对象一', imageStatus: 'READY', coverImageUrl: '/one.jpg', outlineId: 'outline-1', linkedExhibits: [] }]
: [{ stopId: 'stop-2', name: '对象二', imageStatus: 'MISSING', outlineId: 'outline-1', linkedExhibits: [] }]
}
}
})
@@ -35,7 +38,7 @@ describe('BackendExplainContentProvider hall stop paging', () => {
])
expect(first).toMatchObject({ total: 30, pageNo: 1, pageSize: 20, hasMore: true })
expect(first.items[0]).toMatchObject({ id: 'stop-1', hallName: '恐龙厅', playTargetId: 'target-1' })
expect(first.items[0]).toMatchObject({ id: 'stop-1', stopId: 'stop-1', hallName: '恐龙厅', outlineId: 'outline-1' })
expect(second.items.map((item) => item.id)).toEqual(['stop-2'])
expect(requests.filter((url) => url.includes('/stops/page'))).toHaveLength(2)
expect(requests.some((url) => url.includes('/outlines'))).toBe(false)
@@ -79,4 +82,25 @@ describe('BackendExplainContentProvider hall stop paging', () => {
expect(requests.filter((url) => url.includes('/catalog/halls?'))).toHaveLength(1)
expect(requests.filter((url) => url.includes('/stops/page'))).toHaveLength(1)
})
it('warns when a hall has guide stops but every compatibility outline reports zero', async () => {
const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined)
installRequest((url) => {
if (url.includes('/catalog/halls?')) {
return { code: 0, data: [{ id: 'hall-1', name: '恐龙厅', stopCount: 2 }] }
}
if (url.includes('/catalog/halls/hall-1/outlines?')) {
return { code: 0, data: [{ id: 'outline-1', name: '单元一', hallId: 'hall-1', stopCount: 0 }] }
}
throw new Error(`Unexpected request: ${url}`)
})
const units = await new BackendExplainContentProvider().listTemporaryBusinessUnitsByHall('hall-1')
expect(units).toHaveLength(1)
expect(warn).toHaveBeenCalledWith(
'一级单元与讲解点关联异常,一级单元仅作为兼容入口:',
expect.objectContaining({ hallId: 'hall-1', hallStopCount: 2 })
)
})
})