Skip to content

Migrate remaining vitest tests from axios-mock-adapter to useServerMock#21634

Merged
davelopez merged 18 commits intogalaxyproject:devfrom
dannon:use-server-mock
Jan 21, 2026
Merged

Migrate remaining vitest tests from axios-mock-adapter to useServerMock#21634
davelopez merged 18 commits intogalaxyproject:devfrom
dannon:use-server-mock

Conversation

@dannon
Copy link
Copy Markdown
Member

@dannon dannon commented Jan 21, 2026

Switches all the remaining test files from axios-mock-adapter to useServerMock and 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)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

dannon added 17 commits January 20, 2026 21:32
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().
@dannon dannon marked this pull request as ready for review January 21, 2026 12:34
@github-actions github-actions Bot added this to the 26.1 milestone Jan 21, 2026
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.
Copy link
Copy Markdown
Contributor

@davelopez davelopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@dannon
Copy link
Copy Markdown
Member Author

dannon commented Jan 21, 2026

@davelopez clever, cleaner than the fix I was hacking around for those, thank you!

@davelopez
Copy link
Copy Markdown
Contributor

clever

I would say... clauder 🤣

@jmchilton
Copy link
Copy Markdown
Member

Very nice enhancement - thanks for splitting this out!

@davelopez davelopez merged commit a79f97e into galaxyproject:dev Jan 21, 2026
32 checks passed
@github-actions
Copy link
Copy Markdown

This PR was merged without a "kind/" label, please correct.

@davelopez davelopez added the kind/refactoring cleanup or refactoring of existing code, no functional changes label Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/client area/UI-UX kind/refactoring cleanup or refactoring of existing code, no functional changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants