Skip to content

test(cli): the four *AllUseCase orchestrators are the least-tested, most-used code in the project #467

Description

@blafourcade

Problem

doctor-all-use-case.ts (13.3% line coverage), restore-all-use-case.ts (15.2%), status-all-use-case.ts (18.3%), and update-all-use-case.ts (31.8%) are the sole code path for the plain aidd doctor/restore/status/update commands — verified: commands/doctor.ts:17, restore.ts:18, status.ts:17, update.ts:17 call them unconditionally, not behind an opt-in flag.

What's missing

Each fans out across ai/ide/plugin categories with per-category error isolation, but only the trivial empty-project happy path is e2e-tested (tests/e2e/command-matrix-help.e2e.test.ts:230-246). No test exercises actual multi-category drift, partial failure, or RestoreAllUseCase.execute's interactive/force branches (restore-all-use-case.ts:42).

A related gap in the same audit: src/infrastructure/adapters/auth-provider-adapter.ts (61.4% lines, 42.85% functions) — login(), authenticated status(), and verifyConfig are never exercised against the real adapter (existing unit tests use a fake CredentialStore). gh-token-adapter.ts:8's verifyToken, which calls the real GitHub API, has no test for either its success or failure path.

Also: tests/e2e/command-matrix-plugin.e2e.test.ts:179-188 is titled "ai restore exits 0 and restores plugin files when a tracked file is deleted" but never deletes a file, and its assertion (/Restor|Nothing to restore/) matches either outcome — it cannot fail even if plugin restore is completely broken.

Fix

  1. Add integration tests seeding real drift/failures in one category for each *AllUseCase, asserting the aggregate result and per-category error isolation.
  2. Add an integration test for AuthProviderAdapter.login/status against a mocked HTTP layer (success + invalid-token cases), and a unit test for GhTokenAdapter.verifyToken's both branches.
  3. Fix the plugin-restore e2e test to actually delete a file first and assert the specific outcome.

Acceptance criteria

  • Each *AllUseCase has an integration test covering multi-category partial failure
  • AuthProviderAdapter.login/status and GhTokenAdapter.verifyToken are covered for both success and failure
  • The plugin-restore e2e test can actually fail if restore breaks

Found by a tests audit of cli/ — full report: cli/aidd_docs/tasks/2026_07/2026_07_22_audit/tests.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    None yet

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions