Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
test: content-length is recomputed for postBody override (#16169)
Yury Semikhatsky0bab5c60c4e9
diff --git a/tests/page/page-request-continue.spec.ts b/tests/page/page-request-continue.spec.tsindex bc31743d4c..8300959718 100644--- a/tests/page/page-request-continue.spec.ts+++ b/tests/page/page-request-continue.spec.ts@@ -173,6 +173,25 @@ it.describe('post data', () => {expect((await serverRequest.postBody).toString('utf8')).toBe('doggo');});+ it('should compute content-length from post data', async ({ page, server, browserName }) => {+ it.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/16027' });+ it.fixme(browserName === 'firefox');+ await page.goto(server.EMPTY_PAGE);+ const data = 'a'.repeat(7500);+ await page.route('**/*', route => {+ const headers = route.request().headers();+ headers['content-type'] = 'application/json';+ route.continue({ postData: data, headers });+ });+ const [serverRequest] = await Promise.all([+ server.waitForRequest('/sleep.zzz'),+ page.evaluate(() => fetch('/sleep.zzz', { method: 'PATCH', body: 'birdy' }))+ ]);+ expect((await serverRequest.postBody).toString('utf8')).toBe(data);+ expect(serverRequest.headers['content-length']).toBe(String(data.length));+ expect(serverRequest.headers['content-type']).toBe('application/json');+ });+it('should amend method and post data', async ({ page, server }) => {await page.goto(server.EMPTY_PAGE);await page.route('**/*', route => {