Skip to content

test(visual): add Playwright + Chromatic page visual regression suite#18009

Open
pettinarip wants to merge 32 commits intodevfrom
feat/playwright-chromatic-page-visual-tests
Open

test(visual): add Playwright + Chromatic page visual regression suite#18009
pettinarip wants to merge 32 commits intodevfrom
feat/playwright-chromatic-page-visual-tests

Conversation

@pettinarip
Copy link
Copy Markdown
Member

@pettinarip pettinarip commented Apr 21, 2026

Summary

  • Add a Playwright-driven page visual regression suite that renders real Next.js pages (covering each layout under src/layouts/) at three viewports and uploads DOM archives to Chromatic.
  • Wire a dedicated chromatic-pages GitHub Actions workflow that builds the production app with mock data, runs Playwright, and hands off archives to Chromatic — aligned with the official Playwright + Chromatic pattern.
  • Build via pnpm build with USE_MOCK_DATA=true and NEXT_PUBLIC_BUILD_LOCALES=en so tests exercise the same webpack output the site ships, deterministically.
  • Introduce a data-slot="loading" contract on the shared Skeleton and Spinner primitives so tests wait on one signal for all loaders to settle before snapshotting — no per-page hydration selectors.

Test plan

  • CI: chromatic-pages workflow succeeds on this PR and publishes a Chromatic build
  • Chromatic build shows snapshots for each layout under src/layouts/
  • No regressions in the existing chromatic.yml Storybook workflow
  • Re-running the workflow produces stable snapshots (no flakiness from hydration / network)

Integrated review findings:
- Merged Unit 3 (scripts) into Unit 1 — not independently deliverable
- Clarified two-job CI rationale: enables partial archive upload on failure
- Resolved getGFIs() open question — fetch-gfis.json covers it via USE_MOCK_DATA
- Documented reuseExistingServer caveat for local dev determinism
- Clarified catch-all page coverage in Unit 2
Use --frozen-lockfile on both pnpm installs so CI cannot silently
drift from the committed lockfile. Also drop the unneeded
`if: always()` on chromatic-upload; it was only ever reachable via
`needs`, so the default already gates it on the build job producing
artifacts to upload.
networkidle is flaky on Next.js pages due to analytics beacons and
prefetch — the explicit stable-selector + nav-skeleton-detach waits
already gate readiness, so domcontentloaded is enough.

Also default stableSelector to "h1" in the loop destructure and drop
the 15 redundant literals from the page table.
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 21, 2026

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit 15b0dd8
🔍 Latest deploy log https://app.netlify.com/projects/ethereumorg/deploys/69f093a6c23cca000827ba1b
😎 Deploy Preview https://deploy-preview-18009.ethereum.it
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 72 (🟢 up 23 from production)
Accessibility: 93 (no change from production)
Best Practices: 100 (no change from production)
SEO: 98 (🔴 down 1 from production)
PWA: 59 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added dependencies 📦 Changes related to project dependencies documentation 📖 Change or add documentation tooling 🔧 Changes related to tooling of the project labels Apr 21, 2026
@pettinarip pettinarip marked this pull request as draft April 21, 2026 15:16
@pettinarip pettinarip force-pushed the feat/playwright-chromatic-page-visual-tests branch from 67da493 to 586226c Compare April 21, 2026 15:20
The previous merge of origin/dev preferred dev's lockfile, which
dropped @chromatic-com/playwright added by this branch. Regenerated
to restore the missing entry and unblock unit-tests CI.
The webServer block ran pnpm start for every project, breaking
unit tests in CI which don't need (or have) a production build.
Gate it on chromatic project args so unit and e2e runs skip it.
Plans under docs/plans/ are local working artifacts and should not be
committed alongside feature work.
@pettinarip pettinarip force-pushed the feat/playwright-chromatic-page-visual-tests branch from 0feba3f to 1f2458f Compare April 27, 2026 12:46
@github-actions github-actions Bot added the config ⚙️ Changes to configuration files label Apr 27, 2026
@pettinarip pettinarip force-pushed the feat/playwright-chromatic-page-visual-tests branch from ed0cbf5 to 306594f Compare April 27, 2026 13:37
@pettinarip pettinarip marked this pull request as ready for review April 28, 2026 10:55
…tic-page-visual-tests

# Conflicts:
#	pnpm-lock.yaml
Copy link
Copy Markdown
Collaborator

@myelinated-wackerow myelinated-wackerow left a comment

Choose a reason for hiding this comment

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

LGTM on the visual-test infrastructure. A few actionables:

  • PR description says "tests exercise the same webpack output the site ships" — stale after the #17906 merge. The workflow runs pnpm build, which is now Turbopack. Either update the description, or pin the workflow to pnpm build:webpack if webpack-specific output matters for snapshot fidelity.
  • last-24-hrs translation key is orphanedEthPriceCard no longer renders the 24hr % change, so the key is unused in source code but still present in src/intl/{locale}/common.json across all 25 locales. Remove it from the namespace if the deprecation is intentional.
  • EthPriceCard quietly drops the 24hr % change indicator (arrow + percentage + colored gradient). Probably worth a one-line mention in the PR body so it's not invisible to reviewers and stakeholders watching the homepage.
  • Naming nit on maybeShufflesafeShuffle reads better; the "safe" framing makes the intent (deterministic for visual tests) clearer than the conditional-sounding "maybe."
  • Minor: reuseExistingServer: true in playwright.visual.config.ts — fine for CI, but locally a pnpm dev on :3000 will be silently used in place of the production build the tests assume. Worth a one-liner in the skill doc's "Common situations" section.

Skill doc is genuinely useful — covers the non-obvious gotchas (1024 viewport, dual config, data-slot contract, HOME: /root).

Reviewed by Claude (Opus 4.7)

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

Labels

config ⚙️ Changes to configuration files dependencies 📦 Changes related to project dependencies documentation 📖 Change or add documentation tooling 🔧 Changes related to tooling of the project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants