Repository navigation
fix(e2e): capture HUD instead of canvas mask in running-hud-overlay-legacy-current VRT (#1980) - #1988
Conversation
…egacy-current VRT (#1980) PR #1925's .battle-stage__viewport made canvas and .battle-ui-layer share nearly the same bounding box, so the pre-existing Playwright `mask: [page.locator('canvas')]` in expectDomOverlayScreenshot() painted an opaque rectangle over the whole capture root (HUD included), leaving vrt-running-hud-overlay.png ~99.8% a single color and unable to detect any HUD regression. Add a `canvasVisibility` option ('mask' default, unchanged for every other DOM overlay baseline; 'hidden' opt-in) that excludes the canvas via a tests/e2e/visual.freeze.css visibility rule instead of a mask rectangle, following the existing [data-visual-mask='true'] pattern. Only the running-hud-overlay-legacy-current call site opts into 'hidden'. Add a pixel-diversity test (canvas getImageData, no new deps) proving the regenerated baseline is not single-color-dominated, and a negative-control test proving the screenshot assertion actually fails when [data-combat-hud] is hidden. Regenerate vrt-running-hud-overlay.png at 1230x693 with the HUD visible. Update docs/dev/visual-baseline-registry.md's running-hud-overlay-legacy-current row and add a narrative entry documenting the capture-policy change. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URLPreview removed (PR #1988 closed). |
#1980) test-runner検証(iteration 1)により、negative control testが実baseline capture(AC5/AC6)と同じsnapshot名を共有していたため、`pnpm run test:vrt:update:e2e`(--update-snapshots=all)実行時にファイル内実行順で negative controlの「HUD非表示」captureが実baselineを上書き破壊し、 negative controlが常にPASSしてしまう(検出できない)欠陥が判明した。 negative controlをtoHaveScreenshot()のsnapshot読み書きパイプラインから 切り離し、Locator.screenshot()で直接取得したHUD非表示captureと、 ディスク上のcommitted baseline PNGをcanvas getImageData()でpixel-diffする 方式に変更。baselineファイルへ一切書き込まないため、--update-snapshotsの 有無に関わらず安定して動作する。 docs/dev/visual-baseline-registry.mdに根本原因と修正内容を明記した。
iteration 1 fix_delta 対応(head
|
…d container (#1980) Iteration 2 fix_delta: the previous head's baseline PNG was generated locally (non-containerized Playwright/Chromium) which rendered with different anti-aliasing / subpixel behavior than required CI's mcr.microsoft.com/playwright@sha256:9bd26ad900bb5e0f4dee75839e957a89ae89c2b7ab1e76050e559790e946b948 container, causing the e2e job's AC5/AC6 screenshot assertion to fail by 2373 pixels (exceeding maxDiffPixels: 100). This regenerates tests/e2e/__screenshots__/visual-overlay.spec.ts/ vrt-running-hud-overlay.png with `pnpm run test:vrt:update:e2e` executed inside a `docker run` against the exact digest pinned in .github/workflows/ci.yml (lines 570/1128), matching the e2e job's corepack/pnpm install + VITE_E2E_MODE build + LOOP_VRT_LANE playwright invocation. Re-verified with a fresh (non-update) run in the same container: AC1 (canvasVisibility static checks), AC2 (pixel diversity), AC3 (negative control), and AC4 (full visual-overlay.spec.ts suite) all PASS with no drift against the new baseline. Refs #1980
判定REQUEST_CHANGES。現 head Findings[P1] Negative control が本番の screenshot assertion を検証していないIssue #1980 の AC3 は、HUDを非表示・変形した場合に、実際の しかし現在の negative control は、次の独自比較に置換されています。
これは本番ゲートの HUD全体を隠しているため実際にも失敗する可能性は高いですが、現在のテストはその事実を証明していません。 修正案 本来のmatcherへ戻し、baseline更新時だけnegative controlを実行しない構成にしてください。 test('... negative control ...', async ({ page }, testInfo) => {
test.skip(
testInfo.config.updateSnapshots === 'all',
'read-only negative control must not run during baseline regeneration',
)
// HUDを非表示化
await expect(
expectDomOverlayScreenshot(
overlayRoot,
'vrt-running-hud-overlay.png',
'running-hud-overlay-legacy-current',
{
maxDiffPixels: 100,
canvasVisibility: 'hidden',
},
),
).rejects.toThrow()
})これなら通常CIでは実際のmatcherが失敗することを確認し、 [P1] PR #1984 が同じ欠陥を直後に再導入するhelperは 並行中のdraft PR #1984は、同じ
つまり全件が既定のCanvas maskへ戻ります。 さらにPR #1984自身も、Canvas maskがcapture領域のほぼ全域を覆い、pause/result画面の識別力が低いことを既知の制限として認めています。 必要な処置
加えて、helper側に次のfail-closed guardを入れるべきです。
これがない限り、今後も呼び出し側の指定漏れだけで同じ「greenだが何も検証していないVRT」が再発します。 [P2] PR本文のRuntime Verification Evidenceが現headと一致していないPR本文は現在も以下を主張しています。
しかし現headは 変更理由自体はコメントに記録されていますが、PR本文の中心的なAC3証跡が旧実装のままです。 修正必須事項
その他の評価Canvas maskではなくCSS visibilityでCanvas要素だけをpaint対象外にする実装、属性を 現headのGitHub Actionsは成功していますが、greenであることは独自RGBA comparatorとPlaywright本番matcherの同値性を保証しません。 推奨マージ条件は「AC3を実matcherへ戻す」「#1984のmask再導入を解消する」「PR本文を現headへ同期する」の3点です。 GitHub上へのレビュー投稿・変更操作は行っていません。 |
… guard (#1980) OWNER REQUEST_CHANGES review fix (PR #1988 review comment): - Negative control now calls the real production expectDomOverlayScreenshot() / toHaveScreenshot() matcher (pixelmatch/YIQ, 0.2 threshold) instead of a custom one-shot RGBA byte-diff, and skips during --update-snapshots=all baseline regeneration (testInfo.config.updateSnapshots === 'all') so it can never again silently overwrite the committed baseline (iteration-0 root cause). - expectDomOverlayScreenshot() (visual-utils.ts) now throws a fail-closed error when canvasVisibility defaults to 'mask' and the canvas element's bounding box covers >90% of the capture root's area, so a future caller cannot silently reintroduce this Issue's mask-over-HUD defect. Default 'mask' behavior is unchanged for capture roots where this does not apply; the 'hidden' branch (running-hud-overlay-legacy-current) never reaches this check. Verified inside the CI-pinned Playwright container (mcr.microsoft.com/playwright@sha256:9bd26ad900bb5e0f4dee75839e957a89ae89c2b7ab1e76050e559790e946b948): the negative control test PASSES against the real matcher (proving expectDomOverlayScreenshot() actually rejects the hidden-HUD capture) and is confirmed skipped under --update-snapshots=all; the regenerated baseline PNG is byte-identical (canvasVisibility: 'hidden' capture logic for running-hud-overlay-legacy-current unchanged). Co-Authored-By: Claude Sonnet 5 <[email protected]>
Summary
owner レビュー(issuecomment-5172060362、REQUEST_CHANGES / P0 blocker)で判明した
running-hud-overlay-legacy-current(vrt-running-hud-overlay.png)の capture defect を修正する。968af36e)が Canvas と.battle-ui-layerを同一.battle-stage__viewport内へ移した結果、両者がほぼ同一の bounding box を持つようになり、expectDomOverlayScreenshot()が適用していた Playwrightmask: [page.locator('canvas')]が capture root 全面(HUD を含む)を単色マスクで覆ってしまっていた(旧 baseline は単一色ピクセル比率 99.8% 以上)。tests/e2e/visual-utils.tsのexpectDomOverlayScreenshot()にcanvasVisibilityオプション(既定'mask'= 従来挙動、'hidden'= 新方式)を追加した。'hidden'はdata-visual-canvas-hidden="true"を<html>に一時的に設定し、tests/e2e/visual.freeze.cssの[data-visual-canvas-hidden='true'] canvas { visibility: hidden !important; }(既存の[data-visual-mask='true']opt-in パターンを踏襲)で canvas を除外する。他の DOM overlay baseline(running-hud等)の呼び出し箇所は既定値のまま変更していない。tests/e2e/visual-overlay.spec.tsのrunning-hud-overlay-legacy-currentシナリオのみcanvasVisibility: 'hidden'を指定するよう変更した。getImageDataで検証する pixel diversity test、および[data-combat-hud]を意図的に非表示化すると本番の screenshot assertion が確実に fail することを確認する negative control test を追加した(新規 npm 依存なし)。tests/e2e/__screenshots__/visual-overlay.spec.ts/vrt-running-hud-overlay.pngを 1230x693・canvas 非表示(CSS visibility、mask ではない)で、CI pinned Playwright container(mcr.microsoft.com/playwright@sha256:9bd26ad900bb5e0f4dee75839e957a89ae89c2b7ab1e76050e559790e946b948)内で再生成した。expected/actual を目視確認し、HUD(Hull/Kills/Elapsed/Weapon/Assist/Pause)が実際に描画されていることを確認済み。docs/dev/visual-baseline-registry.mdのrunning-hud-overlay-legacy-current行と、本更新を記録する明示的な narrative section を追加した。iteration-1(OWNER PR REQUEST_CHANGES 対応、head
9864dcd1)OWNER が本 PR へ直接投稿した review comment(issuecomment-5178434876)で 2 件の P1 blocker が指摘され、以下を修正した。
Locator.screenshot()一回撮り + canvasgetImageDataによる独自 RGBA 完全一致 diff(diffPixelCount > 100)に置換されていた。これは本番ゲートexpect(locator).toHaveScreenshot()(Playwright の retry-until-stable 比較 + pixelmatch YIQ 色差 + 既定 threshold0.2)と同値ではなく、独自比較での差分が本番 matcher の reject を論理的に含意しない。修正: negative control を本来のexpectDomOverlayScreenshot()呼び出し(同じ registryId・canvasVisibility: 'hidden'・同じ snapshot 名)に戻し、.rejects.toThrow()で本番 matcher の reject を直接確認する形へ復元した。ただし同じ snapshot 名を使うため、testInfo.config.updateSnapshots === 'all'(baseline 再生成モード)のときはtest.skip()で実行をスキップする(iteration-0 の root cause — 同名 negative control が--update-snapshots=all実行時に baseline を破壊的に上書きした事故の再発防止)。canvasVisibility既定'mask'の fail-open 問題:expectDomOverlayScreenshot()に、canvasVisibilityが既定'mask'のまま呼ばれ、かつ canvas のバウンディングボックスが capture root 面積の 90% を超えて覆う場合に throw する fail-closed guard を追加した(tests/e2e/visual-utils.ts)。既定挙動('mask')自体はこの条件に該当しない呼び出し箇所では変更していない。この guard はcanvasVisibility: 'hidden'を既に指定しているrunning-hud-overlay-legacy-currentの呼び出し箇所には到達しない('hidden'分岐は'mask'分岐より先に判定されない独立した早期リターンのため)。Checks
pnpm typecheck— passpnpm lint— passpnpm test— 1835 passed(107 files)pnpm build— passuv run pytest .claude/skills/gemini-cli-headless-delegation/tests/test_model_routing.py— 21 passedrg -n "canvasVisibility: 'hidden'" tests/e2e/visual-overlay.spec.ts/rg -n "canvasVisibility" tests/e2e/visual-utils.ts— 両方ヒット(AC1)pnpm run test:vrt:update:e2e(CI pinned container内、LOOP_VRT_LANE=true)— 3 passed / 4 skipped(negative control はupdateSnapshots === 'all'のため意図通り skip、baseline PNG は再生成後も既存コミットとバイト同一)pnpm exec playwright test tests/e2e/visual-overlay.spec.ts -g "pixel diversity"(container 内)— 1 passed(AC2)pnpm exec playwright test tests/e2e/visual-overlay.spec.ts -g "negative control"(container 内、通常実行)— 1 passed(AC3。本番expectDomOverlayScreenshot()の Promise が意図通り reject/throw することを確認)pnpm run test:vrt:e2e(container 内)— 4 passed, 3 skipped(既存のtest.skip()pending-baseline scenarios、AC4)git diff --name-only origin/main...HEAD— Allowed Paths 内の 5 ファイルのみ(AC5、下記参照)rg -n "canvasVisibility" docs/dev/visual-baseline-registry.md— ヒット(AC6)uv run python3 scripts/check-vrt-snapshot-policy.py— passuv run python3 scripts/check-visual-artifact-pipeline.py— pass動作検証証跡(Runtime Verification Evidence)
Issue #1980 本文の「Runtime Verification Applicability」節では、動作検証の適用判定を
immediateとしており、対象となる受け入れ条件は AC2・AC3・AC4 の 3 件である。mcr.microsoft.com/playwright@sha256:9bd26ad900bb5e0f4dee75839e957a89ae89c2b7ab1e76050e559790e946b948(.github/workflows/ci.ymlのe2ejob と同一 digest、PLAYWRIGHT_VERSION: "1.60.0")。corepack enable pnpm && corepack prepare [email protected] --activate→pnpm install --frozen-lockfile→VITE_E2E_MODE=true pnpm build→LOOP_VRT_LANE=true pnpm exec playwright test tests/e2e/visual-overlay.spec.ts。playwright.config.ts既定 viewport 1280x720。ローカル非コンテナ Chromium は baseline 再生成に使用していない(過去 iteration でローカル環境と CI 環境のレンダリング差異が発生したため)。9864dcd1308fd99e8112994c095454a66794cbcfpnpm exec playwright test tests/e2e/visual-overlay.spec.ts -g "pixel diversity"→ exit 0、1 passed。dominant color ratio を canvasgetImageDataで算出し0.9未満であることを確認(旧 defect は約 0.998)。pnpm exec playwright test tests/e2e/visual-overlay.spec.ts -g "negative control"→ exit 0、1 passed。[data-combat-hud]をvisibility: hidden !importantで強制非表示化した状態で、本番のexpectDomOverlayScreenshot(overlayRoot, 'vrt-running-hud-overlay.png', 'running-hud-overlay-legacy-current', { maxDiffPixels: 100, canvasVisibility: 'hidden' })を呼び出し、その Promise が.rejects.toThrow()で reject することを確認(独自 RGBA diff ではなく本番 pixelmatch/YIQ matcher 経由)。同一テストを--update-snapshots=all付きで実行するとtest.skip()により skip されることも確認済み(baseline 破壊防止)。pnpm run test:vrt:e2e→ exit 0、4 passed / 3 skipped(running-hud-paused/result-timeout/final-no-command-railは既存の registrypending-baselineに対応した既存の明示的test.skip())。git diffに現れない)。Schema Change Applicability
not_schema_changeexpectDomOverlayScreenshot()のオプション追加・fail-closed guard 追加)・テスト専用 CSS・baseline PNG・docs のみを変更し、他 Skill / SubAgent が読み取る producer-consumer 境界の machine-readable contract(schema)を変更しない。canvasVisibilityオプションは追加のみで既存呼び出し箇所の既定挙動('mask')を変更しない後方互換な追加。iteration-1 で追加した fail-closed guard も、条件に該当しない既存呼び出し箇所の挙動を変えない。Schema Consumer Inventory
not_schema_change(上記)のため N/ASafety Claim Matrix
N/A(reason: 変更対象は
tests/e2e/**の Playwright テストヘルパー・テスト専用 CSS・baseline PNG・docs/dev/visual-baseline-registry.mdのみであり、transport/permission/sandbox/auth/mcp/.claude/skills//.github/workflows/のいずれの safety-sensitive path にも該当しない)Notes
tests/e2e/visual-overlay.spec.ts/tests/e2e/visual-utils.ts/tests/e2e/visual.freeze.css/tests/e2e/__screenshots__/visual-overlay.spec.ts//docs/dev/visual-baseline-registry.md)内でのみ変更している。[data-combat-hud]に切り替えること、running-hud-paused/result-timeout/final-no-command-rail対応、src/style.cssの変更、新規 npm 依存の追加。[data-battle-ui-root]のrunning-hud-overlay/running-hud-paused/result-timeout3 capture が canvas mask 既定挙動のまま呼ばれている点)が本 Issue と同種の defect を再導入する懸念を指摘している。本 PR(fix(e2e): capture HUD instead of canvas mask in running-hud-overlay-legacy-current VRT (#1980) #1988)はこの懸念を PR feat(ui): result screen と pause overlay を battle-stage 内に統合する #1984 自体を変更することでは対応していない(feat(ui): result screen と pause overlay を battle-stage 内に統合する #1984 は本 Issue の Allowed Paths 外であり、別 Issue の scope)。iteration-1 でtests/e2e/visual-utils.tsに追加した fail-closed geometric guard(canvas が capture root 面積の 90% 超を覆うmask呼び出しを throw する)は、fix(e2e): capture HUD instead of canvas mask in running-hud-overlay-legacy-current VRT (#1980) #1988 マージ後に feat(ui): result screen と pause overlay を battle-stage 内に統合する #1984 が rebase する際、該当 3 capture がこの guard に抵触して落ちる形で問題を可視化する設計だが、feat(ui): result screen と pause overlay を battle-stage 内に統合する #1984 側のcanvasVisibility: 'hidden'指定・baseline 再生成自体は feat(ui): result screen と pause overlay を battle-stage 内に統合する #1984 の実装スコープであり本 PR には含まれない。マージ順序は「fix(e2e): capture HUD instead of canvas mask in running-hud-overlay-legacy-current VRT (#1980) #1988 を先にマージ → feat(ui): result screen と pause overlay を battle-stage 内に統合する #1984 が rebase → feat(ui): result screen と pause overlay を battle-stage 内に統合する #1984 が 3 capture にcanvasVisibility: 'hidden'を指定して baseline 再生成」を想定している。