spawn/cli/src/__tests__
A 242eb1dde0
test: add 54 tests for env injection, JSON extraction, SSH key, and opencode helpers (#743)
Cover previously untested shared/common.sh functions:
- inject_env_vars_ssh: env var injection via SSH (argument passing, content, permissions)
- inject_env_vars_local: env var injection for container providers (local arg format)
- _extract_json_field: Python-based JSON field extraction with defaults
- check_ssh_key_by_fingerprint: SSH key fingerprint lookup via API
- opencode_install_cmd: robust OpenCode install command generation
- track_temp_file/cleanup_temp_files: secure temp file lifecycle
- validate_resource_name: resource name validation edge cases

Agent: test-engineer

Co-authored-by: A <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
2026-02-12 15:18:57 -08:00
..
agent-config-setup.test.ts test: fix failing assertion and add checkEntity message output tests (#513) 2026-02-11 13:08:45 -08:00
check-entity-messages.test.ts test: fix failing assertion and add checkEntity message output tests (#513) 2026-02-11 13:08:45 -08:00
check-entity.test.ts fix: suggest cross-kind fuzzy matches when args may be swapped with typos (#510) 2026-02-11 12:47:53 -08:00
cli-entry-edge-cases.test.ts feat: store spawn history locally and repurpose spawn list (#486) 2026-02-11 10:01:48 -08:00
cli-pipeline.test.ts refactor: Rename improve to discovery and remove improve CLI command 2026-02-10 16:13:56 +00:00
cli-version-and-dispatch.test.ts test: add CLI version output, dispatch routing, and flag validation tests (#674) 2026-02-12 15:02:52 -08:00
cloud-agent-quickstart.test.ts test: add 25 tests for cloud/agent Quick start and Not-yet-available display (#507) 2026-02-11 12:28:43 -08:00
cloud-info.test.ts fix: Improve UX for local cloud quick-start and env var messaging (#385) 2026-02-11 01:02:45 -08:00
cmd-help-content.test.ts fix: add ENVIRONMENT VARIABLES section to spawn help text (#504) 2026-02-11 12:08:32 -08:00
cmd-interactive.test.ts feat: store spawn history locally and repurpose spawn list (#486) 2026-02-11 10:01:48 -08:00
cmd-listing-output.test.ts test: add 41 tests for cmdMatrix, cmdAgents, cmdClouds listing output (#732) 2026-02-12 15:02:55 -08:00
cmdlist-filter-resolution.test.ts fix: spawn list <cloud> now correctly filters by cloud instead of failing (#563) 2026-02-11 17:54:19 -08:00
cmdlist-integration.test.ts fix: improve spawn list UX with positional filters and long flags (#549) 2026-02-11 15:46:39 -08:00
cmdrun-happy-path.test.ts test: Add cmdRun happy-path pipeline integration tests (#526) 2026-02-11 14:10:58 -08:00
cmdrun-resolution.test.ts test: Add E2E tests for cmdRun argument resolution and swapping (#311) 2026-02-10 18:00:14 -08:00
commands-cloud-info.test.ts fix: Show cloud type and agent notes in info commands (#255) 2026-02-10 15:11:06 -08:00
commands-compact-list.test.ts fix: improve CLI UX for list filters, dry-run URLs, history, and matrix display (#537) 2026-02-11 14:59:31 -08:00
commands-display.test.ts feat: store spawn history locally and repurpose spawn list (#486) 2026-02-11 10:01:48 -08:00
commands-error-paths.test.ts fix: improve spawn list and clouds UX (#491) 2026-02-11 10:34:28 -08:00
commands-exported-utils.test.ts test: Add 57 tests for previously untested exported utility functions (#409) 2026-02-11 01:39:45 -08:00
commands-helpers.test.ts fix: Resolve display names and case-insensitive input in CLI (#306) 2026-02-10 17:37:51 -08:00
commands-info-details.test.ts feat: Add quick-start section to cloud and agent info views (#373) 2026-02-11 00:13:15 -08:00
commands-internal-helpers.test.ts fix: show setup instructions in script failure credential hints (#683) 2026-02-12 13:34:25 -08:00
commands-list-grid.test.ts feat: store spawn history locally and repurpose spawn list (#486) 2026-02-11 10:01:48 -08:00
commands-name-suggestions.test.ts fix: improve fuzzy matching to check display names for better typo suggestions (#414) 2026-02-11 02:06:52 -08:00
commands-output.test.ts feat: store spawn history locally and repurpose spawn list (#486) 2026-02-11 10:01:48 -08:00
commands-resolve-run.test.ts feat: store spawn history locally and repurpose spawn list (#486) 2026-02-11 10:01:48 -08:00
commands-swap-resolve.test.ts fix: improve spawn list and clouds UX (#491) 2026-02-11 10:34:28 -08:00
commands-untested.test.ts refactor: Rename improve to discovery and remove improve CLI command 2026-02-10 16:13:56 +00:00
commands-update-download.test.ts feat: store spawn history locally and repurpose spawn list (#486) 2026-02-11 10:01:48 -08:00
commands-utils.test.ts test: Add 49 tests for command utility functions (commands-utils.test.ts) (#372) 2026-02-11 00:10:04 -08:00
commands.test.ts feat: store spawn history locally and repurpose spawn list (#486) 2026-02-11 10:01:48 -08:00
dispatch-extra-args.test.ts feat: store spawn history locally and repurpose spawn list (#486) 2026-02-11 10:01:48 -08:00
download-and-failure.test.ts feat: store spawn history locally and repurpose spawn list (#486) 2026-02-11 10:01:48 -08:00
dry-run-preview.test.ts fix: improve CLI UX for list filters, dry-run URLs, history, and matrix display (#537) 2026-02-11 14:59:31 -08:00
exec-script-errors.test.ts fix: show cleanup warning when script is interrupted by Ctrl+C (#723) 2026-02-12 15:00:30 -08:00
fuzzy-key-matching.test.ts test: Add 57 tests for findClosestKeyByNameOrKey fuzzy matching (#419) 2026-02-11 02:36:00 -08:00
history-trimming.test.ts test: add 22 tests for history MAX_HISTORY_ENTRIES trimming and boundaries (#541) 2026-02-11 15:18:23 -08:00
history.test.ts test: add 34 tests for history module (loadHistory, saveSpawnRecord, filterHistory) (#487) 2026-02-11 10:10:12 -08:00
index-dispatch-routing.test.ts fix: redirect 'spawn agents <name>' and 'spawn clouds <name>' to info pages (#709) 2026-02-12 15:02:23 -08:00
index-edge-cases.test.ts fix: Show unified agent+cloud suggestions for unknown single-arg commands (#229) 2026-02-10 12:49:44 -08:00
index-main-routing.test.ts test: fix non-TTY test expectations to match actual CLI behavior (#432) 2026-02-11 04:09:53 -08:00
index-parsing.test.ts refactor: Rename improve to discovery and remove improve CLI command 2026-02-10 16:13:56 +00:00
install-helpers.test.ts test: add 46 tests for install.sh helper functions (#720) 2026-02-12 15:02:49 -08:00
install-script-validation.test.ts test: add 83 tests for install.sh script validation (#716) 2026-02-12 15:01:43 -08:00
integration.test.ts fix: Force CI mode for complete Unicode disabling in CLI 2026-02-10 07:35:20 +00:00
list-display.test.ts fix: improve spawn list UX with positional filters and long flags (#549) 2026-02-11 15:46:39 -08:00
list-empty-footer.test.ts test: add 46 tests for list display helpers and unknown command error (#512) 2026-02-11 12:54:52 -08:00
list-filter-suggestions.test.ts fix: improve CLI UX for list filters, dry-run URLs, history, and matrix display (#537) 2026-02-11 14:59:31 -08:00
list-prompt-display.test.ts test: add 31 tests for cmdList prompt display and suggestCloudsForPrompt (#500) 2026-02-11 11:25:32 -08:00
list-table-rendering.test.ts test: add 34 tests for cmdList table rendering and resolveDisplayName (#515) 2026-02-11 13:26:21 -08:00
manifest-cache-lifecycle.test.ts test: Add 52 tests for manifest cache lifecycle edge cases (#117) 2026-02-09 19:50:13 -08:00
manifest-helpers.test.ts test: Add 77 tests covering argument parsing, manifest, and security encoding edge cases (#101) 2026-02-09 10:20:57 -08:00
manifest-integrity.test.ts test: Add manifest integrity tests (26 tests) (#194) 2026-02-10 08:54:52 -08:00
manifest-real-data.test.ts test: Add 1649 tests validating CLI functions against real manifest data (#386) 2026-02-11 01:03:19 -08:00
manifest-type-contracts.test.ts test: add 496 manifest type contract validation tests (#446) 2026-02-11 05:20:13 -08:00
manifest-validation.test.ts test: Add 70 new tests for CLI parsing, manifest validation, and security edge cases (#87) 2026-02-09 09:31:41 -08:00
manifest.test.ts fix: Restore missing imports in test files 2026-02-08 04:47:58 +00:00
matrix-compact-footer.test.ts test: add coverage for compact matrix view and footer rendering (#708) 2026-02-12 15:01:59 -08:00
no-cloud-error-paths.test.ts test: add 24 tests for missing-cloud error paths and suggestCloudsForPrompt (#485) 2026-02-11 09:43:31 -08:00
prompt-file-errors.test.ts test: Add 34 tests for --prompt-file error handling paths (#421) 2026-02-11 02:58:14 -08:00
README.md test: add unit tests for CLI TypeScript implementation 2026-02-08 00:52:12 +00:00
resolve-list-filters.test.ts test: add 75 tests for resolveListFilters and related functions (#724) 2026-02-12 15:02:06 -08:00
resolve-prompt.test.ts refactor: Rename improve to discovery and remove improve CLI command 2026-02-10 16:13:56 +00:00
script-conventions.test.ts test: Add exhaustive shell script convention tests for all 411 scripts (#363) 2026-02-10 23:20:49 -08:00
script-failure-guidance.test.ts fix: restore --prompt in retry command after script failure (#731) 2026-02-12 15:00:46 -08:00
script-syntax.test.ts test: Add 420 bash -n syntax validation tests for all shell scripts (#254) 2026-02-10 15:10:43 -08:00
security-edge-cases.test.ts fix: Remove curl|bash script validation that blocks spawn scripts 2026-02-10 09:40:16 +00:00
security-encoding.test.ts fix: Remove curl|bash script validation that blocks spawn scripts 2026-02-10 09:40:16 +00:00
security.test.ts fix: add log_step for progress messages, fix misleading prompt error (#440) 2026-02-11 04:28:17 -08:00
shared-common-credential-mgmt.test.ts test: add 55 tests for credential management functions in shared/common.sh (#714) 2026-02-12 15:01:44 -08:00
shared-common-env-inject.test.ts test: add 54 tests for env injection, JSON extraction, SSH key, and opencode helpers (#743) 2026-02-12 15:18:57 -08:00
shared-common-helpers.test.ts test: add 39 tests for untested shared/common.sh helper functions (#477) 2026-02-11 08:49:18 -08:00
shared-common-oauth-retry.test.ts refactor: simplify API retry logic and dispatchCommand (#533) 2026-02-11 14:29:37 -08:00
shared-common-server-retry.test.ts test: add 40 tests for get_validated_server_name and API retry logic (#536) 2026-02-11 14:57:56 -08:00
shared-common-token-provider.test.ts test: add 66 tests for ensure_api_token_with_provider credential flow (#729) 2026-02-12 15:01:03 -08:00
shared-common-validators.test.ts fix: improve user-facing messages and error text across CLI and shell scripts (#464) 2026-02-11 07:26:00 -08:00
show-info-or-error.test.ts fix: improve fuzzy matching to check display names for better typo suggestions (#414) 2026-02-11 02:06:52 -08:00
ssh-retry.test.ts fix: retry script execution on transient SSH failures (exit 255) (#706) 2026-02-12 12:13:38 -08:00
test-helpers.ts refactor: security - add input validation and script content checks 2026-02-08 04:46:19 +00:00
unicode-detect.test.ts fix: Remove curl|bash script validation that blocks spawn scripts 2026-02-10 09:40:16 +00:00
unknown-flags.test.ts feat: add --dry-run flag to preview provisioning details (#478) 2026-02-11 08:56:59 -08:00
update-check.test.ts feat: Check for updates on every run, remove 24-hour cache 2026-02-10 07:13:42 +00:00
upload-file-security.test.ts test: add 114 security regression tests for upload_file across all clouds (#465) 2026-02-11 07:26:28 -08:00
validate-implementation-branches.test.ts feat: store spawn history locally and repurpose spawn list (#486) 2026-02-11 10:01:48 -08:00
verb-aliases.test.ts fix: handle common verb aliases (run, launch, start, deploy, exec) in CLI (#516) 2026-02-11 13:26:25 -08:00
version-comparison.test.ts test: Add 46 tests for version comparison logic in update-check.ts (#167) 2026-02-10 07:17:04 -08:00

CLI Tests

This directory contains comprehensive tests for the Spawn CLI TypeScript implementation.

Test Files

manifest.test.ts

Tests for manifest loading, caching, and parsing:

  • Network fetching and fallback behavior
  • Disk cache TTL and invalidation
  • Offline mode with stale cache
  • Agent/cloud key extraction
  • Matrix status checking
  • Implemented combination counting

commands.test.ts

Tests for CLI command handlers:

  • cmdHelp - Help text display
  • cmdList - Matrix table rendering
  • cmdAgents - Agent listing
  • cmdClouds - Cloud provider listing
  • cmdAgentInfo - Agent details with available clouds
  • cmdRun - Script execution with validation and fallback

integration.test.ts

Integration tests for end-to-end workflows:

  • Version command
  • Manifest caching across loads
  • Offline scenarios
  • Agent/cloud key extraction
  • Matrix validation
  • Implementation counting

Running Tests

# Run all tests once
npm test

# Run tests in watch mode
npm run test:watch

# Run with coverage (requires coverage provider)
npm test -- --coverage

Test Coverage

Current coverage targets critical paths:

  • manifest.ts: ~80% coverage of caching, fetching, and parsing logic
  • commands.ts: ~70% coverage of command handlers and validation
  • integration: Basic end-to-end scenarios

Notes

  • Tests use vitest for fast execution with Bun/Node compatibility
  • Mock manifest data is used to avoid network dependencies
  • Cache directory is isolated per test to prevent interference
  • Some tests account for local manifest.json fallback in project directory