Skip to content

test: increase command layer test coverage from 28% to 80%+ #64

@iamfj

Description

@iamfj

Problem

The commands layer has 28.18% statement coverage. 9 of 11 command files have 0% coverage:

Command File Coverage Risk
issues.ts 50.53% High — complex flag validation untested
auth.ts 81.81% Low
comments.ts 0% Medium
cycles.ts 0% Medium
documents.ts 0% Medium — most logic of any read-only command
files.ts 0% Medium
labels.ts 0% Low — simple pass-through
milestones.ts 0% Medium
projects.ts 0% Low — simple pass-through
teams.ts 0% Low — simple pass-through
users.ts 0% Low — simple pass-through

The highest-risk untested code is the issues update flag validation:

  • Mutual exclusivity: --parent-ticket vs --clear-parent-ticket
  • --label-mode requires --labels
  • --clear-labels conflicts with --labels and --label-mode
  • Relation flag mutual exclusivity (5 flags, only 1 allowed)

Approach

Command tests should mock createContext() to return mock gql/sdk clients, then verify:

  1. Flag validation — invalid combinations throw before any API call
  2. Resolver calls — correct identifiers passed to resolvers
  3. Service calls — correct UUIDs and inputs passed to services
  4. OutputoutputSuccess() called with service result

Test template

vi.mock("../../src/common/context.js", () => ({
  createContext: vi.fn(() => ({
    gql: { request: vi.fn() },
    sdk: { sdk: { teams: vi.fn(), issues: vi.fn() } },
  })),
}));

Priority order

  1. issues update — highest complexity, highest risk
  2. issues create — many optional flags with dependencies
  3. documents — has --issue attachment logic, URL extraction
  4. cycles--window flag logic
  5. milestones — project-scoped resolution
  6. Remaining simple commands

Acceptance criteria

  • issues update flag validation: all mutual exclusivity checks tested
  • issues create required flag (--team) tested
  • Every command file has ≥1 happy-path + ≥1 error-path test
  • Overall command coverage ≥70%
  • npm run test:coverage reports improvement

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions