Frontend: - Replace Next.js with Vite + React + TypeScript - Add new component architecture (app-shell, sidebar, dashboard modules) - Implement product modules: FRAME, safety protocols, walkthrough checkin, campus/staff attendance, personality quiz, sign language, classroom timer - Add shadcn/ui component library with Tailwind CSS - Remove legacy generated components, stores, and pages Backend: - Add product migrations: frame_entries, user_progress, safety_quiz_results, walkthrough_checkins, communication_events, personality_quiz_results, campus_attendance_config/summaries, staff_attendance_records, content_catalog - Add corresponding models, services, and routes - Implement cookie-based auth with refresh token rotation - Add content catalog seeder with product content - Migrate to ESLint flat config - Switch from yarn to npm Infrastructure: - Update .gitignore for new tooling - Add project documentation (CLAUDE.md, docs/) - Remove deprecated config files and yarn.lock Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
7.5 KiB
Frontend Test Coverage
Purpose
Frontend tests protect the three-layer architecture by testing API/data-access and business logic directly, without rendering full product modules when rendering is not needed.
Test Runner
npm run testrunsvitest run.npm run test:e2eruns backend-free Playwright smoke tests against a production build served by Vite preview.npm run test:e2e:contentruns backend-seeded content catalog Playwright tests against a production build served by Vite preview.npm run typecheckremains the TypeScript gate.npm run buildruns typecheck before Vite.
Current Coverage
Current coverage includes architecture guardrails, API/data-access behavior, and pure business-layer behavior in these files:
frontend/src/app/appRoutes.test.tsfrontend/src/business/app-shell/selectors.test.tsfrontend/src/business/auth/mappers.test.tsfrontend/src/business/auth/selectors.test.tsfrontend/src/business/campus-attendance/mappers.test.tsfrontend/src/business/campus-attendance/printReport.test.tsfrontend/src/business/campus-attendance/selectors.test.tsfrontend/src/business/campuses/mappers.test.tsfrontend/src/business/classroom-support/selectors.test.tsfrontend/src/business/classroom-timer/selectors.test.tsfrontend/src/business/communications/selectors.test.tsfrontend/src/business/community/selectors.test.tsfrontend/src/business/dashboard/selectors.test.tsfrontend/src/business/director-dashboard/selectors.test.tsfrontend/src/business/esa-funding/selectors.test.tsfrontend/src/business/frame/mappers.test.tsfrontend/src/business/frame/selectors.test.tsfrontend/src/business/personality/mappers.test.tsfrontend/src/business/personality/selectors.test.tsfrontend/src/business/policies/mappers.test.tsfrontend/src/business/policies/selectors.test.tsfrontend/src/business/safety-quiz/mappers.test.tsfrontend/src/business/safety-quiz/selectors.test.tsfrontend/src/business/sign-language/selectors.test.tsfrontend/src/business/staff-attendance/mappers.test.tsfrontend/src/business/staff-attendance/selectors.test.tsfrontend/src/business/top-bar/selectors.test.tsfrontend/src/business/user-progress/mappers.test.tsfrontend/src/business/vocational/selectors.test.tsfrontend/src/business/walkthrough/mappers.test.tsfrontend/src/business/walkthrough/selectors.test.tsfrontend/src/business/walkthrough/validators.test.tsfrontend/src/business/zones/selectors.test.tsfrontend/src/shared/api/auth.test.tsfrontend/src/shared/api/campusAttendance.test.tsfrontend/src/shared/api/campuses.test.tsfrontend/src/shared/api/communications.test.tsfrontend/src/shared/api/contentCatalog.test.tsfrontend/src/shared/api/documents.test.tsfrontend/src/shared/api/frame.test.tsfrontend/src/shared/api/httpClient.test.tsfrontend/src/shared/api/personality.test.tsfrontend/src/shared/api/safetyQuizResults.test.tsfrontend/src/shared/api/staffAttendance.test.tsfrontend/src/shared/api/userProgress.test.tsfrontend/src/shared/api/walkthrough.test.tsfrontend/src/shared/architecture/import-boundaries.test.tsfrontend/src/shared/business/apiListRows.test.tsfrontend/src/shared/business/queryState.test.tsfrontend/src/shared/constants/moduleRoutes.test.tsfrontend/src/shared/errors/errorMessages.test.ts
These tests verify import-boundary enforcement, centralized network access through shared/api/httpClient, alias-only source imports, required API contract-test coverage, HTTP client request normalization, cookie-backed auth refresh behavior, JSON body serialization, empty response handling, backend error propagation, API wrapper endpoint/query/body contracts, shared list/query/error helpers, route config, module route metadata, module access correction, sidebar navigation selectors, mobile sidebar overlay visibility, auth display/profile mapping, signup validation, campus mapping, dashboard and director dashboard selectors, classroom support selectors, timer formatting/progress/threshold parsing, DTO mapping, FRAME edit access, campus attendance mapping, calculations, and printable report output, staff attendance mapping and rollups, walkthrough create DTO mapping, walkthrough filtering, walkthrough check-in stats/history mapping, walkthrough scoring, generated summaries, repeated low-rating flags, communication role visibility, community catalog filtering and stats, ESA funding selectors, policy mapping/filtering/validation, safety quiz compliance mapping and editable payload validation, sign language selectors, top bar display selectors, user progress normalization, vocational zip/category/search/stat calculations, zones selectors, personality DTO mapping, personality distribution grouping, EI thresholds, personality quiz progress, and MBTI-derived communication guidance.
The personality selector tests caught and now guard against a grouping defect where S/J and S/P types were classified from the third code character instead of the fourth code character.
The import-boundary tests enforce the three-layer dependency direction:
- API modules must not import business or view modules.
- Business modules must not import view modules.
- View modules must not call
frontend/src/shared/api/directly. - Source imports must use the configured
@alias instead of relative paths. - Direct
fetchcalls must stay centralized infrontend/src/shared/api/httpClient.ts. - Runtime data access must stay centralized in the shared API layer.
- Every runtime module in
frontend/src/shared/api/must have a colocated.test.tscontract test.
Current Smoke Coverage
Playwright smoke tests live under:
frontend/tests/e2e/app-shell.e2e.ts
The current smoke suite covers:
- teacher guest access to staff modules and absence of director-only modules;
- restricted executive route redirect for teacher guests;
- director guest access to director and walk-through navigation;
- superintendent guest access persistence after navigating between executive modules.
Backend-Seeded Content E2E Coverage
Backend-seeded content tests live under:
frontend/tests/e2e/content-catalog.seeded.e2e.ts
The seeded suite is intentionally excluded from default npm run test:e2e through frontend/playwright.config.ts. Run it with:
VITE_BACKEND_API_URL=http://localhost:8080/api npm run test:e2e:content
Prerequisites:
- backend database migrations have run;
- backend database seeders have run;
- backend server is running at
VITE_BACKEND_API_URL.
The seeded suite verifies the minimum content catalog seed set through the public backend API, then renders classroom timer, classroom support, sign language, and zones routes with UI assertions based on the live backend response.
Rules For New Tests
- Prefer testing selectors, mappers, validators, and calculations before rendering full components.
- Cover shared API/client behavior with mocked
fetch; do not call a live backend from unit tests. - Keep import-boundary tests updated when adding a new top-level layer directory.
- Keep tests deterministic: no live backend, no network, and no current-time dependency unless the current date is injected.
- Use typed fixtures instead of
anyor unsafe casts. - Add React/hook tests only when a workflow cannot be verified through pure functions.
- Keep backend-free Playwright smoke tests focused on high-value role/navigation workflows.
- Put live backend/database assertions only in explicit seeded suites such as
test:e2e:content.