Skip to content

test(definitions): add unit tests for dashboard definitions CLI commands#942

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

test(definitions): add unit tests for dashboard definitions CLI commands#942
aaight merged 1 commit intodevfrom
feature/unit-tests-definitions-cli

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 17, 2026

Summary

  • Add unit tests for all 9 definitions CLI commands: list, show, create, update, delete, export, import, reset, triggers
  • Covers happy paths, JSON output mode, and error/edge cases for each command
  • Tests the import upsert logic (create → conflict → update with --update flag) and agentType resolution from file vs. --agent-type flag
  • Follows the established mock pattern from tests/unit/cli/dashboard/projects/integration-credentials.test.ts and tests/unit/cli/dashboard/agents/agents.test.ts

Test plan

  • definitions list — calls client.agentDefinitions.list.query, table/JSON output, empty list
  • definitions show — passes agent type arg to query, text/JSON output, missing arg error
  • definitions create — reads JSON and YAML files, passes agent-type + definition, JSON output, missing flag error
  • definitions update — passes agent-type with patch from file (JSON/YAML), JSON output, missing flag error
  • definitions delete — passes agent type with --yes, errors without --yes, JSON output, missing arg error
  • definitions export — fetches single or all definitions, YAML/JSON format, --output file, stdout write
  • definitions import (create path) — creates when definition doesn't exist
  • definitions import (upsert path) — falls back to update on conflict with --update flag
  • definitions import — resolves agentType from file, --agent-type flag overrides file, YAML+JSON parsing, errors when agentType missing
  • definitions reset — passes agent type with --yes, errors without --yes, JSON output
  • definitions triggers — passes agent type, displays triggers, JSON output, empty triggers, missing arg error
  • All 39 tests pass: npx vitest run --project unit-core tests/unit/cli/dashboard/definitions/
  • Lint and typecheck pass

Card: https://trello.com/c/DT071HWQ/461-as-a-developer-i-want-unit-tests-for-dashboard-definitions-cli-commands-so-that-agent-definition-management-is-covered

🤖 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.

LGTM — Well-structured unit tests for all 9 definitions CLI commands. The test file follows the established mock pattern from agents.test.ts and integration-credentials.test.ts exactly (module-level mock functions, makeClient() factory, oclifConfig stub, beforeEach for config setup). All 39 tests pass, CI is green.

The test coverage is thorough:

  • Happy paths for all commands (list, show, create, update, delete, export, import, reset, triggers)
  • JSON output mode for each command
  • Error/edge cases (missing required args/flags, empty lists, empty triggers)
  • Import upsert logic (create → conflict → update with --update flag) correctly mirrors the source implementation
  • Agent type resolution precedence (file content vs --agent-type flag override) matches source behavior
  • YAML/JSON file parsing paths both exercised

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

@aaight aaight merged commit 28574df 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