From 11b49cf7bdd20088edc75b27af213c3c57db2c35 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Fri, 25 Jul 2025 10:54:07 +0100 Subject: [PATCH] Playwright: Some tweaks to improve stability (#108667) playwright stability tweaks --- .../dashboards-edit-panel-title-description.spec.ts | 6 ++++-- .../dashboards-suite/dashboard-timepicker.spec.ts | 3 +++ e2e-playwright/various-suite/frontend-sandbox-app.spec.ts | 8 ++++---- playwright.config.ts | 3 +++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/e2e-playwright/dashboard-new-layouts/dashboards-edit-panel-title-description.spec.ts b/e2e-playwright/dashboard-new-layouts/dashboards-edit-panel-title-description.spec.ts index 30373362528..425f01db823 100644 --- a/e2e-playwright/dashboard-new-layouts/dashboards-edit-panel-title-description.spec.ts +++ b/e2e-playwright/dashboard-new-layouts/dashboards-edit-panel-title-description.spec.ts @@ -51,8 +51,10 @@ test.describe( // Get the tooltip ID from the aria-describedby attribute const tooltipId = await descriptionIcon.getAttribute('aria-describedby'); - const tooltip = page.locator(`[id="${tooltipId}"]`); - await expect(tooltip).toHaveText(`${newDescription}\n`); + await expect(async () => { + const tooltip = page.locator(`[id="${tooltipId}"]`); + await expect(tooltip).toHaveText(`${newDescription}\n`); + }).toPass(); }); } ); diff --git a/e2e-playwright/dashboards-suite/dashboard-timepicker.spec.ts b/e2e-playwright/dashboards-suite/dashboard-timepicker.spec.ts index ac505aa9cd4..e57c56b5afe 100644 --- a/e2e-playwright/dashboards-suite/dashboard-timepicker.spec.ts +++ b/e2e-playwright/dashboards-suite/dashboard-timepicker.spec.ts @@ -42,6 +42,9 @@ test.describe( await page.getByTestId(selectors.components.TimeZonePicker.containerV2).click(); await page.getByRole('option', { name: 'Asia/Tokyo' }).click(); await page.getByTestId(selectors.components.UserProfile.preferencesSaveButton).click(); + // wait for the page to reload before trying to navigate, otherwise this can cause flakes + // see e.g. https://github.com/microsoft/playwright/issues/21451#issuecomment-1502251404 + await page.waitForURL('/profile'); // Open dashboard with time range from 8th to end of 10th. // Will be Tokyo time because of above preference diff --git a/e2e-playwright/various-suite/frontend-sandbox-app.spec.ts b/e2e-playwright/various-suite/frontend-sandbox-app.spec.ts index 6ec59ded434..dfa19753b15 100644 --- a/e2e-playwright/various-suite/frontend-sandbox-app.spec.ts +++ b/e2e-playwright/various-suite/frontend-sandbox-app.spec.ts @@ -31,7 +31,7 @@ test.describe( await expect(sandboxDiv).toBeHidden(); const appPage = page.getByTestId('sandbox-app-test-page-one'); - await expect(appPage).toBeVisible({ timeout: 10000 }); + await expect(appPage).toBeVisible(); }); test('Loads the app configuration without the sandbox div wrapper', async ({ page }) => { @@ -41,7 +41,7 @@ test.describe( await expect(sandboxDiv).toBeHidden(); const configPage = page.getByTestId('sandbox-app-test-config-page'); - await expect(configPage).toBeVisible({ timeout: 10000 }); + await expect(configPage).toBeVisible(); }); }); @@ -59,7 +59,7 @@ test.describe( await expect(sandboxDiv).toBeVisible(); const appPage = page.getByTestId('sandbox-app-test-page-one'); - await expect(appPage).toBeVisible({ timeout: 10000 }); + await expect(appPage).toBeVisible(); }); test('Loads the app configuration with the sandbox div wrapper', async ({ page }) => { @@ -69,7 +69,7 @@ test.describe( await expect(sandboxDiv).toBeVisible(); const configPage = page.getByTestId('sandbox-app-test-config-page'); - await expect(configPage).toBeVisible({ timeout: 10000 }); + await expect(configPage).toBeVisible(); }); }); }); diff --git a/playwright.config.ts b/playwright.config.ts index 94281dbd2d8..b569bc6feea 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -16,6 +16,9 @@ export default defineConfig({ reporter: [ ['html'], // pretty ], + expect: { + timeout: 10_000, + }, use: { baseURL: process.env.GRAFANA_URL ?? DEFAULT_URL, trace: 'retain-on-failure',