DSM-171: Frontend testing setup using Vitest and Testing Library#73
Open
wtomaszewska wants to merge 11 commits into
Open
DSM-171: Frontend testing setup using Vitest and Testing Library#73wtomaszewska wants to merge 11 commits into
wtomaszewska wants to merge 11 commits into
Conversation
…licts between eslint and prettier
…ettier on routes and entrypoints subdirectories
…pp for testing components with RQ, add bucket data generator
…frontend tests not being recognized by vitest; adjust paths for linting and formatting
…onsumed; add tests for ObjectDetailsRoute - test object overview and storage details displays; add BucketContentsRoute tests
…ractions; add bucket contents test to verify column sorting; extract app rendering and loader check to renderAppAndWait
goldsmithb
approved these changes
Jun 5, 2026
goldsmithb
left a comment
There was a problem hiding this comment.
This is great! I just left one small suggestion
| const routePath = path ?? url; // defaults to url — only pass path for parameterized routes | ||
|
|
||
| const router = createMemoryRouter([{ path: routePath, element: ui }], { | ||
| initialEntries: url ? ['/', url] : ['/'], |
There was a problem hiding this comment.
Since url has a default value of '/' and is always truthy, perhaps this could be simplified to just:
initialEntries: ['/', url],
initialIndex: 1,
though it would have a redundant entry if the url is root (but I don't think it would be consequential).
Or something like:
const isRoot = url === '/';
const router = createMemoryRouter([{ path: routePath, element: ui }], {
initialEntries: isRoot ? ['/'] : ['/', url],
initialIndex: isRoot ? 0 : 1,
});
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 DSM-171
Note: This frontend testing setup is identical to the one implemented in the Hyacinth app.
This PR introduces frontend tests using Vitest, Testing Library, and MSW (Mock Service Worker). The focus is on integration tests that verify component rendering and user interactions (sorting columns).
Updated folder structure
vite-plugin-rubyforcibly sets Vite'sroottosourceCodeDir. If the React app's entry point (app/javascript) lives in a different directory than the tests (app/s3browserwhere the frontend code and tests live), the tests are not picked up correctly. To solve this, I moved all frontend code underapp/javascriptso that the entry point file, the frontend code, and the tests share the same parent directory.Test 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 testssrc/testing/data-generators.ts) - factory functions for creating test datasrc/testing/test-utils.tsx)renderApp(ui, options)- renders a component inside QueryClientProvider + MemoryRouter for testing route componentsFrontend Tests
Frontend tests cover all the routes users can navigate to.
bucket-contents.test.tsxbuckets.test.tsxobject-details.test.tsxNote: Pagination tests are not included, as the underlying bugs need to be addressed before we start adding tests.