add test for redirects

This commit is contained in:
Simon Knott 2024-09-16 10:27:21 +02:00
parent dde4488ebb
commit 2d0919c0f6
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -833,6 +833,23 @@ it('should include API request', async ({ contextFactory, server }, testInfo) =>
}));
});
it('should include redirects from API request', async ({ contextFactory, server }, testInfo) => {
server.setRedirect('/redirect-me', '/simple.json');
const { page, getLog } = await pageWithHar(contextFactory, testInfo);
await page.request.post(server.PREFIX + '/redirect-me', {
headers: { cookie: 'a=b; c=d' },
data: { foo: 'bar' }
});
const log = await getLog();
expect(log.entries.length).toBe(2);
const [redirect, json] = log.entries;
expect(redirect.request.url).toBe(server.PREFIX + '/redirect-me');
expect(json.request.url).toBe(server.PREFIX + '/simple.json');
expect(redirect.timings).toBeDefined();
expect(json.timings).toBeDefined();
});
it('should not hang on resources served from cache', async ({ contextFactory, server, browserName }, testInfo) => {
it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/11435' });
server.setRoute('/one-style.css', (req, res) => {