From 9b7e02b88bcd501f0b3774000c8f9bf504b313c9 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Wed, 6 Oct 2021 08:35:54 -0800 Subject: [PATCH] test: add a couple more route+headers tests (#9322) --- tests/page/page-route.spec.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/page/page-route.spec.ts b/tests/page/page-route.spec.ts index ca08fe9f85..24e954e074 100644 --- a/tests/page/page-route.spec.ts +++ b/tests/page/page-route.spec.ts @@ -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(); +});