tests: unique package names for the public page cache test (the temp-folder cache outlives a run)

This commit is contained in:
CRTkafa 2026-10-13 20:47:22 +08:00
parent be9ff8b788
commit 88a37e4735

View file

@ -94,14 +94,15 @@ describe('public store page read', () => {
expect(await playPublicPage('com.example.first200', { noCache: true })).toMatchObject({ state: 'public', http: 200, versionName: '1.0.0' });
});
test('offline or a server error = unknown; unknown is never cached', async () => {
const off = `com.example.offline${Date.now()}`;
globalThis.fetch = (async () => { throw new Error('getaddrinfo ENOTFOUND play.google.com'); }) as unknown as typeof fetch;
const r = await playPublicPage('com.example.offline', { noCache: true });
const r = await playPublicPage(off, { noCache: true });
expect(r).toMatchObject({ state: 'unknown', http: null });
expect(r.error).toContain('ENOTFOUND');
answer(503);
expect((await playPublicPage('com.example.offline')).state).toBe('unknown');
expect((await playPublicPage(off)).state).toBe('unknown');
answer(404);
expect((await playPublicPage('com.example.offline')).state).toBe('notPublic');
expect((await playPublicPage(off)).state).toBe('notPublic');
});
test('answers are cached for a few minutes', async () => {
const urls = answer(404);