Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: unflake 'Copy Prompt' tests (#35714)

Max Schmitt400f4669579f
diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts
index aa827cda08..4468c4d475 100644
--- a/tests/playwright-test/reporter-html.spec.ts
+++ b/tests/playwright-test/reporter-html.spec.ts
@@ -2890,6 +2890,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
await page.getByRole('link', { name: 'sample' }).click();
await page.getByRole('button', { name: 'Copy prompt' }).click();
+ await page.waitForFunction(() => navigator.clipboard.readText());
const prompt = await page.evaluate(() => navigator.clipboard.readText());
expect(prompt, 'first line').toContain(`Playwright test failed.`);
expect(prompt, 'contains error').toContain('expect(received).toBe(expected)');
@@ -2930,6 +2931,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {
await page.context().grantPermissions(['clipboard-read', 'clipboard-write']);
await page.getByRole('link', { name: 'sample' }).click();
await page.getByRole('button', { name: 'Copy prompt' }).click();
+ await page.waitForFunction(() => navigator.clipboard.readText());
const prompt = await page.evaluate(() => navigator.clipboard.readText());
expect(prompt, 'contains snapshot').toContain('- button "Click me"');
});
diff --git a/tests/playwright-test/ui-mode-trace.spec.ts b/tests/playwright-test/ui-mode-trace.spec.ts
index 6eb41bfd96..3d9d666a35 100644
--- a/tests/playwright-test/ui-mode-trace.spec.ts
+++ b/tests/playwright-test/ui-mode-trace.spec.ts
@@ -570,6 +570,7 @@ test('fails', async ({ page }) => {
await page.context().grantPermissions(['clipboard-read', 'clipboard-write']);
await page.getByText('Errors', { exact: true }).click();
await page.locator('.tab-errors').getByRole('button', { name: 'Copy prompt' }).click();
+ await page.waitForFunction(() => navigator.clipboard.readText());
const prompt = await page.evaluate(() => navigator.clipboard.readText());
expect(prompt, 'contains error').toContain('expect(received).toBe(expected)');
expect(prompt.replaceAll('\r\n', '\n'), 'contains test sources').toContain(`