test(cli): add runPick unit tests#2336
Conversation
📝 WalkthroughWalkthroughAdds a Vitest suite for ChangesrunPick test coverage
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/cli/src/commands/pick.test.ts (1)
21-128: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd inline comments for all
anyusages and type assertions.The coding guidelines for
**/*.{ts,tsx}require an inline comment explaining everyanyusage and every type assertion. This file usesanyextensively (lines 21, 34, 57, 67, 69, 71, 85, 91, 106, 114, 121, 128) and type assertions viaas any(lines 57, 67, 91, 128) without any inline justification.For mock factory functions, a single comment at the top of each factory (e.g.,
// any: mock constructor uses dynamic this assignment) would satisfy the guideline. Foras anyonrunPickargs, a comment like// as any: test only passes partial CliArgswould suffice.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli/src/commands/pick.test.ts` around lines 21 - 128, Add inline comments explaining every any usage and type assertion in the runPick tests. Place a single justification at the top of each mock factory using dynamic this, and add targeted comments immediately before each as any assertion, including partial runPick arguments and mocked component data; ensure all usages in the test block are covered.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/cli/src/commands/pick.test.ts`:
- Line 126: Restore the console.log spy created in the cancellation test by
calling consoleSpy.mockRestore() at the test’s end or from its afterEach
cleanup, alongside the existing vi.clearAllMocks() handling; use the consoleSpy
variable to ensure the original console.log implementation is reinstated.
---
Nitpick comments:
In `@packages/cli/src/commands/pick.test.ts`:
- Around line 21-128: Add inline comments explaining every any usage and type
assertion in the runPick tests. Place a single justification at the top of each
mock factory using dynamic this, and add targeted comments immediately before
each as any assertion, including partial runPick arguments and mocked component
data; ensure all usages in the test block are covered.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: ac9b54a6-a99e-4fb4-851c-d9dd28ee703f
📒 Files selected for processing (1)
packages/cli/src/commands/pick.test.ts
Description
This PR adds comprehensive unit tests for the interactive picker CLI helper
runPickinsidepackages/cli/src/commands/pick.ts.Related Issue
Closes #2333
Which package(s)?
@termuijs/cli
Type of Change
type:bug)type:feature)type:docs)type:testing)type:refactor)type:design)type:accessibility)type:performance)type:devops)type:security)Checklist
needs-starcheck blocks your merge otherwise.bun vitest runbun run buildbun run typecheckCONTRIBUTING.md.type: short description.markDirty()(if your change affects rendering).anytypes without an inline comment explaining why.GSSoC 2026 Participation
https://gssoc.girlscript.org/profile/Harshithk951Screenshots / Recordings (UI changes)
N/A
Notes for the Reviewer
None
Summary by CodeRabbit