Skip to content

refactor: migrate storybook mocking to sb.mock() - #1832

Open
jonsuguiyama wants to merge 1 commit into
hasadna:mainfrom
jonsuguiyama:simplify-storybook-mocking
Open

refactor: migrate storybook mocking to sb.mock()#1832
jonsuguiyama wants to merge 1 commit into
hasadna:mainfrom
jonsuguiyama:simplify-storybook-mocking

Conversation

@jonsuguiyama

Copy link
Copy Markdown
Collaborator

Summary

  • Replaces per-story MSW handlers with Storybook 10's sb.mock(),
    mocking the actual hooks/functions instead of intercepting HTTP
    by URL
  • Removes a dead MSW handler (/siri_rides/list) from two stories;
    verified repo-wide (every caller of siriRidesListGet, full import
    tree of both components and their children) that it never runs

Test plan

  • npx tsc --noEmit
  • npx eslint (all changed files)
  • npx storybook build
  • Visual check in Storybook dev server

Closes #1455

Storybook 10's sb.mock() replaces the per-story MSW HTTP handlers
(hardcoded URLs, manual JSON responses) with module-level mocks of
the actual data-fetching hooks/functions, registered once in
.storybook/preview.tsx.

Migrated: OperatorGaps, BusToolTip, ComplaintModal,
MapWithLocationsAndPath, AllLinesChart, DayTimeChart,
WorstLinesChart, OperatorRoutes, VelocityHeatmapRectangles.

Dropped an MSW handler for /siri_rides/list in BusToolTip and
ComplaintModal stories. Verified across the whole repo (every
caller of siriRidesListGet, plus the full import tree of both
components and their children) that neither component ever
reaches that endpoint, so it was mocking a request that never
happens.

Requires allowImportingTsExtensions in tsconfig.json, needed for
sb.mock()'s static import-path analysis.
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.

simplify storybook mocking

1 participant