fix(tests): update DatasetList tests to new fetch-mock API#37623
Conversation
The fetch-mock library was upgraded and the API changed:
- fetchMock.reset() → fetchMock.removeRoutes()
- fetchMock.resetHistory() → fetchMock.clearHistory()
- fetchMock.restore() → fetchMock.removeRoutes()
- fetchMock.calls() → fetchMock.callHistory.calls()
- call[0] → call.url, call[1] → call.options
- { overwriteRoutes: true } option removed (no longer exists)
- QueryParamProvider now requires adapter prop
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review Agent Run #c84c92
Actionable Suggestions - 2
-
superset-frontend/src/pages/DatasetList/DatasetList.testHelpers.tsx - 1
- Incorrect unmatched call detection · Line 454-454
-
superset-frontend/src/pages/DatasetList/DatasetList.behavior.test.tsx - 1
- Incorrect Jest mock access · Line 165-165
Review Details
-
Files reviewed - 6 · Commit Range:
e13418f..e13418f- superset-frontend/src/pages/DatasetList/DatasetList.behavior.test.tsx
- superset-frontend/src/pages/DatasetList/DatasetList.integration.test.tsx
- superset-frontend/src/pages/DatasetList/DatasetList.listview.test.tsx
- superset-frontend/src/pages/DatasetList/DatasetList.permissions.test.tsx
- superset-frontend/src/pages/DatasetList/DatasetList.test.tsx
- superset-frontend/src/pages/DatasetList/DatasetList.testHelpers.tsx
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.
Documentation & Help
- Fix toast message access: use mock.calls[0][0] instead of mock.calls[0].url
(Jest mock calls are arrays, not objects with url property)
- Fix unmatched calls detection: use calls('unmatched') instead of calls(false)
(fetch-mock v12 API change)
- Add fetchMock.removeRoute() before per-test mocks in permissions tests
(ensures test-specific mocks override setupMocks() defaults)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review Agent Run #1ad292Actionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
- Add fetchMock.removeRoute() before re-registering routes
- Add { name: ... } option to all route registrations for proper removal
- Remove unused setupApiPermissions function
- Fix PayloadMap type to use Record<string, string[]>
- Add DELETE_ROUTE_NAME constant for delete operation assertions
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add removeRoute() + named routes to behavior test overrides. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review Agent Run #8dcdcfActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
@sadpandajoe @rusackas Do you know why CI didn't fail previously? |
|
@michael-s-molina there wasn't any new tests with |
@michael-s-molina, @hainenber is correct that there were no tests that used the same |
Summary
Updates DatasetList test files to use the new fetch-mock v12 API, fixing TypeScript compilation errors.
#36681 added comprehensive RTL and integration tests for DatasetList using the fetch-mock v11 API. Subsequently, #36662 upgraded fetch-mock from v11.1.5 to v12.6.0, which introduced breaking API changes. This PR updates the DatasetList tests to use the new API.
Changes
API migrations (6 files, 318 insertions, 420 deletions):
fetchMock.reset()fetchMock.removeRoutes()fetchMock.resetHistory()fetchMock.clearHistory()fetchMock.restore()fetchMock.removeRoutes()fetchMock.calls(filter)fetchMock.callHistory.calls(filter)call[0](url)call.urlcall[1](options)call.options{ overwriteRoutes: true }<QueryParamProvider><QueryParamProvider adapter={ReactRouter5Adapter}>Files modified:
DatasetList.testHelpers.tsxDatasetList.test.tsxDatasetList.behavior.test.tsxDatasetList.listview.test.tsxDatasetList.permissions.test.tsxDatasetList.integration.test.tsxTest plan
npm run buildpasses (TypeScript compilation)🤖 Generated with Claude Code