Search 3.0: add Storybook stories for feature-selector components (SEARCH-179)#48624
Search 3.0: add Storybook stories for feature-selector components (SEARCH-179)#48624
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 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
adamwoodnz
left a comment
There was a problem hiding this comment.
Review depth: standard (391 lines, 2 projects)
Summary
Adds Storybook coverage for <ExperienceOption> and <FeatureSelector>, extends the search-dashboard-modules Vite plugin to resolve bare store/store/* imports (in addition to existing components/*), and adds a placeholder dummy.js the plugin needs to anchor relative resolution.
Findings
Convention
[suggestion]— Changelog type ischanged, but the precedent for the only other Storybook-only entry in this package wasAdded:These are net-new story files, so### Added - Added stories for the NoticeBox component [#26367]Type: addedis the more accurate classification.
https://github.com/Automattic/jetpack/blob/5e8e407cbc/projects/packages/search/changelog/add-storybook-stories-search-179#L1-L4
Code quality
-
[suggestion]— Inexperience-option.stories.jsx, onlyexperienceanddisabledare declared inargTypes. ThependingExperienceandactiveExperienceargs drive the seeded store state but aren't exposed in the Storybook controls panel — so a reviewer can't toggle "selected" / "active" / "unselected" states without editing the file. Either add controls for them, or drop the Template-args pattern and use plain function stories likefeature-selector.stories.jsxalready does. Mixing the two muddies what the controls actually do.
https://github.com/Automattic/jetpack/blob/5e8e407cbc/projects/packages/search/src/dashboard/components/feature-selector/stories/experience-option.stories.jsx#L19-L52 -
[suggestion]—createStoreWithSettingsis duplicated across the two new story files (and again in the existing test fixtures attests/js/dashboard/feature-selector/). A tiny shared decorator (e.g.,decorators/with-search-store.jsx) would let the next story skip this boilerplate and put the seed shape in one place if the store schema evolves. Not blocking — fine to defer.
https://github.com/Automattic/jetpack/blob/5e8e407cbc/projects/packages/search/src/dashboard/components/feature-selector/stories/feature-selector.stories.jsx#L21-L34 -
[suggestion]— The story comment "Embedded experience (default - shows RECOMMENDED badge)" is slightly misleading: the RECOMMENDED badge is keyed offexperience === EMBEDDEDand is always present on that row regardless of selection/active state. WithpendingExperience: null, activeExperience: nullandmodule_active/instant_search_enabledboth true,getActiveExperiencederives to'overlay', so the Embedded row in this story renders unselected/inactive. Consider clarifying the comment to "Default — Embedded row in its unselected/inactive baseline; RECOMMENDED badge always shows on Embedded".
https://github.com/Automattic/jetpack/blob/5e8e407cbc/projects/packages/search/src/dashboard/components/feature-selector/stories/experience-option.stories.jsx#L55-L62 -
[suggestion]— Thesearch-dashboard-modulesplugin now ORs three id-shape checks. Easier to scan and extend later as:const handled = id.startsWith( 'components/' ) || id === 'store' || id.startsWith( 'store/' ); if ( handled && importer?.includes( '/search/src/dashboard/' ) ) { … }
Or as an array of prefixes. Not blocking. Worth noting that on
trunkthe referenceddummy.jsdidn't actually exist — the plugin was unexercised until this PR — so this is the first time the path is hit in practice; the new file lands correctly alongside the matching imports.
https://github.com/Automattic/jetpack/blob/5e8e407cbc/projects/js-packages/storybook/storybook/main.js#L82-L101
Other checks
Security, performance, backward compatibility, translations, a11y, RTL, data/privacy, cross-project impact: all clear (devtools-only changes; no public API, no user-facing strings, no DB or network access).
Verdict
Minor issues — can merge after addressing. No blockers. Worth taking #1 (changelog type) before merge; the rest are stylistic suggestions you can take or leave.
Reviewed 5 files, 391 lines changed.
Code Coverage Summary1 file is newly checked for coverage.
|
Agent-Logs-Url: https://github.com/Automattic/jetpack/sessions/c03948c1-2e59-47c7-8a0b-d608e8a2a164 Co-authored-by: adamwoodnz <1017872+adamwoodnz@users.noreply.github.com>
- Reformat the search-dashboard-modules id check to a single line (prettier). - Reorder imports in the new story files to satisfy import/order. - Add a js-packages/storybook changelog entry for the Vite plugin tweak.
7f06984 to
02e6047
Compare
The Template seed left settings.experience null and relied on the legacy boolean fallback in getActiveExperience, which derives 'overlay' from `instant_search_enabled: true`. That made the Overlay baseline and OverlaySelected stories render identically to OverlayActive (both is-selected and is-active set). Pick a default active that doesn't match the rendered row so each story shows the state it advertises.
Fixes SEARCH-179
Why
No user-visible change. Designers and reviewers of the Search 3.0 dashboard can now demo the feature-selector UI — plan-gating, badge variants, and the dirty / saving / disabled save-button states — directly in Jetpack's Storybook without booting WordPress. This keeps visual regression checks and design review in the loop for the components shipped in #48500.
Proposed changes
<ExperienceOption>(Packages/Search/FeatureSelector/ExperienceOption) covering each experience (embedded, overlay, inline, off), selected vs unselected, and the disabled state with upgrade tooltip.<FeatureSelector>(Packages/Search/FeatureSelector) covering clean (Save aria-disabled), dirty (Save enabled), saving (isBusyspinner), classic-only-plan (Embedded + Overlay disabled), and each experience as the active row.RegistryProviderwith a fake store seeded withjetpackSettingsandsitePlan, mirroring the existing test fixtures.search-dashboard-modulesVite plugin in Storybook to resolve barestoreandstore/imports (in addition to the existingcomponents/handling) so the components render without module resolution errors.dummy.jsplaceholder insrc/dashboard/to back the Vite plugin's path resolution.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
pnpm jetpack build js-packages/storybook(or run an existing Storybook build for the monorepo), thenpnpm --filter @automattic/jetpack-storybook storybook.ExperienceOptionrenders one row per story (Embedded, Overlay, Inline, Off), in selected and unselected variants, and that the Disabled story shows the upgrade tooltip on hover.FeatureSelectorrenders the full form with the documented states reachable as separate stories: Clean (Save aria-disabled), Dirty (Save enabled), Saving (spinner viaisBusy), ClassicOnlyPlan (Embedded + Overlay disabled), and each experience as the active row.--wpds-*custom properties from@wordpress/theme) load correctly — text colours, spacing, and badge styles should all look right.Original prompt
Issue Title: Search dashboard feature selector: Storybook stories
Issue Description: Companion to RSM-2116 (PR #48500). The new dashboard components ship without Storybook coverage; this issue tracks adding them.
Why
The Search package already publishes one story (
Packages/Search/RecordMeter/NoticeBox) under the Jetpack monorepo's Storybook atprojects/js-packages/storybook/. Adding stories for the new feature-selector components keeps designers, reviewers, and visual regression checks in the loop without booting WordPress, and gives us a place to demo plan-gating, badge variants, and the dirty / saving / disabled save-button states in isolation.Components to cover
All three are added in PR #48500 and live in
projects/packages/search/src/dashboard/components/:<ExperienceOption>—dashboard/components/feature-selector/experience-option.jsxPackages/Search/FeatureSelector/ExperienceOptionexperience('embedded' | 'overlay' | 'classic' | 'off'),disabled.<FeatureSelector>—dashboard/components/feature-selector/index.jsxPackages/Search/FeatureSelectorisBusy), classic-only-plan (Embedded + Overlay disabled), each experience as the active row.The components subscribe to the dashboard's redux store, so the stories will need a
RegistryProviderwrapper that registers a fake store seeded withjetpackSettings(andsitePlanfor the plan-gating story). The existing test files atprojects/packages/search/tests/js/dashboard/feature-selector/show the exact shape of that wrapper and the seed args for each state.Acceptance
--wpds-*custom properties from@wordpress/theme).Fixes https://linear.app/a8c/issue/SEARCH-179/search-dashboard-feature-selector-storybook-stories
Branch Name should include the identifier "SEARCH-179"