Skip to content

Add Storybook & Chromatic visual regression testing#760

Draft
anth-volk wants to merge 6 commits intomainfrom
visual-testing
Draft

Add Storybook & Chromatic visual regression testing#760
anth-volk wants to merge 6 commits intomainfrom
visual-testing

Conversation

@anth-volk
Copy link
Collaborator

@anth-volk anth-volk commented Feb 26, 2026

Fixes #759

Summary

  • Add 79 Storybook stories across 30 components covering pages, pathways, report output, and visualizations
  • Integrate Chromatic for automated visual regression testing with TurboSnap (--only-changed)
  • Add GitHub Actions workflow that runs Chromatic on PRs (requires visual approval) and auto-accepts baselines on push to main
  • Add mock data infrastructure (storybookProviders.tsx) that pre-populates Redux store and React Query cache for stories needing API data

Details

Stories cover:

  • Report output components (MetricCard, ParameterTable, IndividualTable, EntityInstanceDisplay, GroupEntityDisplay, ReportActionButtons, ReportSidebar, ReportOutputLayout, SocietyWideOverview)
  • Report creation flow views (ReportLabelView, ReportSetupView, ReportSubmitView, SimulationLabelView, SimulationSetupView, SimulationPolicySetupView, SimulationPopulationSetupView, PolicyLabelView, PopulationLabelView, PopulationScopeView)
  • Common components (DataTable, EmptyState, FloatingAlert, MultiButtonFooter, PaginationControls, RenameIngredientModal)
  • Layout components (ChartContainer, IngredientReadView, SidebarTabs)
  • Visualizations (HexagonalMap, USDistrictChoroplethMap)

CI workflow (chromatic.yaml):

  • On PR: runs Chromatic with --only-changed, check fails until visual changes are reviewed/accepted in Chromatic UI
  • On push to main: runs with --auto-accept-changes to update the baseline

Mock data provider:

  • storybookProviders.tsx provides withMockedProviders() decorator that seeds Redux with metadata (tax years, regions) and React Query with policy/household/geographic associations
  • Avoids vitest imports so it works in the Storybook browser environment
  • Uses deterministic seeded PRNG for map visualizations to ensure stable snapshots

Test plan

  • bun run storybook:build passes
  • Chromatic baseline established — 79 stories, 0 errors, 0 unstable
  • Verify CHROMATIC_PROJECT_TOKEN secret is set in GitHub Actions
  • Verify Chromatic check runs on a test PR

🤖 Generated with Claude Code

anth-volk and others added 2 commits February 26, 2026 22:20
- 30 story files with 79 stories across shared components, report output,
  and report creation flow
- Storybook preview updated with Redux, React Query, MemoryRouter providers
- storybookProviders.tsx for pre-populated mock data in creation flow stories
- Chromatic CI workflow and npm script
- Install chromatic and @storybook/addon-essentials

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove --exit-zero-on-changes so PR checks fail until visual changes
  are reviewed in Chromatic UI
- Add push trigger to auto-accept merged changes as new baseline

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Feb 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
policyengine-app-v2 Ready Ready Preview, Comment Feb 26, 2026 11:11pm
policyengine-calculator Ready Ready Preview, Comment Feb 26, 2026 11:11pm

Request Review

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix no-param-reassign in seeded PRNG by using local variable
- Fix operator-assignment lint rule (use ^= instead of = ... ^)
- Fix duplicate import from ./choropleth
- Update ParameterTable story to match current PolicyColumn interface
- Cast choropleth config to PartialChoroplethMapConfig for type safety

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@anth-volk
Copy link
Collaborator Author

Converting to draft, as in hindsight, this should probably be based on the changes in #730.

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.

Add Storybook & Chromatic visual regression testing

1 participant