문제: 시각 회귀 허용치가 maxDiffPixelRatio 0.002(이미지의 0.2%)라서 긴 화면일수록 허용 픽셀이 커진다. 넓은 셸 1440×900은 2,592 px를 허용한다. 그래서 UI-04 수정을 되돌린 회귀(선택 상자 값 잘림, 1,145 px)가 통과한다. 골든이 코드와 조금씩 달라져도 실패하지 않아 어느 골든이 낡았는지 알 수 없다. VD-08 8항은 작은 rasterization 차이만 허용한다고 적는다. 고른 방법: maxDiffPixels 50. 11-02로 글꼴과 래스터 설정을 고정한 뒤 같은 호스트에서 깨끗한 빌드를 다시 찍으면 0 px 차이다(아래 검증). 50은 흩어진 anti-aliasing만 덮고, 지금까지 잰 가장 작은 실제 변화(낡은 compact 골든 175 px)보다 작다. tests/unit/visual-regression-tolerance.test.ts가 비율 허용치가 다시 들어오거나 절대값이 175 이상이 되면 실패한다. 버린 대안: - 0 px: 이 호스트에서는 흔들리지 않았지만 다른 Linux 러너의 래스터는 재 보지 못했다(U-1). 50은 실제 회귀를 놓치지 않는 범위의 여유다. - 위험 영역만 따로 찍어 비율의 분모를 줄이기: 골든이 늘어난다. - 현상 유지: 회귀를 놓친다. 위험·한계: - 커밋된 골든 2장이 새 허용치에서 실패한다. 깨끗한 빌드 기준으로 넓은 셸 614 px, compact 6,955 px 다르다. compact는 이 변경 전 0.2%에서도 이미 실패한다(08-01의 서랍 변경). 골든은 다시 찍지 않았다. 오케스트레이터가 마지막에 한 번 찍는다. 나머지 3장은 0 px로 통과한다. - 다른 호스트의 래스터 차이는 재 보지 못했다. 수십 px 넘게 나오면 그 측정값으로 허용치를 정한다(리뷰 재검토 조건). 검증 (pnpm을 부르지 않으려고 build-frontend.ts로 빌드하고 webServer만 vite preview로 바꾼 로컬 설정 사본으로 실행, flock, 비교 대상은 깨끗한 빌드로 새로 찍은 scratch 골든. 저장소 골든은 건드리지 않았다): - 깨끗한 빌드 vs scratch 골든, 허용치 0, --repeat-each=3: 16 passed. - RED: UI-04 변이(f1b9d3c의 shell.css 변경을 git apply -R)를 넣은 빌드, 0.2% 비율: 6 passed. 허용치 0: 넓은 셸만 "1145 pixels are different". - GREEN: 같은 변이, maxDiffPixels 50: 넓은 셸 실패(1,145 px), 나머지 통과. 변이를 되돌리고 다시 빌드, --repeat-each=2: 11 passed. - 새 단위 테스트는 수정 전 "expected 0.002 to be undefined"로 실패, 수정 뒤 2 passed. supply-chain·deletable-history-documents· test-evidence-source-rules와 함께 37 passed. - tsc(node·test), eslint, check-test-evidence --source-only PASS, verify-documentation-readiness PASS_SCOPED. Refs: docs/reviews/2026-11-01-maturity-review/11-tests-browser-release-scale.md 11-03
59 lines
1.8 KiB
TypeScript
59 lines
1.8 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: {
|
|
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"] },
|
|
],
|
|
});
|