Skip to content

Commit

Permalink
test: add test to validate redirecting in request.respond (#4106)
Browse files Browse the repository at this point in the history
  • Loading branch information
aslushnikov committed Mar 5, 2019
1 parent c68df32 commit 9db09fe
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/network.spec.js
Expand Up @@ -106,7 +106,6 @@ module.exports.addTests = function({testRunner, expect, CHROME}) {

// Load and re-load to make sure it's cached.
await page.goto(server.PREFIX + '/cached/one-style.html');
await page.waitFor(1000);
await page.reload();

expect(responses.size).toBe(2);
Expand Down Expand Up @@ -749,6 +748,25 @@ module.exports.addTests = function({testRunner, expect, CHROME}) {
expect(response.headers().foo).toBe('bar');
expect(await page.evaluate(() => document.body.textContent)).toBe('Yo, page!');
});
it('should redirect', async({page, server}) => {
await page.setRequestInterception(true);
page.on('request', request => {
if (!request.url().includes('rrredirect')) {
request.continue();
return;
}
request.respond({
status: 302,
headers: {
location: server.EMPTY_PAGE,
},
});
});
const response = await page.goto(server.PREFIX + '/rrredirect');
expect(response.request().redirectChain().length).toBe(1);
expect(response.request().redirectChain()[0].url()).toBe(server.PREFIX + '/rrredirect');
expect(response.url()).toBe(server.EMPTY_PAGE);
});
it('should allow mocking binary responses', async({page, server}) => {
await page.setRequestInterception(true);
page.on('request', request => {
Expand Down

0 comments on commit 9db09fe

Please sign in to comment.