test: add a couple more route+headers tests (#9322)

This commit is contained in:
Pavel Feldman 2021-10-06 08:35:54 -08:00 committed by GitHub
parent ab879fecd6
commit 9b7e02b88b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -673,7 +673,7 @@ it('should support the times parameter with route matching', async ({ page, serv
expect(intercepted).toHaveLength(1);
});
it('should contain raw header', async ({ page, server }) => {
it('should contain raw request header', async ({ page, server }) => {
let headers: any;
await page.route('**/*', async route => {
headers = await route.request().allHeaders();
@ -682,3 +682,31 @@ it('should contain raw header', async ({ page, server }) => {
await page.goto(server.PREFIX + '/empty.html');
expect(headers.accept).toBeTruthy();
});
it('should contain raw response header', async ({ page, server }) => {
let request: any;
await page.route('**/*', async route => {
request = route.request();
route.continue();
});
await page.goto(server.PREFIX + '/empty.html');
const response = await request.response();
const headers = await response.allHeaders();
expect(headers['content-type']).toBeTruthy();
});
it('should contain raw response header after fulfill', async ({ page, server }) => {
let request: any;
await page.route('**/*', async route => {
request = route.request();
await route.fulfill({
status: 200,
body: 'Hello',
contentType: 'text/html',
});
});
await page.goto(server.PREFIX + '/empty.html');
const response = await request.response();
const headers = await response.allHeaders();
expect(headers['content-type']).toBeTruthy();
});