Skip to content

test(sudoku): re-record dark-band baseline + pin macos monetization gate - #973

Merged
wei18 merged 3 commits into
mainfrom
test/dark-band-baseline-and-macos-gate
Jul 29, 2026
Merged

wei18 merged 3 commits into
mainfrom
test/dark-band-baseline-and-macos-gate

Conversation

@wei18

@wei18 wei18 commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Closes #972

Two small, related test-hygiene fixes. Base = main @ a0bb3c2 (includes #971).

Task 1 (#972) — re-record the stale dark-band baseline

postFix_themedBackground_dailyHubDarkMode_bannerOpen_noBand has been red on
main since #943 changed the three difficulty cards' subtitle from a
shimmer/skeleton placeholder to the resolved Best — empty state, and nobody
re-recorded the baseline. Per the issue's own diagnosis (confirmed
independently here): deterministic staleness, not a timing flake — the pixel
diff bbox is (64,304)→(721,662), matching #943's change exactly, nowhere
near the banner slot.

Eyeball verification (the whole point of this test, #851): cropped +
2x-upscaled the banner-boundary region of the re-recorded PNG — solid,
uniform dark background, no lighter band/seam. Row-mean grayscale across the
entire banner region stays flat at ~(17,18,20) with only a ~2-3 unit bump
where the loading-spinner glyph pixels sit — noise, not a seam. #851 has not
regressed.

Diff-confinement verification: programmatic pixel-diff between the old
and new committed baselines confirms the changed region is exactly bbox
(64,304)→(721,662) — the three difficulty-card subtitle rows — nothing
else moved.

Task 2 (no tracking issue — flagged by #971's two code reviewers + its

acceptance agent) — pin the macOS monetization gate with a test

#971 fixed a real Guideline 2.1 exposure (macOS offered "Remove Ads" where no
ads exist) by nil-ing a LOCAL (settingsMonetizationController) inside each
app's Live.swift makeRouteFactory, on macOS only. Nothing pinned that
behaviour, so a future refactor could silently reintroduce it. The subtlety:
bag.monetizationController (the composition-level DI handle) stays non-nil
on macOS — only the value fed into the Settings route is gated — so the
existing liveAdProviderIsLiveOnIOSNoopOnMac-style test doesn't reach it.

Chosen seam: reach through the real .live() composition to
routeFactory.view(for: .settings) and assert on the rendered SettingsView
struct's monetizationController field via String(reflecting:). This
exercises the actual production #if os(iOS) gate in Live.swift — not a
duplicate of it — added to both SudokuAppCompositionTests and
MinesweeperAppCompositionTests (mirror principle). Rejected alternatives:
exposing a standalone "resolved value" accessor would be one more
indirection between the test and the real gate for no benefit; asserting on
the Purchases-affordance's rendered text is l10n-fragile compared to
Mirror-inspecting the stored property directly. swift test always builds
for the macOS host regardless of the package's iOS support (documented
repo gotcha), so the #else branch is what a local run actually pins; the
#if os(iOS) branch mirrors the same defensive shape already used by
liveAdProviderIsLiveOnIOSNoopOnMac.

Negative proof (acceptance evidence) — temporarily reverted the gate in
Sudoku's Live.swift:

$ swift test --filter CompositionTests/liveCompositionGatesSettingsMonetizationControllerByPlatform
Test liveCompositionGatesSettingsMonetizationControllerByPlatform() recorded an issue: Expectation failed:
(dump → "...monetizationController: Optional(MonetizationUI.MonetizationStateController)...").contains("monetizationController: nil")
Test run with 1 test in 1 suite failed after 0.015 seconds with 1 issue.

Restored the gate (git diff against main confirmed byte-identical) and
re-ran:

Test liveCompositionGatesSettingsMonetizationControllerByPlatform() passed after 0.013 seconds.

Verification

  • swift test --package-path Packages/SudokuKit --filter "SettingsView|CompositionTests" — 82/82 passed.
  • swift test --package-path Packages/SudokuKit --filter BannerSlotDarkBandRegressionTests — 1/1 passed.
  • swift test --package-path Packages/SudokuKit --no-parallel (full suite, avoiding the documented
    local parallel-execution segfault flake) — 444/444 passed.
  • swift test --package-path Packages/MinesweeperKit (full suite) — 372/372 passed.
  • mise run lint:swift_strict on both changed test files — 0 issues.
  • git status --porcelain shows exactly one modified snapshot baseline (Task
    1. plus the two test-file diffs (Task 2) — nothing else re-recorded.

Test plan

🤖 Generated with Claude Code

wei18 and others added 3 commits July 30, 2026 01:06
`postFix_themedBackground_dailyHubDarkMode_bannerOpen_noBand` has been red
on main since #943 changed the three difficulty cards' subtitle from a
shimmer/skeleton placeholder to the resolved `Best —` empty state; nobody
re-recorded the baseline. Verified deterministic (not the timing-sensitive
flake a #971 reviewer suspected): the pixel diff bbox (64,304 → 721,662)
matches #943's change exactly and is nowhere near the banner slot.

Eyeballed the re-recorded PNG and the banner-boundary crop: no dark band or
seam, confirming #851 has not regressed — this is a stale-baseline fix, not
a determinism rework.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
#971 fixed a Guideline 2.1 exposure — macOS offered "Remove Ads" where no
ads exist — by nil-ing the LOCAL `settingsMonetizationController` inside
each app's `Live.swift` `makeRouteFactory` on non-iOS platforms. Both code
reviewers and the acceptance agent on that PR flagged that nothing pins the
behaviour: the composition-level `bag.monetizationController` DI handle
stays non-nil on macOS (only the value fed into `LiveRouteFactory`'s
Settings route is gated), so the existing `liveAdProviderIsLiveOnIOSNoopOnMac`
pattern doesn't reach it, and a future refactor could silently reintroduce
the exposure. No tracking issue exists for this — it surfaced purely from
review.

Added `liveCompositionGatesSettingsMonetizationControllerByPlatform` to both
`SudokuAppCompositionTests` and `MinesweeperAppCompositionTests` (mirror
principle), reaching through the real `.live()` composition to
`routeFactory.view(for: .settings)` and asserting on the rendered
`SettingsView`'s `monetizationController` field via `String(reflecting:)` —
this exercises the actual `#if os(iOS)` gate in `Live.swift`, not a copy of
it, so deleting the gate flips the assertion. Verified by temporarily
un-gating Sudoku's `Live.swift` (passing the controller unconditionally):
the new test failed with `monetizationController: Optional(...)`; restored
the gate and the test passes again.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
CR round 1: SudokuAppComposition.live() is synchronous, so the test never
awaited anything — and the Minesweeper mirror test was already sync. Now
symmetric.

Co-Authored-By: Claude <[email protected]>
@wei18
wei18 merged commit 965609b into main Jul 29, 2026
5 checks passed
@wei18
wei18 deleted the test/dark-band-baseline-and-macos-gate branch July 29, 2026 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(sudoku): dark-band regression baseline is stale since #943, red on main

1 participant