Skip to content

test(cli): add unit tests for PM/SCM commands and cliCommandFactory#944

Merged
aaight merged 1 commit intodevfrom
feature/unit-tests-pm-scm-cli-commands
Mar 17, 2026
Merged

test(cli): add unit tests for PM/SCM commands and cliCommandFactory#944
aaight merged 1 commit intodevfrom
feature/unit-tests-pm-scm-cli-commands

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 17, 2026

Summary

Closes https://trello.com/c/lyc2vG0V/463-as-a-developer-i-want-unit-tests-for-pm-scm-tool-commands-and-clicommandfactory-so-that-agent-tool-coverage-gaps-are-closed

  • Add unit tests for 7 PM CLI commands: read-work-item, list-work-items, move-work-item, delete-checklist-item, update-checklist-item, create-work-item, post-comment
  • Add unit tests for 8 SCM CLI commands: get-pr-details, get-pr-diff, get-pr-checks, get-pr-comments, get-ci-run-logs, post-pr-comment, reply-to-review-comment, update-pr-comment
  • Add unit tests for cliCommandFactory covering all flag types, gadgetOnly exclusion, file-input resolution, owner/repo auto-resolution, and JSON output format

New test files

  • tests/unit/cli/pm/pm-commands.test.ts — 19 tests
  • tests/unit/cli/scm/scm-commands.test.ts — 24 tests
  • tests/unit/cli/cli-command-factory.test.ts — 19 tests

Test plan

  • All 62 new tests pass
  • Full unit test suite passes (3514 tests across 191 files)
  • Lint passes (biome check clean)
  • TypeScript type check passes (zero errors)

Key decisions

  • Used makeMockConfig() factory function (not a shared const) so each test gets a fresh runHook mock that isn't cleared by vi.restoreAllMocks() in afterEach
  • Mocked credential-scoping dependencies (withGitHubToken, withTrelloCredentials, withJiraCredentials, createPMProvider, withPMProvider) to isolate CLI command logic — matching the pattern from file-input-flags.test.ts
  • Set CASCADE_REPO_OWNER/CASCADE_REPO_NAME env vars in beforeEach for SCM tests that use auto-resolved owner/repo
  • The readWorkItemDef defines includeComments with default: true, so tests verify the boolean flag correctly passes true by default and false with --no-includeComments

🤖 Generated with Claude Code

🕵️ claude-code · claude-sonnet-4-6 · run details

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

LGTM — Well-structured test suite that closes coverage gaps for PM/SCM CLI commands and cliCommandFactory. All 62 tests correctly verify CLI → core function wiring, with proper mocking of credential-scoping dependencies and core functions. CI is green.

Code Issues

Nitpick

  • tests/unit/cli/cli-command-factory.test.ts:44 — Unused mockConfig const. The makeMockConfig() factory is correctly used everywhere, but the old const mockConfig on line 44 was left behind as dead code. Minor cleanup opportunity.

🕵️ claude-code · claude-opus-4-6 · run details

@aaight aaight merged commit 7b4cfdb into dev Mar 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants