Skip to content

Commit

Permalink
test: add a test for disabled cache with context-wide request interce…
Browse files Browse the repository at this point in the history
…ption (#30072)

References #30000
  • Loading branch information
aslushnikov committed Mar 26, 2024
1 parent 599185d commit 397244c
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion tests/page/page-network-response.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
});
}
}
});

0 comments on commit 397244c

Please sign in to comment.