Migrate remaining vitest tests from axios-mock-adapter to useServerMock#21634
Merged
davelopez merged 18 commits intogalaxyproject:devfrom Jan 21, 2026
Merged
Migrate remaining vitest tests from axios-mock-adapter to useServerMock#21634davelopez merged 18 commits intogalaxyproject:devfrom
axios-mock-adapter to useServerMock#21634davelopez merged 18 commits intogalaxyproject:devfrom
Conversation
Replace axios-mock-adapter with MSW-based useServerMock for better type safety and consistency with other tests.
Replace axios-mock-adapter with MSW-based useServerMock. Handle query param checking inside the handler.
Replace axios-mock-adapter with MSW-based useServerMock. Handle query params inside handlers.
Replace axios-mock-adapter with MSW-based useServerMock. Use regex patterns for URL matching and HttpResponse.error() for network errors. Capture delete requests in array for assertions.
…ests to useServerMock Replace axios-mock-adapter with MSW-based useServerMock. Use request tracking arrays for history assertions and HttpResponse for error responses.
Remove axios-mock-adapter and use request tracking for POST assertions. The file already used useServerMock for GET, now uses it for POST too.
Remove axios-mock-adapter and use request tracking for PUT/POST assertions. Both files already used useServerMock for some endpoints, now fully migrated.
Remove axios-mock-adapter and consolidate all mocks into useServerMock handlers. Both files already used useServerMock for configuration, now fully migrated.
Replace axios-mock-adapter with MSW-based useServerMock for InvocationsProvider, JobProvider, PageProvider, and StoredWorkflowProvider tests. Handle custom URL prefixes and response headers.
ChangePassword, NewUserConfirmation, and RegisterForm tests now use the MSW-based useServerMock pattern with POST request tracking.
…ts to useServerMock These tests now use MSW-based mocking. The watchHistory test uses server.resetHandlers() to stage different responses for the multi-phase failure/recovery scenario.
These tests needed query parameter handling via request.url parsing rather than including query params directly in the path.
ToRemoteFile, ToLink, DatasetInformation, and DatasetAttributes tests now use the MSW-based mocking approach.
All tests have been migrated to use useServerMock (MSW-based mocking).
The component uses router.push() after successful password change.
Use Object.defineProperty to mock window.location.search instead of vi.spyOn, which wasn't working properly in this context.
Mock only window.location.search instead of the entire location object to avoid breaking vue-router. Also add router since the component uses router.push().
Ensures test setup navigates to a dedicated route before mounting components,
avoiding NavigationDuplicated errors when router.push("/") is invoked after
successful form submissions. The issue is caused because the router starts at "/" by default, and when any component tries to navigate again to "/" the NavigationDuplicated error will be thrown.
davelopez
approved these changes
Jan 21, 2026
Contributor
davelopez
left a comment
There was a problem hiding this comment.
Awesome! Thank you!
We can improve the typing later if needed, but this is enough to remove the old dependency and establish the current best practice mocking mechanism.
I pushed a commit fixing an issue with the router here https://github.com/galaxyproject/galaxy/actions/runs/21209751407/job/61014979943?pr=21634
Member
Author
|
@davelopez clever, cleaner than the fix I was hacking around for those, thank you! |
Contributor
I would say... clauder 🤣 |
Member
|
Very nice enhancement - thanks for splitting this out! |
|
This PR was merged without a "kind/" label, please correct. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switches all the remaining test files from
axios-mock-adaptertouseServerMockand removes the axios-mock-adapter package. Suggested by @davelopez in the Vue 3 branch PR - started working on it there but splitting it out here so it can land independently, then we'll rebase that.30 test files migrated, axios-mock-adapter removed from devDependencies. All tests pass.
How to test the changes?
(Select all options that apply)
License