Skip to content

test: add Vitest test infrastructure and baseline test coverage #44

Description

@teckedd-code2save

Summary

Add Vitest test infrastructure to Convoy and establish baseline test coverage for core stage execution and state management.

Why

  • Convoy is a deployment agent that writes files, creates PRs, and deploys to Fly.io — operations that are risky to test manually
  • The project has zero automated tests and zero open issues, which means quality gaps are undetected
  • The deterministic core (scanner, picker, author, orchestrator, state store, medic) is well-isolated and highly testable with mocked adapters
  • Tests would prevent regressions in the SQLite state machine, plan execution pipeline, and adapter interfaces
  • The project already has a clean TypeScript setup — adding Vitest requires minimal boilerplate

What to Do

  1. Install Vitest: Add vitest as a dev dependency. Add a test script to package.json.

  2. Create test config: A vitest.config.ts that excludes web/ and demo-app/ from the test scope.

  3. Prioritize core modules for initial coverage:

    • src/core/state.ts — SQLite state store operations (create plan, transition stages, query history). Test schema migration and CRUD operations.
    • src/core/stages/ — Each stage (scan, plan, author, rehearse, canary, promote, observe, medic) should have a test verifying its interface contract and state transitions.
    • src/planner/scanner.ts — File tree scanning logic. Test with fixture directories.
    • src/planner/author.ts — Template-based file authorship. Test that templates produce valid output.
    • src/adapters/fly/runner.ts — Test with mocked flyctl responses. Verify error handling and rollback logic.
  4. CI integration: Update .github/workflows/ci.yml to run npm test on every push and pull request.

Acceptance Criteria

  • vitest in devDependencies
  • vitest.config.ts exists at repo root
  • npm test runs Vitest with at least 3 passing tests
  • Tests cover state store CRUD operations (create plan, read, transition)
  • Tests cover scanner file tree detection with a fixture directory
  • Existing CI workflow runs tests
  • Tests are deterministic (no network calls, no external dependencies)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions