Skip to content

test(ui): full component test coverage — 48% → 97% statements, 226 tests#5

Merged
Sam Gammon (sgammon) merged 2 commits into
mainfrom
test/ui-coverage-testgen
Jul 15, 2026
Merged

test(ui): full component test coverage — 48% → 97% statements, 226 tests#5
Sam Gammon (sgammon) merged 2 commits into
mainfrom
test/ui-coverage-testgen

Conversation

@sgammon

Copy link
Copy Markdown
Member

Summary

Test generation pass over @elide/ui: every previously untested component now has a behavior-focused jsdom suite. Coverage: 48% → 96.75% statements / 98.37% lines; 74 → 226 tests (34 files), all green. Also fixes a blind spot: the coverage include only counted src/components, so src/i18n and src/lib were invisible in reports — they're counted (and tested) now.

All tests follow the existing conventions (RTL role/name queries, userEvent, jest-dom): open/close and keyboard flows for the Base UI overlays, aria wiring (dialogs labelled by their titles, aria-current, aria-hidden separators), callback props, and real logic (theme persistence + OS preference, i18n deep-merge, keyed() stability, table-of-contents scroll-spy via a captured IntersectionObserver stub).

jsdom gaps are stubbed per test file, never in shared setup: PointerEvent, ResizeObserver, matchMedia, scrollIntoView, and an in-memory localStorage (Node's built-in localStorage shadows jsdom's and throws unless launched with --localstorage-file).

Remaining gaps (intentional)

  • ScrollArea scrollbar/thumb — Base UI only mounts them after measuring real content overflow; jsdom has no layout. Render paths are covered; the browser-mode Storybook suite is the right home for the rest.
  • mobile-nav branch coverage (~58%) — untested prop permutations (controlled open, section header variants); statements are at 100%.
  • select.tsx (70%) — scroll-button/positioning code that needs layout.
  • No visual-placement assertions anywhere (no layout in jsdom) — Chromatic owns those.

Pre-existing issue (not addressed here)

bunx tsc --noEmit fails on main in src/stories/CommandPalette.stories.tsx (2 × TS2322: story objects using render lack the required args) — shipped with #3, unrelated to this PR, left untouched to keep this tests-only. Trivial fix: add args: { groups: [] } (or make groups optional in meta args typing) to the two stories.

Test plan

  • bun run test:coverage — 34 files / 226 tests pass; 96.75% stmts, 90.56% branch, 98.37% lines
  • eslint src clean
  • No component source touched — tests + coverage config only

🤖 Generated with Claude Code

Sam Gammon (sgammon) and others added 2 commits July 14, 2026 18:32
The coverage include list only counted src/components, so the i18n merge
logic and lib/utils helpers were invisible in reports.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Adds 18 test files and extends 2, +152 tests (74 -> 226), written against
rendered behavior: roles, aria wiring, keyboard/pointer interaction, and
callback props — no snapshots, no CSS assertions.

- Base UI overlays: dialog, popover, tooltip, sheet, dropdown-menu
- Base UI primitives: accordion, select, switch, tabs, separator,
  scroll-area, navigation-menu (covers the extracted *-variants.ts too)
- Docs components: breadcrumbs, callout, page-footer-nav, command-palette,
  elide-logo markOnly branch, theme-provider (storage/OS-preference/toggle)
- Logic: lib/utils cn + keyed, i18n default + deep-merge, code-block
  editor/terminal/Prism paths, api-method signature branches,
  table-of-contents scroll-spy via a captured IntersectionObserver stub

jsdom gaps are stubbed per-file (PointerEvent, ResizeObserver, matchMedia,
an in-memory localStorage — Node's built-in shadows jsdom's); ScrollArea's
scrollbar/thumb need real layout to mount, so only its render paths are
asserted.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit f9b3c70.

@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.72%. Comparing base (5eea68c) to head (f9b3c70).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main       #5       +/-   ##
===========================================
+ Coverage   83.61%   97.72%   +14.11%     
===========================================
  Files          38       38               
  Lines         659      659               
  Branches      279      263       -16     
===========================================
+ Hits          551      644       +93     
+ Misses        108       15       -93     
Flag Coverage Δ
ui-browser 97.72% <ø> (+14.11%) ⬆️
ui-unit 97.72% <ø> (+14.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 13 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sgammon Sam Gammon (sgammon) merged commit d02a1c7 into main Jul 15, 2026
9 checks passed
@sgammon Sam Gammon (sgammon) deleted the test/ui-coverage-testgen branch July 15, 2026 01:35
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.

1 participant