Skip to content

test(web): add visual regression tests - #35

Merged
iskhakovt merged 9 commits into
mainfrom
test/visual-regression
Apr 12, 2026
Merged

iskhakovt merged 9 commits into
mainfrom
test/visual-regression

Conversation

@iskhakovt

@iskhakovt iskhakovt commented Apr 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add 27 baseline screenshots across 6 Playwright tests covering every screen and key conditional path
  • Add visual project to playwright.config.ts with deterministic Chromium args (--font-render-hinting=none, --force-color-profile=srgb, --disable-lcd-text, --disable-font-subpixel-positioning, --disable-skia-runtime-opts)
  • Add pnpm test:visual script (separate from pnpm test:e2e)
  • Add visual CI job that uploads diff artifacts on failure
  • Split pnpm test:e2e to --project=e2e only

Screenshots covered

Spec Screenshots Covers
landing 4 Landing page, CreateGroup form (filtered/all/all-options)
admin-flow 15 Setup form/links, invite, intro ±timing, welcome, question ±timing, summary, review, end-of-questions, waiting (admin), results (2p)
partner-flow 5 Waiting (non-admin), pick-anatomy, pick-anatomy expanded, pending, pick-anatomy (partner)
three-person 5 Invite (3 members), waiting (3p partial), results with 3 pair tabs

Chromium args rationale

Arg Purpose
--font-render-hinting=none Eliminates cross-platform font rendering diffs (biggest source of flakiness)
--disable-lcd-text No LCD subpixel anti-aliasing (varies per display)
--disable-font-subpixel-positioning Deterministic glyph placement
--force-color-profile=srgb Consistent color space regardless of monitor ICC profile
--disable-skia-runtime-opts No CPU-specific rendering optimizations

Test plan

  • pnpm -r typecheck passes
  • pnpm test — all 335 unit tests pass
  • pnpm test:e2e — all 37 E2E tests pass (existing tests unaffected by project split)
  • pnpm test:visual — all 6 visual tests pass against generated baselines

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Tests

    • Added comprehensive visual regression testing with desktop and mobile coverage
    • Integrated visual tests into the continuous integration pipeline
  • Documentation

    • Updated README with new testing commands and setup instructions
  • Chores

    • Enhanced test infrastructure and CI configuration to support expanded testing capabilities

27 baseline screenshots across 6 tests covering every screen and key
conditional rendering path:

- Landing page + CreateGroup form (filtered/all modes, all options)
- Admin flow: setup → links → invite → intro → welcome → question →
  summary → review → waiting → results (2-person)
- Intro with/without timing, question with timing sub-question
- Non-admin waiting screen (no "View group members" button)
- Self-pick anatomy: pick screen, expanded options, pending screen
- 3-person: invite list, waiting (partial), results with pair tabs

Chromium args for deterministic rendering: font-render-hinting=none,
disable-lcd-text, disable-font-subpixel-positioning,
force-color-profile=srgb, disable-skia-runtime-opts.

Adds a `visual` project to playwright.config.ts (separate from `e2e`),
`pnpm test:visual` script, and a CI job that uploads diff artifacts
on failure.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 12, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 620e465d-1dec-4ce8-8dce-17e9eb8d8ed8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Implements visual regression testing infrastructure using Playwright with Git LFS storage for PNG baselines. Adds configuration for desktop and mobile test projects, new e2e test specs covering landing/partner/admin flows and three-person groups, CSS for deterministic rendering, workflow CI job, and documentation.

Changes

Cohort / File(s) Summary
Git LFS & Configuration
.gitattributes, playlist.config.ts
Configured Git LFS for storing visual test baselines in e2e/visual/**/*.png and added visual-specific Playwright projects with screenshot expectations (device scaling, reduced motion, animation disabling, diff thresholds).
Visual Test Specs
e2e/visual/landing.spec.ts, e2e/visual/admin-flow.spec.ts, e2e/visual/partner-flow.spec.ts, e2e/visual/three-person.spec.ts
Added four Playwright e2e test files with visual regression assertions covering landing page, group creation, admin and partner flows, multi-person scenarios, and UI state transitions with screenshot captures.
Visual Test Infrastructure
e2e/visual/screenshot.css
Added CSS stylesheet that disables animations/transitions globally and hides overlay noise to ensure deterministic screenshot rendering across test runs.
Test Scripts & Package Configuration
package.json
Updated test:e2e script to run only e2e project and added three new visual testing scripts (test:visual, test:visual:update, test:visual:new) with snapshot management options.
CI/CD Workflow
.github/workflows/ci.yml
Added new visual job that installs Playwright Chromium (with caching), Ubuntu libraries, runs visual tests, uploads test results on failure, and made release job depend on visual test completion.
Documentation
README.md, todo.md
Documented new visual testing commands and Git LFS workflow in README; removed completed visual regression coverage task from todo list.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Snapshots and screens, from left to right,
Pixels preserved in LFS light,
No jitter, no bounce—just truth so clear,
Visual regression? Don't fear, don't fear! 📸✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test(web): add visual regression tests' accurately summarizes the main change—introducing visual regression tests via Playwright across multiple test specs and configurations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/visual-regression

Comment @coderabbitai help to get the list of available commands and usage tips.

@iskhakovt

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Apr 12, 2026

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

iskhakovt and others added 3 commits April 12, 2026 15:49
54 baseline screenshots (27 desktop @ 1280×800 2x, 27 mobile @ 390×664
2x) across 6 tests × 2 viewports covering every screen and key
conditional rendering path:

- Landing page + CreateGroup form (filtered/all modes, all options)
- Admin flow: setup → links → invite → intro → welcome → question →
  summary → review → waiting → results (2-person)
- Intro with/without timing, question with timing sub-question
- Non-admin waiting screen (no "View group members" button)
- Self-pick anatomy: pick screen, expanded options, pending screen
- 3-person: invite list, waiting (partial), results with pair tabs

Deterministic rendering via Chromium args (font-render-hinting=none,
disable-lcd-text, force-color-profile=srgb, etc.) plus a screenshot.css
that suppresses animations and the feTurbulence grain overlay.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Move 54 baseline PNGs to Git LFS to keep the repo lean. Add
.gitattributes rule for e2e/visual/**/*.png, lfs: true on the visual
CI checkout step, and baseline update instructions in README.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- test:visual:new — generate baselines for new tests only (--update-snapshots=missing)
- test:visual:update — regenerate all baselines (--update-snapshots=all)

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Ensures LFS objects are uploaded on every push. Without this, git push
sends only LFS pointers and CI fails with 404s on checkout.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
.github/workflows/ci.yml (1)

145-163: Consider extracting duplicated Playwright setup into a reusable unit.

The Playwright version/cache/install/deps sequence is duplicated between e2e and visual. A composite action or reusable workflow would reduce drift risk over time.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ci.yml around lines 145 - 163, The Playwright setup steps
("Get Playwright version" with id pw-version, "Cache Playwright browsers" with
id playwright-cache, "Install Playwright Chromium", and "Install Chromium OS
deps") are duplicated across the e2e and visual jobs; extract these into a
single reusable unit (either a composite action or a reusable workflow) that
accepts inputs (e.g., cache key prefix, browser choice) and performs the
PW_VERSION detection, cache restore/save, conditional npx playwright install,
and apt deps installation, then replace the duplicated step sequences in both
jobs with a single call to that composite action or workflow (passing required
inputs and preserving existing ids/outputs like version).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@e2e/visual/admin-flow.spec.ts`:
- Around line 119-123: The test currently makes the timing branch optional by
checking nowBtn.isVisible() and skipping the assertion if it isn't present;
change this to assert the timing UI is present and then capture the screenshot
so the test fails if the "Now" step disappears — specifically remove the
conditional around nowBtn and replace it with an explicit visibility/assertion
on page.getByRole("button", { name: "Now" }) (or expect(nowBtn).toBeVisible())
before calling expect(page).toHaveScreenshot("question-timing.png"), ensuring
the timing-enabled path exercised by the test (the nowBtn variable and the
screenshot assertion) is always validated.
- Around line 58-64: The test is asserting "Yes" remains visible after each
click which doesn't confirm the survey advanced; change the synchronization to
wait for the question/card to change between clicks. After clicking a radio via
alice.getByRole("radio", { name: ... }).click(), await a locator that identifies
the current question/card (for example the question heading or the card
container used in the test) to update—either assert the previous question text
is gone (expect(oldQuestionLocator).not.toBeVisible()) or assert the new
question text/identifier appears (expect(newQuestionLocator).toBeVisible() or
toHaveText(...)); update the repeated assertions around the clicks so each click
is followed by a wait for the question/card transition rather than checking the
static "Yes" text.

In `@e2e/visual/partner-flow.spec.ts`:
- Around line 27-28: The test currently uses expect(bob.getByText("View group
members")).not.toBeVisible(), which only checks visibility and can miss elements
that are rendered but hidden; replace that assertion with an absence check by
asserting the locator has zero matches (e.g., use expect(bob.getByText("View
group members")).toHaveCount(0) or expect(bob.locator('text="View group
members"')).toHaveCount(0)) so the test fails if the element is present in the
DOM even if hidden.

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 145-163: The Playwright setup steps ("Get Playwright version" with
id pw-version, "Cache Playwright browsers" with id playwright-cache, "Install
Playwright Chromium", and "Install Chromium OS deps") are duplicated across the
e2e and visual jobs; extract these into a single reusable unit (either a
composite action or a reusable workflow) that accepts inputs (e.g., cache key
prefix, browser choice) and performs the PW_VERSION detection, cache
restore/save, conditional npx playwright install, and apt deps installation,
then replace the duplicated step sequences in both jobs with a single call to
that composite action or workflow (passing required inputs and preserving
existing ids/outputs like version).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1dd04167-71f0-4bb0-bafc-3ac381026670

📥 Commits

Reviewing files that changed from the base of the PR and between 384ea1c and 890ebec.

⛔ Files ignored due to path filters (54)
  • e2e/visual/admin-flow.spec.ts-snapshots/end-all-answered-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/end-all-answered-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/intro-no-timing-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/intro-no-timing-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/intro-with-timing-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/intro-with-timing-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/invite-members-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/invite-members-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/question-timing-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/question-timing-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/question-unanswered-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/question-unanswered-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/results-2p-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/results-2p-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/review-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/review-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/setup-form-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/setup-form-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/setup-links-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/setup-links-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/summary-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/summary-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/waiting-admin-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/waiting-admin-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/welcome-screen-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/admin-flow.spec.ts-snapshots/welcome-screen-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/landing.spec.ts-snapshots/create-group-all-options-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/landing.spec.ts-snapshots/create-group-all-options-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/landing.spec.ts-snapshots/create-group-all-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/landing.spec.ts-snapshots/create-group-all-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/landing.spec.ts-snapshots/create-group-filtered-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/landing.spec.ts-snapshots/create-group-filtered-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/landing.spec.ts-snapshots/landing-home-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/landing.spec.ts-snapshots/landing-home-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/partner-flow.spec.ts-snapshots/pending-waiting-anatomy-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/partner-flow.spec.ts-snapshots/pending-waiting-anatomy-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/partner-flow.spec.ts-snapshots/pick-anatomy-expanded-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/partner-flow.spec.ts-snapshots/pick-anatomy-expanded-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/partner-flow.spec.ts-snapshots/pick-anatomy-partner-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/partner-flow.spec.ts-snapshots/pick-anatomy-partner-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/partner-flow.spec.ts-snapshots/pick-anatomy-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/partner-flow.spec.ts-snapshots/pick-anatomy-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/partner-flow.spec.ts-snapshots/waiting-non-admin-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/partner-flow.spec.ts-snapshots/waiting-non-admin-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/three-person.spec.ts-snapshots/invite-3-members-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/three-person.spec.ts-snapshots/invite-3-members-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/three-person.spec.ts-snapshots/results-3p-first-tab-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/three-person.spec.ts-snapshots/results-3p-first-tab-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/three-person.spec.ts-snapshots/results-3p-second-tab-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/three-person.spec.ts-snapshots/results-3p-second-tab-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/three-person.spec.ts-snapshots/results-3p-third-tab-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/three-person.spec.ts-snapshots/results-3p-third-tab-visual-mobile-linux.png is excluded by !**/*.png
  • e2e/visual/three-person.spec.ts-snapshots/waiting-3p-partial-visual-desktop-linux.png is excluded by !**/*.png
  • e2e/visual/three-person.spec.ts-snapshots/waiting-3p-partial-visual-mobile-linux.png is excluded by !**/*.png
📒 Files selected for processing (11)
  • .gitattributes
  • .github/workflows/ci.yml
  • README.md
  • e2e/visual/admin-flow.spec.ts
  • e2e/visual/landing.spec.ts
  • e2e/visual/partner-flow.spec.ts
  • e2e/visual/screenshot.css
  • e2e/visual/three-person.spec.ts
  • package.json
  • playwright.config.ts
  • todo.md
💤 Files with no reviewable changes (1)
  • todo.md

Comment thread e2e/visual/admin-flow.spec.ts Resolved
Comment thread e2e/visual/admin-flow.spec.ts Resolved
Comment thread e2e/visual/partner-flow.spec.ts Resolved
iskhakovt and others added 4 commits April 12, 2026 16:27
- Remove flaky mixed-rating sequence (no-op waits between questions)
- Assert timing sub-question is visible instead of conditional skip
- Use toHaveCount(0) instead of not.toBeVisible() for absent elements

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Excludes screenshot PNGs from GitHub language stats and diffs.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- Add answerQuestionsCycling helper that rotates through all 5 ratings
- Admin flow uses mixed answers → review shows all rating styles,
  summary shows partial progress, results show match/possible/fantasy
- New results-edge.spec.ts: green-light column with timing enabled,
  empty state ("No overlaps")
- Three-person test uses mixed answers for match type variety across
  all pair tabs

30 unique screenshots × 2 viewports = 60 baselines total.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
- SHA-pin actions/upload-artifact@v4 (supply-chain consistency)
- Move personBase() to e2e/helpers.ts (was duplicated in two specs)
- Add comment explaining why visual-mobile uses Desktop Chrome

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@iskhakovt
iskhakovt enabled auto-merge (squash) April 12, 2026 15:56
@iskhakovt
iskhakovt merged commit c9c627b into main Apr 12, 2026
8 checks passed
@iskhakovt
iskhakovt deleted the test/visual-regression branch April 12, 2026 15:57
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.6.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant