Skip to content

test: jsdom + Testing Library component smoke tests#7

Closed
abk1969 wants to merge 1 commit into
test/data-integrityfrom
test/component-smoke
Closed

test: jsdom + Testing Library component smoke tests#7
abk1969 wants to merge 1 commit into
test/data-integrityfrom
test/component-smoke

Conversation

@abk1969
Copy link
Copy Markdown
Owner

@abk1969 abk1969 commented May 15, 2026

Summary

Closes the highest-impact gap from the TDD audit retrospective: the project had zero component-level tests. The C2 `roleNotes` scope error in PR #3 (caught only by spec review) is the canonical example — green unit tests + green build, yet a runtime `ReferenceError` when reaching the verdict screen.

Stacks on PR #6.

What's set up

New devDeps: `@testing-library/react`, `@testing-library/jest-dom`, `@testing-library/user-event`, `jsdom`.

vitest.config.js: per-file environment via `environmentMatchGlobs`. Only `*.dom.test.jsx` files spin up jsdom — the existing 109 node-env tests stay fast. Adds `@vitejs/plugin-react` for JSX transform.

src/test-setup.js: jest-dom matchers (`toBeInTheDocument`, `toBeEnabled`, …) + a stub for `window.scrollTo` (jsdom doesn't implement it; the App calls it on step change → otherwise produces noisy stderr).

Tests added (`src/app.dom.test.jsx`)

4 component smoke tests:

  1. App mounts welcome screen without throwing — the minimum runtime safety net. If the React tree ever fails to construct (missing import, syntax error in JSX, scope mistake at component boundary), this test fails.
  2. Welcome → Step 1 navigation — verifies the Start button is clickable and Step 1 renders.
  3. Continue button enables after role selection — exercises state-driven UI gating.
  4. deployerKind sub-question conditional visibility — directly tests the pattern that broke in C2: a state field (`answers.role === 'deployeur'`) gating a downstream UI element. If the gating logic regressed, this would fail.

Tests

  • 113 passing (109 → 113)
  • Build green, no bundle change (test infra only)
  • Suite runtime: ~5 s (node tests ~1.5 s, jsdom tests ~3.5 s)
  • jsdom stderr suppressed via `window.scrollTo` stub

What's deferred

Deep Result-screen walk-throughs (advancing all 7 steps to verify the verdict renders) are NOT in this PR. Getting there in jsdom with the current UI requires selector engineering that's high-effort for limited additional safety. The correct path forward is Playwright E2E (Playwright is already a devDep, used by `make-demo.cjs` to record the demo video).

A natural follow-up would be a single `tests/e2e/result.spec.js` that walks each verdict path end-to-end with screenshot assertions.

Test plan

🤖 Generated with Claude Code

…ests

Closes the highest-impact gap from the TDD audit: 0 → 4 component-level tests
that exercise the React tree and would have caught C2's roleNotes scope error
(defined in App, consumed in Result — green unit tests + green build, but
runtime ReferenceError at verdict screen).

Infrastructure:
- devDeps: @testing-library/react, @testing-library/jest-dom,
  @testing-library/user-event, jsdom
- vitest.config.js: per-file environment via environmentMatchGlobs so only
  *.dom.test.jsx files spin up jsdom (keeps the existing 109 node-env tests
  fast). Adds @vitejs/plugin-react for JSX transform.
- src/test-setup.js: jest-dom matchers + stub window.scrollTo (jsdom doesn't
  implement it; the App calls it on step change).

Tests (src/app.dom.test.jsx):
- App mounts welcome screen without throwing
- Welcome → Step 1 navigation
- Continue button enables after role selection
- deployerKind sub-question conditional visibility (would catch the C2 bug
  class: if roleNotes/computeRoleNotes were broken, the dependent UI bits
  would fail to render here)

Total: 113 tests pass (109 + 4), build green, ~5 s suite runtime.

The deeper Result-screen walk-throughs are intentionally deferred to a
future Playwright E2E pass — getting to step 7 in jsdom with the current
UI requires more selector engineering than the safety net warrants.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ai_act_compass Ready Ready Preview, Comment May 15, 2026 2:40pm

@abk1969
Copy link
Copy Markdown
Owner Author

abk1969 commented May 16, 2026

Merged into main via rebase fast-forward (commits applied via stack rebase, see main's history). Branch deleted.

@abk1969 abk1969 closed this May 16, 2026
@abk1969 abk1969 deleted the test/component-smoke branch May 16, 2026 12:44
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