test(cli): unit tests for plugin command (#794) - #805
Conversation
Covers runPluginAdd happy paths (chart + connector), --export named, --override flag, manifest-collision warning, validator-failure rollback, npm-install rollback, missing --export rollback, broken-import rollback, codegen-failure warning; runPluginList counts + overrides marker; runPluginRemove for chart, connector fallback, not-registered error, and npm-uninstall warning. 15 new tests. CLI unit suite: 201 passing, 9 integration skipped. Closes #794. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR adds a complete test suite for the CLI plugin management commands, covering installation, listing, and removal of external plugins. Tests mock configuration, command execution, manifest operations, and validation—validating happy paths, multiple error/rollback scenarios, and proper output formatting. ChangesPlugin command test coverage
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
…st mock cache The --export test used CHART_PKG which was already dynamically imported in an earlier test with the default-export mock shape. Vitest's module cache returned the cached version, so the per-test vi.doMock re-registration with the named-export shape was silently ignored on CI, causing addToManifest to never be called and the assertion to fail with `undefined is not iterable`. Using a distinct package name sidesteps the cache and matches the actual code path tested (validator + manifest entry recording the --export name). Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
|



Closes #794.
Summary
cli/src/__tests__/commands/plugin.test.ts(15 tests)findProjectRoot,run,output,manifest,validatePluginExport, plus per-test dynamic-import mocks viavi.doMockCoverage
runPluginAdd:
--override→overrides: truein manifest entry--export <name>→ export name in manifest entryrunPluginList:
(overrides)marker renderingrunPluginRemove:
Why
Plugin command is the public extension point for third-party charts/connectors. Shipping v1.0 with the install/validate/rollback pipeline untested was a reputational risk for the plugin ecosystem story.
Test plan
npm -w cli run test→ 201 passing, 9 integration skippednpm -w cli run buildclean🤖 Generated with Claude Code
Summary by CodeRabbit