Version. 0.1
Date. 2026-04-27
Author. Marvin Percival (DUNIN7), prepared via Claude.
Target. /Users/dunin7/loomworks-ui (frontend) on DUNIN7-M4 (MacMini). Substrate unchanged.
Priority. Standard.
Confidential. Internal.
Supersedes. Nothing for Phase 20 specifically.
Companion to. Phase 20 scoping note v0.1. Resolves Residue 16 (carried since Phase 14).
Status. First draft. Infrastructure phase — ships the test framework, not a feature. Consumes five settled scoping decisions (S1–S5).
Phase 20 establishes the frontend test framework. Two layers: Vitest + React Testing Library for component-level tests (rendering, props, conditional display, error states) and Playwright for end-to-end tests (auth flow, navigation, contribution, derive). The phase ships installation, configuration, test helpers, and a first batch of tests covering the highest-risk surfaces.
This resolves Residue 16, carried since Phase 14. After Phase 20, the frontend verification step in future CRs becomes lint + tsc + build + test clean.
No substrate changes. Frontend-only.
Archive this CR to docs/phase-crs/phase-20-cr-frontend-test-framework-v0_1.md in the substrate repo at Step 0 before Step 1 begins.
Install:
vitest (test runner)@testing-library/react (component rendering and queries)@testing-library/jest-dom (DOM matchers)@vitejs/plugin-react (JSX transform for Vitest)jsdom (DOM environment for Vitest)
Configuration: vitest.config.ts at repo root. Must resolve Next.js path aliases (@/), handle CSS modules (stub or identity transform), and configure jsdom as the test environment. CC determines the exact configuration for compatibility with Next.js 16 and Turbopack.
Install:
@playwright/testnpx playwright install chromium — Chromium only for localhost testing)
Configuration: playwright.config.ts at repo root. Base URL: http://localhost:3000. No automatic dev server start — the dev server must be running (same as manual testing). Timeout: 30s per test (LLM-dependent flows like Manifestation derivation need headroom). Single browser (Chromium). Screenshots on failure.
tests/
components/ # Vitest + RTL component tests
AssertionCard.test.tsx
HeldAssertionCard.test.tsx
EngagementPickerModal.test.tsx
RoomSwitcher.test.tsx
ContributionSurface.test.tsx
ManifestationRoom.test.tsx
e2e/ # Playwright E2E tests
auth.spec.ts
contribution.spec.ts
derive.spec.ts
navigation.spec.ts
helpers/ # Shared test utilities
mock-data.ts # Deterministic test fixtures
mock-providers.tsx # Context wrappers for component tests
test-setup.ts # Global setup for Vitest
CC may adjust the structure based on Next.js 16 conventions. The structure is a starting point, not a constraint.
Component tests do not call the substrate. A mock approach wraps components with stubbed fetch or context providers. CC determines the best pattern for the codebase — options include:
lib/api.ts module (the API client layer) via Vitest's module mocking.The chosen pattern should be consistent across all component tests.
tests/helpers/mock-data.ts exports deterministic test data: mock assertions (with display numbers, provenance, metadata), mock engagements, mock memberships, mock Manifestation (with and without organized groups), mock memory-status response, mock downstream-impact response. All UUIDs and timestamps are deterministic.
E2E tests run against the live substrate with real data. The Loomworks engagement (12 assertions, derived Manifestation) serves as the primary test engagement. E2E tests that modify state (contribute an assertion, derive a Manifestation) should clean up after themselves where possible, or use assertions that are discarded (not committed).
Playwright supports virtual authenticators. The sign-in E2E test registers a virtual authenticator before the sign-in flow, eliminating the need for a physical passkey. CC implements this per Playwright's WebAuthn documentation. TOTP verification can be computed from the person's TOTP secret (available in the test setup) using a TOTP library (e.g., otpauth).
#N) for committed assertions.
{
"test": "vitest run",
"test:watch": "vitest",
"test:e2e": "playwright test",
"test:e2e:headed": "playwright test --headed",
"test:all": "vitest run && playwright test"
}
CC adjusts as needed. The key constraint: npm run test runs component tests only (fast, no substrate needed). npm run test:e2e runs E2E tests (requires running substrate and dev server). npm run test:all runs both.
Auto-mode posture: Steps 1–3 auto, Checkpoint A. Steps 4–6 auto, Checkpoint B (final).
Step 0 — Pre-flight and CR archival.
Archive this CR (to substrate repo). Confirm prerequisites (Section 2.2).
Commit (substrate repo): Phase 20 step 0: CR archival.
Step 1 — Framework installation and configuration.
Install Vitest + RTL + Playwright. Create configuration files. Create directory structure. Create test helpers (mock data, mock providers). Verify npm run test runs (zero tests, but framework loads).
Commit (frontend repo): Phase 20 step 1: test framework installation and configuration.
Step 2 — Component tests: assertion cards and engagement picker.
Write tests for AssertionCard, HeldAssertionCard, EngagementPickerModal (Sections 5.1–5.3).
Verification: npm run test passes.
Commit (frontend repo): Phase 20 step 2: component tests — assertion cards and engagement picker.
Step 3 — Component tests: room switcher, contribution surface, manifestation room.
Write tests for RoomSwitcher, ContributionSurface, ManifestationRoom (Sections 5.4–5.6).
Verification: npm run test passes. All component tests green.
Commit (frontend repo): Phase 20 step 3: component tests — room switcher, contribution, manifestation.
Checkpoint A — Component test framework complete. All component tests pass. Operator confirms before E2E work begins.
Step 4 — E2E tests: auth and navigation.
Write auth flow and navigation E2E tests (Sections 6.1, 6.4). This step proves the Playwright setup works end-to-end with virtual authenticator and TOTP computation.
Verification: npm run test:e2e passes (with substrate and dev server running).
Commit (frontend repo): Phase 20 step 4: E2E tests — auth and navigation.
Step 5 — E2E tests: contribution and derive flows.
Write contribution flow and derive flow E2E tests (Sections 6.2, 6.3).
Verification: npm run test:e2e passes. All E2E tests green.
Commit (frontend repo): Phase 20 step 5: E2E tests — contribution and derive flows.
Step 6 — Implementation notes and tagging.
Create docs/phase-impl-notes/phase-20-implementation-notes-v0_1.md in the substrate repo.
Commit (substrate repo): Phase 20 step 6: implementation notes.
Checkpoint B — Final. Frontend: lint + tsc + build + test clean. E2E tests pass. Tag both repos as phase-20-frontend-test-framework.
Phase 20 is accepted when:
npm run test passes — all component tests green.npm run test:e2e passes — all E2E tests green (with substrate running).
On acceptance: tag both repos as phase-20-frontend-test-framework. Write implementation notes.
npm run test (component), npm run test:e2e (E2E), npm run test:all (both).lint + tsc + build + test clean replaces lint + tsc + build clean.
> Read the Change Request document at the path I supply below. This is
> CR-2026-034 v0.1, the Phase 20 Change Request (first version; no
> prior Phase 20 CR exists). You are the executing agent named in the
> CR.
>
> CR path: ~/Downloads/phase-20-cr-frontend-test-framework-v0_1.md
>
> This is an infrastructure phase — test framework, not a feature.
> Resolves Residue 16 (zero frontend tests since Phase 14).
>
> Code baseline: frontend at HEAD after Phase 19 amendment commits.
> Substrate: 1124 tests, 2 skips, running at localhost:8000.
>
> Run pre-flight (Step 0) per Section 2.2.
>
> Per Section 2.3: archive this CR to
> docs/phase-crs/phase-20-cr-frontend-test-framework-v0_1.md in
> the substrate repo at Step 0.
>
> Per Section 8, six steps with two checkpoints. Auto-mode posture:
> Steps 1–3 accept auto-mode-proceed; Checkpoint A halts. Steps 4–6
> auto; Checkpoint B (final) halts for tagging.
>
> Component tests mock the substrate (no network calls). E2E tests
> require the substrate running at localhost:8000 and the dev server
> at localhost:3000. WebAuthn uses Playwright's virtual authenticator.
>
> Pre-flight surprises stop at Step 0 and drive a CR v0.2 revision.
>
> Implementation notes at Step 6:
> docs/phase-impl-notes/phase-20-implementation-notes-v0_1.md
DUNIN7 — Done In Seven LLC — Miami, Florida Phase 20: Frontend Test Framework — CR v0.1 — 2026-04-27