Skip to content

test(preview): add component coverage for every fixture lifecycle state - #91

Merged
7shep merged 2 commits into
mainfrom
agent/issue-53-preview-tests
Jul 31, 2026
Merged

test(preview): add component coverage for every fixture lifecycle state#91
7shep merged 2 commits into
mainfrom
agent/issue-53-preview-tests

Conversation

@7shep

@7shep 7shep commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary

apps/preview rendered its lifecycle states with no component coverage, so status semantics, diagnostic visibility, and the sandbox posture could regress without reaching the root test gate.

  • src/preview-app.test.tsx covers the four states named in the issue — no-project, loading, build-unavailable, and runtime-error — plus the ready and retained-last-good states the app has grown since. All are driven by an injected fake PreviewClient; no runtime, network, or generated build is involved.
  • Assertions target the semantics that regress silently: role=status vs role=alert on the right panel, matching aria-live politeness, structured diagnostic visibility, and that each state is distinguishable by its status text rather than colour alone.
  • Also asserted at runtime, not by reading source: the iframe stays sandbox=allow-scripts with referrerpolicy=no-referrer, and the escape routes out of a broken state are real keyboard-focusable links.
  • No full-DOM snapshots, so visual changes do not produce false failures.

New test dependency

The package test script becomes vitest run. Preview is a Vite app and its components are .tsx; node --experimental-strip-types cannot strip JSX, so the existing bare node --test runner cannot load them. Vitest reuses the app's own Vite transform pipeline instead of adding a second one.

Three dev-only dependencies: vitest, jsdom, @testing-library/react. None are bundled. preview-client.test.ts keeps its node:assert/strict assertions and only swaps its test import; its source-reading assertion now resolves via import.meta.dirname. Rationale is documented in the new apps/preview/README.md.

Validation

  • pnpm --filter @universal/preview test (15 passing)
  • pnpm --filter @universal/preview typecheck
  • pnpm --filter @universal/preview lint
  • pnpm --filter @universal/preview build
  • pnpm format:check

No visible behaviour changed; this PR adds tests, a README, and the test runner only.

Closes #53.

🤖 Generated with Claude Code

Preview rendered lifecycle states with no component coverage, so status
semantics, diagnostics, and the sandboxed frame could regress without
reaching the root test gate.

Add component tests driven by an injected fake PreviewClient and run the
package suite under Vitest so JSX and the app Vite pipeline are shared.

Closes #53.

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
universal Ready Ready Preview Jul 31, 2026 6:38pm

@7shep
7shep merged commit d791d33 into main Jul 31, 2026
7 checks passed
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.

test(preview): add component coverage for every fixture lifecycle state

1 participant