[Testing 07] test: component and hook unit tests for the web app - #230
Merged
willchen96 merged 2 commits intoJul 22, 2026
Merged
Conversation
Ported from #24 onto current main; lockfiles regenerated against this tree. Adds vitest as a dev dependency with a `test` script in both packages, excludes test files from the backend tsc build, and seeds one suite per package (backend: downloadTokens, 12 tests; frontend: cn() utils, 8 tests). Verified locally: backend 12/12, frontend 8/8 passing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Ported from the amal66 fork (index: Open-Legal-Products#205), adapted to this repo's frontend/ layout and current component behavior. Adds the jsdom + testing-library harness on top of the existing vitest setup: vitest.config.mts (jsdom environment, @/ alias mirroring tsconfig paths, dummy Supabase env for modules that build a client at import time) and vitest.setup.ts (jest-dom matchers). New devDependencies: jsdom, @testing-library/react, @testing-library/jest-dom, @testing-library/user-event, @vitejs/plugin-react. Ported suites (30 new tests): - FileTypeIcon.test.tsx (11) — fileTypeKind mapping + icon rendering - TRTable.test.tsx (1) — header/row render smoke test; the fork's ARIA role assertions (table/columnheader, "Tabular review" label) target fork-only markup — this repo's grid is div-based, so the test asserts rendered content instead - button.test.tsx (4), pill-button.test.tsx (8), cite-button.test.tsx (3) - useSmoothedReveal.test.ts (3) — passes against this repo's early-return snap behavior unchanged Dropped (subjects don't exist here): - HistoryDropdown.test.tsx — no tr-chat-panel/HistoryDropdown component - applyAssistantStreamEvent.test.ts — no such module - useProjectsQuery/useTabularReviewsQuery/useWorkflowsQuery tests — react-query is fork-only - lib/toast.test.ts — no frontend/src/lib/toast.ts - useAssistantChat.parsers.test.ts — the parser helpers exist inside useAssistantChat.ts but are not exported, and the fork's extracted module doesn't exist here Verified: frontend npm test 38/38 passing (30 new + 8 pre-existing cn() utils tests); npx tsc --noEmit clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
QA Runner seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
willchen96
approved these changes
Jul 22, 2026
willchen96
left a comment
Collaborator
There was a problem hiding this comment.
Some tests are not really needed like those button styling but merging this in
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.
Summary
Component and hook unit tests for the web app (30 tests, jsdom + testing-library), ported from the amal66 fork (reference index #205) and adapted to the current UI. Stacks on #228 (vitest harness).
Changes
FileTypeIcon(11),pill-button(8),button(4),cite-button(3),useSmoothedReveal(3),TRTable(1, adapted — see below).frontend/vitest.config.mts— jsdom environment,@/alias mirroringtsconfig.json, setup file, dummyNEXT_PUBLIC_SUPABASE_*test env (lib/supabase.tscreates its client at module load, and TRTable's import graph reaches it; config-only, no production change).frontend/vitest.setup.ts— jest-dom matchers.@testing-library/react(React 19-compatible),@testing-library/jest-dom,@testing-library/user-event,@vitejs/plugin-react,jsdom.Why
No component in the app has a test today; UI refactors (like the recent surface refresh) currently rely on manual checking alone. These cover the shared primitives most other components compose.
Adaptation notes (accuracy over volume)
role="table", columnheader/rowheader). The TRTable here renders a div grid with none of those semantics, so the test asserts rendered content instead. The missing table semantics are a real accessibility gap worth its own fix — flagging rather than silently testing around it.HistoryDropdown,applyAssistantStreamEvent, react-query hook tests,toast, and the stream-parser tests (those functions are module-private here).Testing
npm test --prefix frontend— 7 files, 38/38 passing.npx tsc --noEmitinfrontend/— clean.Includes #228's commit as its base until proper stacking is possible — review the top commit only.
🤖 Generated with Claude Code