## Summary - serve the release workflow's already-built `dist` from the production Playwright gate - preserve the existing auto-build behavior for standalone local production tests - keep the pre/post `dist` inventory guard strict and unchanged ## Root cause The release workflow built and fingerprinted `dist`, but Playwright then launched `preview:prod`, which ran a second Vite build. Timestamped build metadata changed hashed chunks and caused the integrity comparison to fail after all 26 production browser tests had passed. ## Verification - production Playwright gate: 26/26 passed - pre/post inventory: 735 files, zero changes - release package validation: 735 files passed - ESLint passed - Prettier passed - release package unit tests: 7/7 passed - workflow YAML parsed successfully - no test files changed Co-authored-by: Jeppe Bundgaard <jb@truckwash.dk>
88 lines
2.2 KiB
TypeScript
88 lines
2.2 KiB
TypeScript
import fs from "node:fs";
|
|
import { defineConfig, devices } from "@playwright/test";
|
|
|
|
const baseURL = "http://127.0.0.1:4173";
|
|
const isCI = !!process.env.CI;
|
|
const usePrebuiltDist = ["1", "true"].includes(
|
|
String(process.env.PLAYWRIGHT_PROD_PREBUILT || "")
|
|
.trim()
|
|
.toLowerCase()
|
|
);
|
|
|
|
process.env.PLAYWRIGHT_BASE_URL = baseURL;
|
|
|
|
const osReleaseValue = (key: string) => {
|
|
try {
|
|
const body = fs.readFileSync("/etc/os-release", "utf8");
|
|
const match = body.match(new RegExp(`^${key}=(.*)$`, "m"));
|
|
return String(match?.[1] || "").replace(/^"|"$/g, "");
|
|
} catch {
|
|
return "";
|
|
}
|
|
};
|
|
|
|
const isUnsupportedWebKitHost = () => {
|
|
if (process.platform !== "linux") {
|
|
return false;
|
|
}
|
|
const id = osReleaseValue("ID").toLowerCase();
|
|
const version = Number.parseFloat(osReleaseValue("VERSION_ID"));
|
|
return id === "ubuntu" && Number.isFinite(version) && version >= 26.04;
|
|
};
|
|
|
|
const webKitOverride = String(process.env.PLAYWRIGHT_PROD_WEBKIT || "")
|
|
.trim()
|
|
.toLowerCase();
|
|
const includeWebKit =
|
|
webKitOverride === "1" || (webKitOverride !== "0" && webKitOverride !== "false" && !isUnsupportedWebKitHost());
|
|
|
|
const projects = [
|
|
{
|
|
name: "chromium-desktop",
|
|
use: {
|
|
...devices["Desktop Chrome"],
|
|
},
|
|
},
|
|
{
|
|
name: "chromium-mobile",
|
|
use: {
|
|
...devices["Pixel 5"],
|
|
},
|
|
},
|
|
];
|
|
|
|
if (includeWebKit) {
|
|
projects.push({
|
|
name: "webkit-desktop",
|
|
use: {
|
|
...devices["Desktop Safari"],
|
|
},
|
|
});
|
|
}
|
|
|
|
export default defineConfig({
|
|
testDir: "./tests/e2e/release",
|
|
testMatch: /.*\.local-prod\.spec\.ts/,
|
|
timeout: 60_000,
|
|
fullyParallel: true,
|
|
forbidOnly: isCI,
|
|
retries: isCI ? 2 : 0,
|
|
workers: isCI ? 2 : 3,
|
|
reporter: [["list"], ["html", { open: "never", outputFolder: "output/playwright/prod/report" }]],
|
|
outputDir: "output/playwright/prod/test-results",
|
|
use: {
|
|
baseURL,
|
|
serviceWorkers: "block",
|
|
trace: "retain-on-failure",
|
|
screenshot: "only-on-failure",
|
|
video: "retain-on-failure",
|
|
},
|
|
webServer: {
|
|
command: usePrebuiltDist ? "npm run preview -- --host 127.0.0.1 --port 4173" : "npm run preview:prod",
|
|
url: baseURL,
|
|
timeout: 240_000,
|
|
reuseExistingServer: !isCI,
|
|
},
|
|
projects,
|
|
});
|