Files
clean-architecture-frontend…/playwright.visual.config.ts
T
DongHyeonka 9bddfa529f fix(ci): 시각 골든 빌드가 CI의 빌드·release 식별값을 물려받지 않는다
문제
홈 화면과 플랫폼 구성 화면은 build id와 release id를 글자로 그린다. CI는
workflow 전체에 VITE_BUILD_ID·VITE_COMMIT_SHA·RELEASE_ID를 준다. 그래서
test:visual(FE-GATE-008)의 build가 골든과 다른 글자를 그려, 셸 넓은 화면·
좁은 서랍·플랫폼 구성 3장이 1,109~1,545 px 달라 항상 실패한다. 깨끗한
clone에 CI env를 준 merge 단계 재실행에서 찾았다(af312de와 같은 원인,
1103/11-07).

고른 방법
- playwright.visual.config.ts webServer env로 로컬 식별값(local-build,
  local, local-release)을 준다. 골든은 템플릿의 모양 계약이고 그 값으로
  찍었다.
- 버린 대안: 식별값 글자를 화면마다 가리기. 가릴 곳이 화면마다 늘고,
  식별값을 그리는 새 화면이 생길 때마다 다시 빠진다.

위험·한계
- 시각 테스트의 build는 CI 식별값을 쓰지 않는다. 식별값 표시 자체는
  e2e(compact smoke, 11-06)가 CI 값으로 본다.

검증
- VITE_BUILD_ID=gitea-1-1·VITE_COMMIT_SHA·RELEASE_ID를 주고 test:visual 6/6,
  env 없이 6/6 통과. 수정 전 CI env에서 3건 실패.

Refs: docs/reviews/2026-11-03-maturity-review/README.md 13절 11-07
2026-11-05 01:26:27 +09:00

69 lines
2.2 KiB
TypeScript

import { fileURLToPath } from "node:url";
import { defineConfig, devices } from "@playwright/test";
export default defineConfig({
testDir: "./tests/visual",
forbidOnly: true,
snapshotDir: "./tests/visual/__snapshots__",
outputDir: "./artifacts/tests/visual/results",
reporter: [
["list"],
[
"html",
{ outputFolder: "./artifacts/tests/visual/report", open: "never" },
],
["junit", { outputFile: "./artifacts/tests/visual/results.xml" }],
],
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: "http://127.0.0.1:4174",
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.
env: {
VITE_BUILD_ID: "local-build",
VITE_COMMIT_SHA: "local",
RELEASE_ID: "local-release",
},
command:
"corepack pnpm build && corepack pnpm preview --host 127.0.0.1 --port 4174",
url: "http://127.0.0.1:4174",
reuseExistingServer: false,
},
projects: [
{ name: "visual-fonts", testMatch: /fonts\.setup\.ts$/ },
{ name: "chromium-visual", dependencies: ["visual-fonts"] },
],
});