Premium Analytics: add forced Loading/Error/Empty Storybook stories for migrated widgets#50391
Conversation
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 🔴 Action required: We would recommend that you add a section to the PR description to specify whether this PR includes any changes to data or privacy, like so: 🔴 Action required: Please add missing changelog entries for the following projects: Use the Jetpack CLI tool to generate changelog entries by running the following command: Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
154e20b to
e4c7536
Compare
7601ca8 to
4d9fcee
Compare
4d9fcee to
c5048f2
Compare
c5048f2 to
55f985b
Compare
Proposed changes
Why: The WidgetState migration (#50383) converts the dashboard widgets to render their own loading / error / empty states via
<WidgetState>, but there was no way to review those states directly in Storybook — the stories only exercised the populated (ready) state. Reviewers and designers need to see each widget's loading, error, and empty state without a live backend. These stories were split out of #50383 to keep that PR focused on the behavior change.How: Each migrated widget gains
Loading/Error/Emptystories that force the state through the mock layer rather than rendering the populated fixture:beforeEachviasetReportMockState( '<endpoint>', 'loading' | 'error' | 'empty' )and cleared in the returned cleanup, so it never leaks into sibling stories.quantity) distinct from the widget's other stories, giving it its own query-cache entry so it hits the mock fresh instead of reading another story's cached success from the shared query client.!autodocs— the mock override is keyed by path, so leaving them on the shared autodocs page would drag the sibling stories into the same state.widgets/stories/force-stats-mock-state.tsforces states for the Stats endpoints thatsetReportMockStatecan't reach because a later-registered analytics-proxy handler shadows them.What:
Loading/Error/Emptystories.widgets/stories/force-stats-mock-state.tshelper for endpoints the default mock router shadows.Note: the
emailsandtop-postsforced-state stories ship in #50383, not here — their pre-existing stories passedisLoading/isErrorprops that the migration removed from the leaderboard components, so rewriting them is coupled to that PR and required to keep it green.Stacked on #50383; base will retarget to
trunkautomatically once that merges.Testing instructions
Loading,Error, andEmptystories and confirm each renders the corresponding<WidgetState>state (error shows a Retry action; empty shows the neutral glyph + copy).Default/WithComparison/ dashboard stories still render populated (the forced state doesn't leak across stories).