From ae1e07de106e6a873cd88d85f3e52237b2be9b48 Mon Sep 17 00:00:00 2001 From: Dmitry Gozman Date: Thu, 23 May 2024 17:40:27 -0700 Subject: [PATCH] test: skip/improve some tests that are flaky (#30993) --- tests/library/fetch-proxy.spec.ts | 2 ++ tests/library/inspector/inspectorTest.ts | 11 +++++------ tests/page/page-network-request.spec.ts | 3 ++- tests/page/page-request-continue.spec.ts | 4 ---- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/library/fetch-proxy.spec.ts b/tests/library/fetch-proxy.spec.ts index 90b50b9f1f..b0c921c8e3 100644 --- a/tests/library/fetch-proxy.spec.ts +++ b/tests/library/fetch-proxy.spec.ts @@ -132,6 +132,8 @@ it(`should support proxy.bypass`, async ({ contextFactory, contextOptions, serve }); it('should use socks proxy', async ({ playwright, server, socksPort }) => { + it.skip(!!process.env.INSIDE_DOCKER, 'connect ECONNREFUSED 127.0.0.1:'); + const request = await playwright.request.newContext({ proxy: { server: `socks5://localhost:${socksPort}`, } }); diff --git a/tests/library/inspector/inspectorTest.ts b/tests/library/inspector/inspectorTest.ts index 7f759f13aa..1d5e30825a 100644 --- a/tests/library/inspector/inspectorTest.ts +++ b/tests/library/inspector/inspectorTest.ts @@ -131,12 +131,11 @@ class Recorder { async waitForOutput(file: string, text: string): Promise> { if (!codegenLang2Id.has(file)) throw new Error(`Unknown language: ${file}`); - const handle = await this.recorderPage.waitForFunction((params: { text: string, languageId: string }) => { - const w = window as any; - const source = (w.playwrightSourcesEchoForTest || []).find((s: Source) => s.id === params.languageId); - return source && source.text.includes(params.text) ? w.playwrightSourcesEchoForTest : null; - }, { text, languageId: codegenLang2Id.get(file) }, { timeout: 0, polling: 300 }); - const sources: Source[] = await handle.jsonValue(); + await expect.poll(() => this.recorderPage.evaluate(languageId => { + const sources = ((window as any).playwrightSourcesEchoForTest || []) as Source[]; + return sources.find(s => s.id === languageId)?.text || ''; + }, codegenLang2Id.get(file)), { timeout: 0 }).toContain(text); + const sources: Source[] = await this.recorderPage.evaluate(() => (window as any).playwrightSourcesEchoForTest || []); for (const source of sources) { if (!codegenLangId2lang.has(source.id)) throw new Error(`Unknown language: ${source.id}`); diff --git a/tests/page/page-network-request.spec.ts b/tests/page/page-network-request.spec.ts index 472bb34560..f84a569c5c 100644 --- a/tests/page/page-network-request.spec.ts +++ b/tests/page/page-network-request.spec.ts @@ -315,8 +315,9 @@ it('should get |undefined| with postDataJSON() when there is no post data', asyn expect(response.request().postDataJSON()).toBe(null); }); -it('should return multipart/form-data', async ({ page, server, browserName }) => { +it('should return multipart/form-data', async ({ page, server, browserName, browserMajorVersion }) => { it.fixme(browserName === 'webkit', 'File content is missing in WebKit'); + it.skip(browserName === 'chromium' && browserMajorVersion < 126, 'Requires a recent enough protocol'); await page.goto(server.EMPTY_PAGE); server.setRoute('/post', (req, res) => res.end()); diff --git a/tests/page/page-request-continue.spec.ts b/tests/page/page-request-continue.spec.ts index 9230bb5fa8..2fbac43081 100644 --- a/tests/page/page-request-continue.spec.ts +++ b/tests/page/page-request-continue.spec.ts @@ -515,8 +515,4 @@ it('continue should not change multipart/form-data body', async ({ page, server, '------'].join('\r\n'); expect.soft((await reqBefore.postBody).toString('utf8')).toContain(fileContent); expect.soft((await reqAfter.postBody).toString('utf8')).toContain(fileContent); - // Firefox sends a bit longer boundary. - const expectedLength = browserName === 'firefox' ? '246' : '208'; - expect.soft(reqBefore.headers['content-length']).toBe(expectedLength); - expect.soft(reqAfter.headers['content-length']).toBe(expectedLength); });