HYACINTH-1146 Integrate frontend testing using Vitest#483
Merged
wtomaszewska merged 14 commits intomainfrom Feb 24, 2026
Merged
HYACINTH-1146 Integrate frontend testing using Vitest#483wtomaszewska merged 14 commits intomainfrom
wtomaszewska merged 14 commits intomainfrom
Conversation
….4.1; set up server and db mocking, replicate users API in users mocks, add the first integration test for users index page (users list)
…erations, allow for passing the expected data directly into the mock api function, convert UsersIndexRoute to use updated testing strategy
…ions route-level components
… forms, check successful and unsuccessful form updates
…ests for authorization helper functions
…n to make sure it has access to the current user, rename Settings file to follow established convention for routes dir
…nd queues generation of derivatives for records without derivatives
…o image reference in new UI; Remove unused import in variables.scss
…TableBuilder component. Make path argument optional for routes without parameters
…grate-testing-using-vitest
…ring, add frontend tests to Github actions
elohanlon
requested changes
Feb 24, 2026
Member
elohanlon
left a comment
There was a problem hiding this comment.
This PR is fantastic! Really well done. This is the kind of frontend test coverage we want in our apps, and such a good foundation for future testing.
I left a few very minor suggested changes, but otherwise really like everything I'm seeing here.
app/frontend/src/app/routes/settings/__tests__/settings.test.tsx
Outdated
Show resolved
Hide resolved
app/frontend/src/components/ui/table-builder/__tests__/table-builder.test.tsx
Show resolved
Hide resolved
Member
There was a problem hiding this comment.
One additional test that could be good to add here: verifying that requireAuthorization does an OR-based (as opposed to AND-based) role check when an array of multiple roles is supplied as the second parameter. Example: requireAuthorization(queryClient, [ROLES.ADMIN, ROLES.USER]);
Contributor
Author
There was a problem hiding this comment.
Good idea, added the test
…n loader-authorization
…grate-testing-using-vitest
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.
Ticket HYACINTH-1146
Overview
This PR introduces a frontend testing infrastructure using Vitest, Testing Library, and MSW (Mock Service Worker). The focus is on integration tests that verify component rendering, user interactions, and API integration. Additionally, Capybara E2E tests were added to ensure the Rails-React integration works correctly.
Testing Infrastructure
Vitest Configuration
Dependencies Added
vitest- Test runner@testing-library/react,@testing-library/dom,@testing-library/jest-dom- React testing utilities@testing-library/user-event- User interaction simulationmsw- API mockingjsdom- DOM environment for testsCI Integration
yarn test --runstep to run frontend tests in CI pipelineTest Helpers
src/testing/setup.ts) - global test setup that:src/testing/mock-api.ts)mockApi(method, path, body, status)- registers mock API responses for individual testsapi/v2src/testing/data-generators.ts) - factory functions for creating test data:src/testing/test-utils.tsx)renderApp(ui, options)renderWithRoutes(routesFactory, options)Frontend Tests
Library Tests (
src/lib/__tests__)auth.test.ts(unit tests) - testsuseCurrentUserhook (successful user fetch and graceful null return on API failure)loader-authorization.test.ts(unit tests) - Tests requireAuthorization function - role checking, error throwing and edge cases (no roles required, empty roles array)authorization.test.ts(integration tests) - Tests route-level authorization using actual route loaders and error boundaries - verifies non-admins see access denied, admins can access and self-edit redirects to settingsRoute Tests (
src/app/routes)Users Routes (
src/app/routes/users/__tests__)index.test.tsx- Users list table rendering, column headers, sorting, UID links, “Create New User” buttonnew.test.tsx- Empty form rendering, enabled UID field, default checkbox states, form submission success/erroredit.test.tsx- Form pre-population from API, disabled UID field, save success/error alerts, API key generation UIproject-permissions.test.tsx- Admin info message display, non-admin permissions table, editable checkboxes, add/remove permissionsSettings Routes (
src/app/routes/settings/__tests__)settings.test.tsx- Current user form rendering, disabled fields when editing self, API key section, save success/errorproject-permissions.test.tsx- Admin info message, read-only permissions table for non-admins, disabled checkboxes, no edit controlsComponent Tests (
src/components/ui)table-builder/__tests__/table-builder.test.tsx- Table Builder is a reusable component that uses TanStack Table to display data and enable sorting. In the future, we’ll probably enhance it with filtering, pagination, etc. Since many pages will rely on this component, we want to ensure sufficient test coverage. The tests verify:Backend Tests (Capybara)
React Application Authentication (
ui_v2_spec.rb)Since the React application is rendered under /ui/v2 and relies on Rails for authentication, Capybara feature specs were added to verify the Rails-React integration.
Running Tests