Skip to content

closes #345 closes #346: dark mode toggle E2E tests and visual regression tests#409

Merged
Samuel1-ona merged 2 commits into
Samuel1-ona:mainfrom
JoyAdah:fix/issues-345-346
Jun 1, 2026
Merged

closes #345 closes #346: dark mode toggle E2E tests and visual regression tests#409
Samuel1-ona merged 2 commits into
Samuel1-ona:mainfrom
JoyAdah:fix/issues-345-346

Conversation

@JoyAdah
Copy link
Copy Markdown

@JoyAdah JoyAdah commented Jun 1, 2026

closes #345
closes #346

Summary

closes #345 — Playwright E2E tests for dark mode toggle

Adds e2e/dark-mode.spec.ts with 8 tests covering all specified cases:

  • Clicking ThemeToggle switches from light → dark (class="dark" on <html>)
  • Clicking again switches back to light
  • Dark mode preference persisted after page.reload()
  • Light mode preference persisted after page.reload()
  • System dark mode preference respected on first load via page.emulateMedia({ colorScheme: "dark" }) with no stored preference
  • System light mode preference respected on first load
  • Manual dark override persists when OS switches to light
  • ThemeToggle button is visible with correct aria-label

Uses injectMockWallet + seedHuntData so the page renders with a connected wallet. Local helpers isDarkMode() and clickThemeToggle() keep test bodies concise.

closes #346 — Visual regression tests with Playwright screenshots

Adds e2e/visual-regression.spec.ts with 8 tests (light + dark for each page):

Page Light Dark
Game Arcade (/)
Hunt play page (/hunty)
Creator dashboard (/dashboard)
GameCompleteModal

Each test: seeds mock wallet + hunts → sets theme via localStorage + emulateMediawaitForLoadState("networkidle") + 400 ms settle → expect(page).toHaveScreenshot(name, { maxDiffPixelRatio: 0.02, animations: "disabled" }).

maxDiffPixelRatio: 0.02 absorbs sub-pixel anti-aliasing differences between CI (Linux) and local (macOS/Windows). animations: "disabled" prevents flaky diffs from in-progress CSS transitions.

Adds e2e/screenshots/.gitkeep so the baseline directory is tracked. Baseline PNGs are auto-generated on first run with --update-snapshots.

Updates playwright.config.ts to set snapshotDir: "./e2e/screenshots" and a snapshotPathTemplate that namespaces baselines by {projectName}.

Test plan

  • pnpm exec playwright test dark-mode — all 8 dark mode tests pass
  • pnpm exec playwright test visual-regression --update-snapshots — baselines generated in e2e/screenshots/
  • pnpm exec playwright test visual-regression — all 8 screenshot tests pass against fresh baselines
  • Make a trivial CSS colour change, re-run visual tests — at least one test fails with a diff
  • Revert the CSS change, re-run — all tests pass again

JoyAdah added 2 commits June 1, 2026 14:22
Adds e2e/dark-mode.spec.ts with 8 tests covering all acceptance criteria:

- Clicking ThemeToggle switches from light → dark (class="dark" on <html>)
- Clicking ThemeToggle again switches back to light
- Dark mode preference is persisted after page reload (next-themes localStorage)
- Light mode preference is persisted after page reload
- System dark mode preference respected on first load via
  page.emulateMedia({ colorScheme: 'dark' }) with no stored preference
- System light mode preference respected on first load
- Manual dark override persists when OS switches to light
- ThemeToggle button is visible and has correct aria-label

Uses injectMockWallet + seedHuntData helpers so the page renders with a
connected wallet. isDarkMode() and clickThemeToggle() local helpers
abstract repeated page interaction.

Co-Authored-By: JoyAdah <snipequeen@users.noreply.github.com>
…creenshots

Adds e2e/visual-regression.spec.ts covering the four pages listed in the
issue:

  Game Arcade (light + dark) — /
  Hunt play page (light + dark) — /hunty
  Creator dashboard (light + dark) — /dashboard
  GameCompleteModal (light + dark) — triggered from /hunty

Each test:
  1. Seeds a mock wallet and hunt data via existing helpers.
  2. Sets the theme via localStorage + emulateMedia before navigation.
  3. Calls waitForLoadState("networkidle") + 400 ms settle time.
  4. Calls expect(page).toHaveScreenshot(name, { maxDiffPixelRatio: 0.02,
     animations: "disabled" }) to diff against the stored baseline.

maxDiffPixelRatio: 0.02 absorbs minor sub-pixel anti-aliasing differences
between CI (Linux) and local dev (macOS/Windows) without missing real
regressions. animations: "disabled" prevents flaky diffs from in-progress
CSS transitions.

Adds e2e/screenshots/.gitkeep so the baseline directory is tracked by git.
Baseline PNG files are auto-generated on first run and committed; subsequent
CI runs diff against them.

Updates playwright.config.ts to set snapshotDir: "./e2e/screenshots" and
a snapshotPathTemplate that namespaces baselines by projectName so Chromium
and Firefox baselines stay separate.

Co-Authored-By: JoyAdah <snipequeen@users.noreply.github.com>
@Samuel1-ona Samuel1-ona merged commit 9a52aa3 into Samuel1-ona:main Jun 1, 2026
2 of 3 checks passed
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] Add visual regression tests with Playwright screenshots [TEST] Add Playwright E2E test for dark mode toggle

2 participants