Skip to content

Test infrastructure plan review: key gaps, sequencing fixes, and week-1 execution plan #17

Description

@figitaki

Summary

The test infrastructure plan is directionally strong (risk-first tiers, Vitest, in-memory SQLite strategy), but it needs a few concrete additions to avoid test drift and execution blockers.

Strengths

  • Clear risk-based sequencing (pure logic before infra-heavy tests)
  • Good framework fit (Vitest in a Vite monorepo)
  • Pragmatic DB approach (better-sqlite3 + real migrations)
  • Concrete acceptance criteria and implementation intent

Priority Gaps / Risks

  1. No CI gate for tests
    • Add required pnpm test check in PR workflow immediately.
  2. Cloudflare/Hono runtime mocking is underspecified
    • Define test harness for c.env bindings (D1/KV/env) and request testing.
  3. No fixture/factory pattern
    • Add shared test fixtures/builders for users/credentials/sessions.
  4. Durable Objects strategy too vague
    • Pick one path (miniflare or @cloudflare/vitest-pool-workers) and codify setup/teardown.
  5. Error-path testing underdefined
    • Add negative-path tests (401/403/500, invalid tokens, missing resources).
  6. No integration-flow coverage
    • Add at least one thin end-to-end path (login → credential store → callback).

Recommended Changes

1) Add CI enforcement now

  • Create test.yml running pnpm test on PR + push.
  • Mark test workflow required before merge.

2) Lock the test harness choices

  • Document runtime choice for worker tests (node + mocks vs workers runtime).
  • Provide one canonical helper for test app/env construction.

3) Add fixtures + DB isolation utilities

  • __tests__/fixtures.ts for common entities.
  • createTestDB() helper with migrations.
  • Explicit isolation strategy (fresh DB per test or txn rollback).

4) Re-sequence execution to reduce blockers

Recommended order:

  1. Errors
  2. Crypto
  3. DB helpers
  4. Credentials service
  5. OAuth service
  6. Auth middleware
  7. Route handlers
  8. Durable Objects

This Week Plan (Concrete)

  • Install/configure Vitest workspace
  • Add DB test helper + migration bootstrap
  • Implement errors + crypto tests
  • Implement sessions + credentials tests (incl. error paths)
  • Add CI test workflow and require passing status
  • Document testing conventions in repo

Definition of Done (Phase 1)

  • pnpm test green locally and in CI
  • Core critical-path tests present (errors/crypto/db/credentials)
  • Stable, repeatable test setup documented
  • Team can add new tests without re-solving harness questions

Metadata

Metadata

Assignees

No one assigned

    Labels

    ciRelated to our GitHub actions workflows.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions