frontend: Fix several issues with storybook tests#3580
frontend: Fix several issues with storybook tests#3580sniok merged 7 commits intokubernetes-sigs:mainfrom
Conversation
illume
left a comment
There was a problem hiding this comment.
🎉 thanks
The check will be quite useful.
There was a problem hiding this comment.
Pull Request Overview
This PR strengthens Storybook test reliability by catching unmocked network requests, improves MSW handler configuration to merge base and story-level mocks, and refreshes snapshots for newly rendered UI elements.
- Added detection for unhandled requests and enhanced error messages in
storybook.test.tsx - Changed
parameters.msw.handlersfrom arrays to an object schema (story/storyBase) in many stories - Updated Storyshots to include missing buttons and table markup
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| frontend/src/storybook.test.tsx | Added unhandledRequests tracking, request:unhandled listener, and more detailed fetch-error output |
| frontend/src/components//.stories.tsx | Refactored MSW config to use { handlers: { story, storyBase }} |
| frontend/src/components//snapshots//*.storyshot | Refreshed snapshots to include newly rendered buttons and table structure |
| frontend/src/components/resourceMap/GraphView.stories.tsx | Imported http & HttpResponse to mock HTTP endpoints |
Comments suppressed due to low confidence (2)
frontend/src/storybook.test.tsx:202
- Jest’s
expectdoesn’t support a custom failure message as a second argument. Consider usingexpect(unhandledRequests).toHaveLength(0)and move the explanatory text into the test name or a comment.
).toEqual([]);
frontend/src/storybook.test.tsx:168
- [nitpick] If this listener setup is moved to a shared context (e.g.,
beforeEach), remember to clearunhandledRequestsbetween tests to avoid state leakage.
const unhandledRequests: Array<string> = [];
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: illume, skoeva, sniok The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes following issues with MSW configuration in storybook tests:
parameters.msw.handlersis an array it overrides base mocks.Steps to Test
cd frontend && npm run test