spawn/cli/src/__tests__
A 3030b1d036
fix: revert .profile writes, use explicit PATH in launch commands (#1260)
Stop writing env vars to ~/.profile and ~/.bash_profile — only write to
.bashrc and .zshrc. The .profile approach caused issues because login
shells source it inconsistently across distros, and creating .bash_profile
makes bash -l skip .profile entirely.

Replace `bash -lc claude` launch commands with explicit PATH export +
source pattern across all cloud providers. This ensures claude is found
regardless of shell initialization quirks.

Co-authored-by: lab <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-16 00:43:49 -08:00
..
agent-config-setup.test.ts test: fix agent-config-setup.test.ts - shell mocking for HOME variable substitution (#1195) 2026-02-15 05:16:11 -05:00
agent-env-injection-contract.test.ts feat: wire shared/github-auth.sh into all agent flows (#1216) 2026-02-15 23:00:53 -08:00
agent-info-quickstart.test.ts test: add 55 tests for agent info quick-start display (#1005) 2026-02-13 13:25:26 -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
clear-history.test.ts fix: add confirmation to history clear and improve UX details (#983) 2026-02-13 11:31:01 -08:00
cli-core-edge-cases.test.ts test: fix failing test assertions to match implementations (#1173) 2026-02-14 23:30:27 -05:00
cli-entry-edge-cases.test.ts test: fix outdated error message assertions (#1141) 2026-02-14 16:43:35 -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 fix: correct test expectations to match actual CLI error messages (#1143) 2026-02-14 18:48:03 -05:00
cloud-agent-quickstart.test.ts feat: trim to 9 curated launch clouds, upvote-driven discovery (#1184) 2026-02-15 00:19:39 -08:00
cloud-credentials.test.ts feat: prioritize clouds with detected credentials in interactive picker (#752) 2026-02-12 15:33:14 -08:00
cloud-error-guidance.test.ts feat: trim to 9 curated launch clouds, upvote-driven discovery (#1184) 2026-02-15 00:19:39 -08:00
cloud-info.test.ts feat: trim to 9 curated launch clouds, upvote-driven discovery (#1184) 2026-02-15 00:19:39 -08:00
cloud-lib-api-surface.test.ts test: add cloud lib API surface tests (#852) 2026-02-13 02:09:56 -08:00
cloud-lib-security-conventions.test.ts feat: trim to 9 curated launch clouds, upvote-driven discovery (#1184) 2026-02-15 00:19:39 -08:00
cloud-lib-source-chain.test.ts test: add 343 cloud lib source chain verification tests (#935) 2026-02-13 06:02:06 -08:00
cmd-help-content.test.ts ux: improve CLI help examples and remove duplicate auth text (#1163) 2026-02-14 22:11:42 -05:00
cmd-interactive.test.ts fix(ux): add preflight credential check to interactive mode (#1027) 2026-02-13 18:52:03 -05:00
cmd-listing-output.test.ts fix: improve CLI UX with clearer credential status and help docs (#1012) 2026-02-13 13:53:53 -08:00
cmdlast.test.ts test: add missing coverage for cmdLast (#1176) 2026-02-15 00:08:33 -05: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: fix error message assertions in 7 test files (#1124) 2026-02-14 15:49:12 -05: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-credential-display-internals.test.ts test: add 178 tests for credential display, auth parsing, and internal helpers (#1063) 2026-02-14 01:49:41 -05: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-helpers-edges.test.ts test: add 159 edge-case tests for commands.ts exported helpers (#1051) 2026-02-13 23:37:22 -05:00
commands-exported-utils.test.ts fix: show credential readiness in spawn clouds and relative timestamps in spawn list (#910) 2026-02-13 05:20:04 -08:00
commands-helpers.test.ts fix(ux): show cloud count and credential readiness in interactive agent picker (#1025) 2026-02-13 18:29:25 -05:00
commands-info-details.test.ts feat: trim to 9 curated launch clouds, upvote-driven discovery (#1184) 2026-02-15 00:19:39 -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 test: fix error message assertions in 7 test files (#1124) 2026-02-14 15:49:12 -05: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 test: fix failing test assertions to match implementations (#1173) 2026-02-14 23:30:27 -05: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
credential-display-lines.test.ts test: add 44 tests for credential display functions in dry-run path (#961) 2026-02-13 09:51:49 -08:00
credential-hints.test.ts fix: show specific missing credentials in script failure messages (#813) 2026-02-13 01:45:01 -08:00
credential-prioritization.test.ts test: add 57 tests for credential-based cloud prioritization (PR #752) (#758) 2026-02-12 15:49:29 -08:00
dispatch-extra-args.test.ts fix: improve UX of error messages and status output (#938) 2026-02-13 06:45:04 -08:00
download-and-failure.test.ts test: fix outdated error message assertions (#1141) 2026-02-14 16:43:35 -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(ux): include cloud provider dashboard URLs in script failure and interrupt messages (#1029) 2026-02-13 16:01:57 -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 fix: add defense-in-depth for SPAWN_HOME path validation and manifest JSON sanitization (#984) 2026-02-13 11:37:10 -08:00
index-dispatch-routing.test.ts fix: detect slash notation and suggest correct syntax (#859) 2026-02-13 02:15:59 -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 fix: correct test expectations to match actual CLI error messages (#1143) 2026-02-14 18:48:03 -05:00
index-parsing.test.ts fix: support --flag=value syntax in CLI argument parsing (#826) 2026-02-12 23:55:46 -08:00
install-helpers.test.ts test: Fix manifest consistency and improve test assertions (#1087) 2026-02-14 01:10:03 -08:00
install-script-validation.test.ts fix: align install script tests with actual implementation (#1154) 2026-02-14 20:45:35 -05:00
integration.test.ts fix: Force CI mode for complete Unicode disabling in CLI 2026-02-10 07:35:20 +00:00
key-server.test.ts fix(security): harden weak crypto fallbacks, key validation, and temp paths (#1039) 2026-02-13 21:43:37 -05: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 fix: use buildRetryCommand in spawn list footer to avoid truncated prompts (#819) 2026-02-12 23:52:08 -08:00
list-filter-suggestions.test.ts fix: improve UX for stale manifest cache, list rerun hints, and version info (#805) 2026-02-13 06:09:56 -08:00
list-output-helpers.test.ts test: add 97 tests for list command output helpers (#846) 2026-02-13 06:22:18 -08:00
list-prompt-display.test.ts fix: improve UX for stale manifest cache, list rerun hints, and version info (#805) 2026-02-13 06:09:56 -08:00
list-table-rendering.test.ts fix: improve UX for stale manifest cache, list rerun hints, and version info (#805) 2026-02-13 06:09:56 -08:00
local-cloud-provider-patterns.test.ts test: fix assertions to match actual function behavior (#1104) 2026-02-14 10:42:56 -05: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 feat: trim to 9 curated launch clouds, upvote-driven discovery (#1184) 2026-02-15 00:19:39 -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
oracle-provider-patterns.test.ts test: add 364 tests for Oracle Cloud Infrastructure provider patterns (#1023) 2026-02-13 18:07:41 -05:00
preflight-credentials.test.ts fix: warn about missing credentials before running spawn scripts (#851) 2026-02-13 01:52:41 -08:00
prompt-file-errors.test.ts fix: prevent sensitive file exfiltration via --prompt-file flag (#1024) 2026-02-13 18:30:05 -05:00
prompt-file-security.test.ts test: fix failing test assertions to match implementations (#1173) 2026-02-14 23:30:27 -05:00
quickstart-dashboard-helpers.test.ts test: fix failing test assertions to match implementations (#1173) 2026-02-14 23:30:27 -05: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
run-path-credential-display.test.ts test: add 85 tests for run-path credential display and validation functions (#918) 2026-02-13 05:11:24 -08:00
run-retry-and-display.test.ts test: add 68 tests for run retry logic and display formatting helpers (#945) 2026-02-13 07:24:49 -08:00
script-conventions.test.ts feat: trim to 9 curated launch clouds, upvote-driven discovery (#1184) 2026-02-15 00:19:39 -08:00
script-failure-guidance.test.ts feat: trim to 9 curated launch clouds, upvote-driven discovery (#1184) 2026-02-15 00:19:39 -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 test: fix failing test assertions to match implementations (#1173) 2026-02-14 23:30:27 -05:00
security-encoding.test.ts test: fix assertions to match actual function behavior (#1104) 2026-02-14 10:42:56 -05:00
security.test.ts test: update assertions to match improved error messages (#1109) 2026-02-14 11:49:20 -05:00
shared-common-api-classify.test.ts test: add 51 tests for _classify_api_result and _report_api_failure (#834) 2026-02-13 01:19:31 -08:00
shared-common-api-helpers.test.ts test: add 71 tests for cloud API helper functions in shared/common.sh (#754) 2026-02-12 15:48:46 -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-decomposed-helpers.test.ts test: fix failing test assertions to match implementations (#1173) 2026-02-14 23:30:27 -05:00
shared-common-env-inject.test.ts fix: revert .profile writes, use explicit PATH in launch commands (#1260) 2026-02-16 00:43:49 -08:00
shared-common-error-extraction.test.ts test: add 32 tests for extract_api_error_message in shared/common.sh (#820) 2026-02-12 23:52:27 -08:00
shared-common-error-polling.test.ts test: fix assertions to match actual function behavior (#1104) 2026-02-14 10:42:56 -05: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-input-validation.test.ts test: fix failing test assertions to match implementations (#1173) 2026-02-14 23:30:27 -05:00
shared-common-json-extraction.test.ts test: add 59 tests for JSON extraction helpers in shared/common.sh (#804) 2026-02-13 06:07:50 -08:00
shared-common-logging-utils.test.ts fix: upgrade SSH to StrictHostKeyChecking=accept-new (TOFU) and randomize temp paths (#849) 2026-02-13 02:11:47 -08:00
shared-common-oauth-flow.test.ts test: add 88 tests for OAuth flow functions in shared/common.sh (#843) 2026-02-13 01:22:11 -08:00
shared-common-oauth-retry.test.ts test: fix failing test assertions to match implementations (#1173) 2026-02-14 23:30:27 -05:00
shared-common-oauth-security.test.ts ux: match OAuth callback page to OpenRouter's design theme (#1244) 2026-02-15 23:28:48 -08:00
shared-common-post-session.test.ts feat: trim to 9 curated launch clouds, upvote-driven discovery (#1184) 2026-02-15 00:19:39 -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-ssh-helpers.test.ts test: fix error message assertions in 7 test files (#1124) 2026-02-14 15:49:12 -05:00
shared-common-ssh-key-lifecycle.test.ts test: add 48 tests for SSH key lifecycle functions (#828) 2026-02-12 23:52:22 -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-untested-helpers.test.ts fix: correct test expectations to match actual CLI error messages (#1143) 2026-02-14 18:48:03 -05: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
shared-github-auth.test.ts test: fix failing test assertions to match actual implementation (#1130) 2026-02-14 14:14:33 -08:00
shared-key-request.test.ts test: add 56 tests for shared/key-request.sh credential loading (#1057) 2026-02-14 00:54:00 -05:00
show-info-or-error.test.ts fix: improve CLI error messages for retry commands and unknown names (#777) 2026-02-12 17:19:46 -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
test-infra-sync.test.ts feat: trim to 9 curated launch clouds, upvote-driven discovery (#1184) 2026-02-15 00:19:39 -08:00
time-auth-record-helpers.test.ts test: add 70 tests for time formatting, auth parsing, and record helpers (#963) 2026-02-13 10:18:38 -08:00
trigger-server.test.ts test: add 111 tests for trigger-server security and validation logic (#774) 2026-02-12 16:46:10 -08: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 fix: prevent command injection in update-check reExecWithArgs (#951) 2026-02-13 08:34:04 -08:00
upload-file-security.test.ts feat: trim to 9 curated launch clouds, upvote-driven discovery (#1184) 2026-02-15 00:19:39 -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