test: add a test for disabled cache with context-wide request interception (#30072)

References #30000
This commit is contained in:
Andrey Lushnikov 2024-03-25 22:03:24 -07:00 committed by GitHub
parent 599185dd07
commit 397244c026
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -348,7 +348,7 @@ it('should return body for prefetch script', async ({ page, server, browserName
expect(body.toString()).toBe('// Scripts will be pre-fetched');
});
it('should bypass disk cache when interception is enabled', async ({ page, server, browserName }) => {
it('should bypass disk cache when page interception is enabled', async ({ page, server, browserName }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30000' });
it.fixme(browserName === 'firefox', 'Returns cached response.');
await page.goto(server.PREFIX + '/frames/one-frame.html');
@ -399,3 +399,32 @@ it('should bypass disk cache when interception is enabled', async ({ page, serve
}
}
});
it('should bypass disk cache when context interception is enabled', async ({ page, server, browserName }) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/30000' });
it.fixme(browserName === 'firefox', 'Returns cached response.');
await page.context().route('**/api*', route => route.continue());
await page.goto(server.PREFIX + '/frames/one-frame.html');
{
const requests = [];
server.setRoute('/api', (req, res) => {
requests.push(req);
res.statusCode = 200;
res.setHeader('content-type', 'text/plain');
res.setHeader('cache-control', 'public, max-age=31536000');
res.end('Hello');
});
for (let i = 0; i < 3; i++) {
await it.step(`main frame iteration ${i}`, async () => {
const respPromise = page.waitForResponse('**/api');
await page.evaluate(async () => {
const response = await fetch('/api');
return response.status;
});
const response = await respPromise;
expect(response.status()).toBe(200);
expect(requests.length).toBe(i + 1);
});
}
}
});