frontend-quality-gates / merge / browser tests (r1, w2) (pull_request) Successful in 5m38s
frontend-quality-gates / merge / browser tests (r1, w3) (pull_request) Successful in 4m44s
frontend-quality-gates / merge / browser tests (r1, w4) (pull_request) Successful in 4m33s
frontend-quality-gates / merge / browser tests (r1, w6) (pull_request) Successful in 4m38s
frontend-quality-gates / merge / browser tests (r2, w2) (pull_request) Successful in 5m36s
frontend-quality-gates / merge / browser tests (r2, w3) (pull_request) Successful in 4m44s
frontend-quality-gates / merge / browser tests (r2, w4) (pull_request) Successful in 4m33s
frontend-quality-gates / merge / browser tests (r2, w6) (pull_request) Successful in 4m39s
frontend-quality-gates / merge / browser tests (r3, w2) (pull_request) Successful in 5m37s
frontend-quality-gates / merge / browser tests (r3, w3) (pull_request) Successful in 4m47s
frontend-quality-gates / merge / browser tests (r3, w4) (pull_request) Successful in 4m33s
frontend-quality-gates / merge / browser tests (r3, w6) (pull_request) Successful in 4m37s
116 lines
4.4 KiB
TypeScript
116 lines
4.4 KiB
TypeScript
import { fileURLToPath } from "node:url";
|
|
|
|
import { defineConfig, devices } from "@playwright/test";
|
|
|
|
import { LOCAL_BUILD_IDENTITY } from "./scripts/lib/build-environment.ts";
|
|
import { flakyJudgement, flakyJudgementReporter } from "./scripts/lib/playwright-flaky-judgement.ts";
|
|
import {
|
|
reservePort,
|
|
RUN_OUTPUT_ROOT_VARIABLE,
|
|
TEST_PORT_VARIABLES,
|
|
testRunPath,
|
|
testRunRoot,
|
|
} from "./scripts/lib/run-isolation.ts";
|
|
import { storybookStaticServer } from "./scripts/lib/storybook-static.ts";
|
|
import { childProcessTimeout } from "./tests/helpers/child-process-timeout.ts";
|
|
|
|
// 1105/12-04. Under TEST_RUN_ID the results, report and build are the run's
|
|
// own (.tmp/runs/<id>/); the goldens in snapshotDir are shared and only read.
|
|
// The preview listens on a free port (TEST_VISUAL_PORT pins one); it shared
|
|
// 4174 with the capability dev server.
|
|
const dist = testRunPath("dist");
|
|
const port = await reservePort(TEST_PORT_VARIABLES.visual);
|
|
const origin = `http://127.0.0.1:${port}`;
|
|
// The design-system and screen-state galleries are workshop stories
|
|
// (src/presentation/design-system/galleries.stories.tsx); their goldens open
|
|
// the static workshop, which the second server serves
|
|
// (TEST_VISUAL_WORKSHOP_PORT pins its port).
|
|
const workshopPort = await reservePort(TEST_PORT_VARIABLES.visualWorkshop);
|
|
|
|
const benchWorkers = process.env["CI_PLAYWRIGHT_WORKERS"]
|
|
? Number.parseInt(process.env["CI_PLAYWRIGHT_WORKERS"], 10)
|
|
: undefined;
|
|
|
|
export default defineConfig({
|
|
testDir: "./tests/visual",
|
|
...(benchWorkers ? { workers: benchWorkers } : {}),
|
|
forbidOnly: true,
|
|
...flakyJudgement(),
|
|
snapshotDir: "./tests/visual/__snapshots__",
|
|
outputDir: testRunPath("artifacts/tests/visual/results"),
|
|
reporter: [
|
|
["list"],
|
|
flakyJudgementReporter,
|
|
[
|
|
"html",
|
|
{ outputFolder: testRunPath("artifacts/tests/visual/report"), open: "never" },
|
|
],
|
|
[
|
|
"junit",
|
|
{ outputFile: testRunPath("artifacts/tests/visual/results.xml"), includeRetries: true },
|
|
],
|
|
],
|
|
expect: {
|
|
toHaveScreenshot: {
|
|
animations: "disabled",
|
|
caret: "hide",
|
|
// 11-03. An absolute count, not a share of the image: 0.2% allowed
|
|
// 2,592 px on the wide shell and let the 1,146 px UI-04 regression
|
|
// pass. With fonts and raster settings pinned (11-02), a clean build
|
|
// differs by 0 px, so this only covers stray anti-aliasing.
|
|
maxDiffPixels: 50,
|
|
scale: "css",
|
|
},
|
|
},
|
|
use: {
|
|
...devices["Desktop Chrome"],
|
|
baseURL: origin,
|
|
colorScheme: "light",
|
|
locale: "en-US",
|
|
trace: "retain-on-failure",
|
|
launchOptions: {
|
|
// 11-02. Chromium sees only the fonts the goldens were captured with,
|
|
// whatever the host or an outer FONTCONFIG_FILE says. The
|
|
// `visual-fonts` project checks them before any screenshot.
|
|
env: {
|
|
...process.env,
|
|
FONTCONFIG_FILE: fileURLToPath(
|
|
new URL("./tests/visual/fonts.conf", import.meta.url),
|
|
),
|
|
},
|
|
},
|
|
},
|
|
webServer: [
|
|
{
|
|
// The home page and the platform overview print the build and release
|
|
// identity. CI sets VITE_BUILD_ID, VITE_COMMIT_SHA and RELEASE_ID for
|
|
// the whole workflow, so its build drew other text than the goldens and
|
|
// every CI run failed here. The goldens are the template's shape,
|
|
// captured with the local identity.
|
|
// 1103/11-08: CI too, or the build is checked as a release build.
|
|
env: { ...LOCAL_BUILD_IDENTITY, [RUN_OUTPUT_ROOT_VARIABLE]: testRunRoot() },
|
|
// REV-FE-0015. The wait covers the build: longest start 3,887 ms on
|
|
// desktop (2026-11-23, 2 runs), sized like a child process of a test
|
|
// (tests/helpers/child-process-timeout.ts).
|
|
timeout: childProcessTimeout(3_887),
|
|
command:
|
|
`corepack pnpm build && corepack pnpm preview --host 127.0.0.1 --port ${port} --strictPort --outDir ${dist}`,
|
|
url: origin,
|
|
reuseExistingServer: false,
|
|
},
|
|
{
|
|
// REV-FE-0015. Playwright starts this server once the first one is up,
|
|
// so the two builds do not run together. Longest start with the build:
|
|
// 8,888 ms on desktop (2026-11-23, 2 runs), sized as above.
|
|
timeout: childProcessTimeout(8_888),
|
|
command: storybookStaticServer(workshopPort).command,
|
|
url: `http://127.0.0.1:${workshopPort}`,
|
|
reuseExistingServer: false,
|
|
},
|
|
],
|
|
projects: [
|
|
{ name: "visual-fonts", testMatch: /fonts\.setup\.ts$/ },
|
|
{ name: "chromium-visual", dependencies: ["visual-fonts"] },
|
|
],
|
|
});
|