feat(atomic): migrate IPX button and modal stories to MSW#7601
Conversation
Replace direct API calls with MSW mock handlers for: - atomic-ipx-button: Replace manual getSampleSearchEngineConfiguration() with wrapInSearchInterface() decorator and MockSearchApi handlers - atomic-ipx-modal: Add MockSearchApi handlers to intercept API calls Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Important Testing in progress…🟢 UI Tests: 366 tests unchanged |
|
Tip All tests passed and all changes approved!🟢 UI Tests: 366 tests unchanged |
@coveo/atomic
@coveo/atomic-hosted-page
@coveo/atomic-legacy
@coveo/atomic-react
@coveo/auth
@coveo/bueno
@coveo/create-atomic
@coveo/create-atomic-component
@coveo/create-atomic-component-project
@coveo/create-atomic-result-component
@coveo/create-atomic-rollup-plugin
@coveo/headless
@coveo/headless-react
@coveo/shopify
commit: |
There was a problem hiding this comment.
Pull request overview
This PR updates Atomic IPX Storybook stories so they no longer rely on live API availability, by switching atomic-ipx-button and atomic-ipx-modal to MSW-backed mocks via MockSearchApi and the existing wrapInSearchInterface() utilities.
Changes:
- Added
MockSearchApiinstances and MSW handlers to both story files. - Migrated
atomic-ipx-buttonaway from manualatomic-search-interfaceinitialization to the sharedwrapInSearchInterface({skipFirstSearch: true})decorator/play flow. - Added per-story
beforeEachcleanup to clear queued mock search responses between story runs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/atomic/src/components/ipx/atomic-ipx-modal/atomic-ipx-modal.new.stories.tsx | Adds MockSearchApi + MSW handlers and resets mock search state per story run. |
| packages/atomic/src/components/ipx/atomic-ipx-button/atomic-ipx-button.new.stories.tsx | Uses wrapInSearchInterface + MSW handlers instead of manual interface initialization, and clears mock search state per story run. |
Problem
The
atomic-ipx-buttonandatomic-ipx-modalStorybook stories were not using MSW to mock API calls. Instead, they relied on directgetSampleSearchEngineConfiguration()calls or missing mock handlers, making them dependent on live API availability.Solution
Migrated both stories to use
MockSearchApiwith MSW handlers:wrapInSearchInterface()decorator and added MSW handlersMockSearchApiinstance and MSW handler configurationAll 7 IPX stories now consistently use MSW for API mocking.