Skip to content

Architecture: Testing Strategy

Status: Implemented (Layers 1, 2, 3) / In Progress (Layer 4) Reference: ADR 006: Testing Strategy

ChatKcal adopts a Layered Testing Strategy (The Testing Trophy) to ensure reliability without slowing down development.

1. Static Analysis (Layer 1)

  • Tools: ESLint, Prettier.
  • Scope: All files.
  • CI Gate: Must pass before merge.

2. Unit Testing (Layer 2)

  • Tools: Vitest.
  • Scope:
    • Backend: 100% coverage for AppSync Resolvers (appsync/*.js). These are pure JS functions and must be tested logic-heavy.
    • Frontend: Utility functions (dateUtils.js, calculators.js). React Hooks with complex logic.

3. Integration Testing (Layer 3)

  • Tools: Vitest + React Testing Library (RTL).
  • Scope:
    • Components: Verify user interactions (clicks, forms) and rendering.
    • Philosophy: Test behavior, not implementation details.
    • Must Test:
      • Concurrency & Immutability: Verify that the "God Row" (Settings) rejects updates with stale versions, and that Unit definitions are locked once created.

4. Network Integration (Layer 4)

  • Tools: Playwright (Mocked).
  • Scope: Critical User Journeys (e.g., Logging a Meal, Saving Settings).
  • Method: Network Interception. We mock the API responses to verify the frontend correctly handles Loading, Success, Error, and Race Conditions.

5. End-to-End (Smoke Tests)

  • Tools: Playwright (Live).
  • Scope: Critical "Can I Log In?" path only.
  • Method: Hits the real Test Backend. Run sparingly.