test: fulfilling with gzip should allow to read the body (#30065)

Fixes #29261.
This commit is contained in:
Dmitry Gozman 2024-03-22 13:32:28 -07:00 committed by GitHub
parent 2443d6560f
commit c8e8d8f8bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -438,3 +438,19 @@ it('should fulfill json', async ({ page, server }) => {
expect(response.headers()['content-type']).toBe('application/json');
expect(body).toBe(JSON.stringify({ bar: 'baz' }));
});
it('should fulfill with gzip and readback', {
annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/29261' },
}, async ({ page, server }) => {
server.enableGzip('/one-style.html');
await page.route('**/one-style.html', async route => {
const response = await route.fetch();
expect(response.headers()['content-encoding']).toBe('gzip');
await route.fulfill({ response });
});
const response = await page.goto(server.PREFIX + '/one-style.html');
await expect(page.locator('div')).toHaveText('hello, world!');
await expect(page.locator('body')).toHaveCSS('background-color', 'rgb(255, 192, 203)');
expect(await response.text()).toContain(`<div>hello, world!</div>`);
});