同步 sgs-frontend-mobile 源码
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-07-27 11:26:01 +08:00
parent 575dca430f
commit 9ea1bfab71
181 changed files with 24395 additions and 5212 deletions

View File

@@ -54,4 +54,29 @@ describe('BackendExplainContentProvider hall stop paging', () => {
await expect(provider.listGuideStopsPageByHall('hall-1', 1, 20)).resolves.toMatchObject({ items: [], total: 0, hasMore: false })
expect(attempts).toBe(2)
})
it('reuses the short-lived persistent catalog cache across provider instances', async () => {
const values = new Map<string, string>()
vi.stubGlobal('window', {
localStorage: {
getItem: (key: string) => values.get(key) || null,
setItem: (key: string, value: string) => values.set(key, value),
removeItem: (key: string) => values.delete(key)
}
})
const requests: string[] = []
installRequest((url) => {
requests.push(url)
if (url.includes('/catalog/halls?')) return { code: 0, data: [{ id: 'hall-1', name: '恐龙厅' }] }
return { code: 0, data: { list: [{ stopId: 'stop-1', name: '对象一' }], total: 1 } }
})
const firstProvider = new BackendExplainContentProvider()
const secondProvider = new BackendExplainContentProvider()
await firstProvider.listGuideStopsPageByHall('hall-1', 1, 20)
await secondProvider.listGuideStopsPageByHall('hall-1', 1, 20)
expect(requests.filter((url) => url.includes('/catalog/halls?'))).toHaveLength(1)
expect(requests.filter((url) => url.includes('/stops/page'))).toHaveLength(1)
})
})