Skip to content

[Testing 07] test: component and hook unit tests for the web app - #230

Merged
willchen96 merged 2 commits into
Open-Legal-Products:mainfrom
amal66:olp-pr/frontend-unit-tests
Jul 22, 2026
Merged

[Testing 07] test: component and hook unit tests for the web app#230
willchen96 merged 2 commits into
Open-Legal-Products:mainfrom
amal66:olp-pr/frontend-unit-tests

Conversation

@amal66

@amal66 amal66 commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

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

  • Tests: FileTypeIcon (11), pill-button (8), button (4), cite-button (3), useSmoothedReveal (3), TRTable (1, adapted — see below).
  • frontend/vitest.config.mts — jsdom environment, @/ alias mirroring tsconfig.json, setup file, dummy NEXT_PUBLIC_SUPABASE_* test env (lib/supabase.ts creates its client at module load, and TRTable's import graph reaches it; config-only, no production change).
  • frontend/vitest.setup.ts — jest-dom matchers.
  • Dev-dependencies: @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)

  • The fork's TRTable test asserted table ARIA roles (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.
  • Dropped entirely because their subjects don't exist in this repo: 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 --noEmit in frontend/ — clean.

Includes #228's commit as its base until proper stacking is possible — review the top commit only.

🤖 Generated with Claude Code

QA Runner and others added 2 commits July 20, 2026 10:42
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>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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.

@amal66 amal66 changed the title test: component and hook unit tests for the web app [Testing 07] test: component and hook unit tests for the web app Jul 21, 2026

@willchen96 willchen96 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Some tests are not really needed like those button styling but merging this in

@willchen96
willchen96 merged commit 2ec89a7 into Open-Legal-Products:main Jul 22, 2026
1 check was pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants