From 724ad8e7a19704502c8a86cacf05ac257f34f58e Mon Sep 17 00:00:00 2001 From: Jeppe B <2jepp9350@gmail.com> Date: Wed, 10 Jun 2026 02:57:02 +0200 Subject: [PATCH] ci: stabilize Playwright runner installs and smoke tests --- playwright.config.ts | 3 ++ scripts/install-playwright-browsers.mjs | 40 ++++++++++++++-- .../page/wrappers/RestrictedPageWrapper.vue | 46 ++++++++++++------- tests/e2e/invoicing-period.smoke.spec.js | 12 ++--- tests/e2e/superuser-vehicles.smoke.spec.js | 2 +- tests/e2e/support/network.js | 17 ++++++- 6 files changed, 90 insertions(+), 30 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index d2e45b30..5862e191 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -43,6 +43,9 @@ export default defineConfig({ fullyParallel: true, forbidOnly: isCI, retries: isCI ? 2 : 0, + expect: { + timeout: 15_000, + }, workers, ...(process.env.PLAYWRIGHT_BASE_URL ? {} diff --git a/scripts/install-playwright-browsers.mjs b/scripts/install-playwright-browsers.mjs index 9858f774..d2dec551 100644 --- a/scripts/install-playwright-browsers.mjs +++ b/scripts/install-playwright-browsers.mjs @@ -3,6 +3,26 @@ import { spawnSync } from "node:child_process"; const browsers = process.argv.slice(2); const requestedBrowsers = browsers.length > 0 ? browsers : ["chromium"]; +const fallbackHostPlatformByUnsupportedPlatform = (platform) => { + const ubuntuMatch = platform.match(/^ubuntu(\d+\.\d+)-(x64|arm64)$/); + if (ubuntuMatch && Number.parseInt(ubuntuMatch[1], 10) >= 26) { + return `ubuntu24.04-${ubuntuMatch[2]}`; + } + + return null; +}; + +const outputText = (result) => `${result.stdout || ""}\n${result.stderr || ""}`; + +const unsupportedHostPlatform = (result) => { + const output = outputText(result); + return ( + output.match(/Cannot install dependencies for (?\S+) with Playwright/i)?.groups?.platform || + output.match(/Playwright does not support \S+ on (?\S+)/i)?.groups?.platform || + null + ); +}; + const runPlaywrightInstall = (args, env = {}) => spawnSync("npx", ["playwright", "install", ...args], { cwd: process.cwd(), @@ -23,7 +43,7 @@ const writeOutput = (result) => { }; const isUnsupportedWithDepsFailure = (result) => { - const output = `${result.stdout || ""}\n${result.stderr || ""}`; + const output = outputText(result); return ( result.status !== 0 && /Cannot install dependencies for .* with Playwright/i.test(output) && @@ -42,15 +62,29 @@ if (!isUnsupportedWithDepsFailure(withDepsResult)) { process.exit(withDepsResult.status ?? 1); } +const unsupportedPlatform = unsupportedHostPlatform(withDepsResult); +const fallbackHostPlatform = unsupportedPlatform + ? fallbackHostPlatformByUnsupportedPlatform(unsupportedPlatform) + : null; + +if (!fallbackHostPlatform) { + console.error( + `Playwright dependency install is unsupported for ${unsupportedPlatform || "this platform"}, ` + + "and this script does not have a safe browser archive fallback for it." + ); + process.exit(withDepsResult.status ?? 1); +} + console.warn( [ - "Playwright could not install OS dependencies for this runner image.", - "Retrying browser download without --with-deps and skipping host validation.", + `Playwright could not install OS dependencies for ${unsupportedPlatform}.`, + `Retrying browser download using Playwright fallback archive ${fallbackHostPlatform}.`, "The self-hosted runner image must provide the required browser system libraries.", ].join("\n") ); const browserOnlyResult = runPlaywrightInstall(requestedBrowsers, { + PLAYWRIGHT_HOST_PLATFORM_OVERRIDE: fallbackHostPlatform, PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS: "1", }); writeOutput(browserOnlyResult); diff --git a/src/components/page/wrappers/RestrictedPageWrapper.vue b/src/components/page/wrappers/RestrictedPageWrapper.vue index 22d7fd58..fb865db7 100644 --- a/src/components/page/wrappers/RestrictedPageWrapper.vue +++ b/src/components/page/wrappers/RestrictedPageWrapper.vue @@ -1,9 +1,8 @@