From d42b58c4fe8b45bee9ecfac0f9a8341ca3c2eace Mon Sep 17 00:00:00 2001 From: Jeppe B <2jepp9350@gmail.com> Date: Wed, 10 Jun 2026 15:27:14 +0200 Subject: [PATCH] test: harden flaky chromium smoke specs --- tests/e2e/edge-gateways.smoke.spec.js | 10 +++++++--- tests/e2e/invoice-distribution.smoke.spec.js | 13 +++++++++---- tests/e2e/invoice-transfer-queue-history.spec.js | 6 ++++-- tests/e2e/superuser-vehicles.smoke.spec.js | 4 ++-- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/tests/e2e/edge-gateways.smoke.spec.js b/tests/e2e/edge-gateways.smoke.spec.js index 0227385b..f504367e 100644 --- a/tests/e2e/edge-gateways.smoke.spec.js +++ b/tests/e2e/edge-gateways.smoke.spec.js @@ -534,6 +534,7 @@ test.describe("Edge gateway management smoke", () => { }); test("@smoke manages discovery, bindings, tasks, logs, statistics, uninstall, and delete", async ({ page }) => { + test.slow(); await page.addInitScript(() => { Object.defineProperty(navigator, "clipboard", { configurable: true, @@ -637,6 +638,7 @@ test.describe("Edge gateway management smoke", () => { }); test("@smoke updates the integrated workspace after binding and scanner assignment changes", async ({ page }) => { + test.slow(); await mockApi(page, { authenticated: true, permissions: ["superuser", "user"], @@ -1223,14 +1225,16 @@ test.describe("Edge gateway management smoke", () => { await expect(page.getByTestId("gateway-terminal-page")).toBeVisible(); await expect(page.getByTestId("gateway-terminal-status")).toContainText(/connecting|open/i); - await expect(page.getByTestId("gateway-terminal-output")).toContainText("Connected to CPH Edge 01", { - timeout: 5_000, - }); + await expect(page.getByTestId("gateway-terminal-output")).toContainText("Connected to CPH Edge 01"); + await expect(page.getByTestId("gateway-terminal-send")).toBeDisabled(); + await expect(page.getByTestId("gateway-terminal-input")).toBeEnabled(); await page.getByTestId("gateway-terminal-input").fill("pwd"); + await expect(page.getByTestId("gateway-terminal-send")).toBeEnabled(); await page.getByTestId("gateway-terminal-send").click(); await expect(page.getByTestId("gateway-terminal-output")).toContainText("/opt/truckwash-edge-agent"); + await expect(page.getByTestId("gateway-terminal-close")).toBeEnabled(); await page.getByTestId("gateway-terminal-close").click(); await expect(page.getByTestId("gateway-terminal-status")).toContainText(/closed|idle/i); }); diff --git a/tests/e2e/invoice-distribution.smoke.spec.js b/tests/e2e/invoice-distribution.smoke.spec.js index d667f172..bd3ce2d7 100644 --- a/tests/e2e/invoice-distribution.smoke.spec.js +++ b/tests/e2e/invoice-distribution.smoke.spec.js @@ -76,16 +76,21 @@ test.describe("Invoice distribution smoke", () => { const openMonthButton = page.getByTestId("distribution-overview-open-month").first(); await expect(openMonthButton).toBeVisible({ timeout: 15_000 }); - const popupPromise = page.waitForEvent("popup", { timeout: 3000 }).catch(() => null); + const distributionMonthUrl = /\/superuser\/invoices\/distribution\/\d+\/\d+/; + const popupPromise = page.waitForEvent("popup", { timeout: 10_000 }).catch(() => null); + const samePageNavigationPromise = page + .waitForURL(distributionMonthUrl, { timeout: 10_000 }) + .then(() => null) + .catch(() => null); await openMonthButton.click(); - const popup = await popupPromise; + const popup = await Promise.race([popupPromise, samePageNavigationPromise]); if (popup) { - await expect(popup).toHaveURL(/\/superuser\/invoices\/distribution\/\d+\/\d+/); + await expect(popup).toHaveURL(distributionMonthUrl); return; } - await expect(page).toHaveURL(/\/superuser\/invoices\/distribution\/\d+\/\d+/); + await expect(page).toHaveURL(distributionMonthUrl); }); test("@smoke monthly tabs keep URL query-state in sync", async ({ page }) => { diff --git a/tests/e2e/invoice-transfer-queue-history.spec.js b/tests/e2e/invoice-transfer-queue-history.spec.js index 4f9330fe..70e39778 100644 --- a/tests/e2e/invoice-transfer-queue-history.spec.js +++ b/tests/e2e/invoice-transfer-queue-history.spec.js @@ -384,8 +384,10 @@ test.describe("Invoice transfer queue history reliability", () => { await expect(page.getByTestId("economic-queue-history-retry-9401")).toHaveCount(0); await expect(page.getByTestId("economic-queue-history-retry-9403")).toBeDisabled(); - await page.getByTestId("economic-queue-history-retry-9402").click(); - await expect.poll(() => retryCalls, { timeout: 8_000 }).toBe(1); + const retryButton = page.getByTestId("economic-queue-history-retry-9402"); + await expect(retryButton).toBeEnabled(); + await retryButton.click(); + await expect.poll(() => retryCalls, { timeout: 15_000 }).toBe(1); await expect(page.getByTestId("economic-queue-history-status-9402")).toContainText("QUEUED"); await expect(page.getByTestId("economic-queue-history-retry-9402")).toHaveCount(0); }); diff --git a/tests/e2e/superuser-vehicles.smoke.spec.js b/tests/e2e/superuser-vehicles.smoke.spec.js index 565638c5..f2ec8a7e 100644 --- a/tests/e2e/superuser-vehicles.smoke.spec.js +++ b/tests/e2e/superuser-vehicles.smoke.spec.js @@ -19,8 +19,8 @@ test.describe("Superuser vehicles smoke", () => { await page.goto("/superuser/vehicles"); await expect(page).toHaveURL(/\/superuser\/vehicles$/); - await expect(page.getByRole("heading", { name: /registrerede køretøjer/i })).toBeVisible(); - await expect(page.locator("body")).toContainText(/registrerede/i); + await expect(page.getByRole("heading", { name: /registrerede køretøjer|registered vehicles/i })).toBeVisible(); + await expect(page.locator("body")).toContainText(/registrerede|registered/i); await expect(page.locator("body")).not.toContainText(/Order ID is required/i); }); });