spawn/packages/cli/src/__tests__
A 3911b5bc28
refactor: resolve conflicts — merge packages/shared into packages/cli/src/shared (#2092)
Rebased fix/issue-2083 onto main after commands.ts split (PR #2095).
Key resolutions:
- commands.ts: kept HEAD shim (re-exports from ./commands/index.ts)
- package.json: kept PR version 0.12.0 without @openrouter/spawn-shared dep
- Fixed @openrouter/spawn-shared imports in commands/shared.ts, commands/update.ts,
  and __tests__/orchestrate.test.ts that were added after the PR branched

All 1390 tests pass, biome lint clean.

Agent: pr-maintainer

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 22:05:41 -08:00
..
aws.test.ts fix: replace module-level process.env.HOME with homedir() in config paths (#2026) 2026-02-28 12:54:12 -08:00
check-entity-messages.test.ts test: centralize @clack/prompts mock in test-helpers.ts (#2090) 2026-03-01 20:27:24 -08:00
check-entity.test.ts test: Remove duplicate and theatrical tests (#2085) 2026-03-01 20:41:40 -05:00
clear-history.test.ts test: centralize @clack/prompts mock in test-helpers.ts (#2090) 2026-03-01 20:27:24 -08:00
cloud-credentials.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
cloud-init.test.ts test: Remove duplicate and theatrical tests (#2085) 2026-03-01 20:41:40 -05:00
cmd-interactive.test.ts refactor: resolve conflicts — merge packages/shared into packages/cli/src/shared (#2092) 2026-03-01 22:05:41 -08:00
cmd-listing-output.test.ts test: centralize @clack/prompts mock in test-helpers.ts (#2090) 2026-03-01 20:27:24 -08:00
cmdlast.test.ts test: centralize @clack/prompts mock in test-helpers.ts (#2090) 2026-03-01 20:27:24 -08:00
cmdlist-integration.test.ts test: centralize @clack/prompts mock in test-helpers.ts (#2090) 2026-03-01 20:27:24 -08:00
cmdrun-duplicate-detection.test.ts refactor: resolve conflicts — merge packages/shared into packages/cli/src/shared (#2092) 2026-03-01 22:05:41 -08:00
cmdrun-happy-path.test.ts refactor: resolve conflicts — merge packages/shared into packages/cli/src/shared (#2092) 2026-03-01 22:05:41 -08:00
commands-cloud-info.test.ts test: centralize @clack/prompts mock in test-helpers.ts (#2090) 2026-03-01 20:27:24 -08:00
commands-display.test.ts test: centralize @clack/prompts mock in test-helpers.ts (#2090) 2026-03-01 20:27:24 -08:00
commands-error-paths.test.ts refactor: resolve conflicts — merge packages/shared into packages/cli/src/shared (#2092) 2026-03-01 22:05:41 -08:00
commands-exported-utils.test.ts refactor: Remove dead code and stale references (#2017) 2026-02-28 02:07:48 -08:00
commands-name-suggestions.test.ts test: centralize @clack/prompts mock in test-helpers.ts (#2090) 2026-03-01 20:27:24 -08:00
commands-resolve-run.test.ts refactor: resolve conflicts — merge packages/shared into packages/cli/src/shared (#2092) 2026-03-01 22:05:41 -08:00
commands-swap-resolve.test.ts refactor: resolve conflicts — merge packages/shared into packages/cli/src/shared (#2092) 2026-03-01 22:05:41 -08:00
commands-update-download.test.ts refactor: resolve conflicts — merge packages/shared into packages/cli/src/shared (#2092) 2026-03-01 22:05:41 -08:00
credential-hints.test.ts refactor: Remove dead code and stale references (#2017) 2026-02-28 02:07:48 -08:00
custom-flag.test.ts fix(hetzner): add SPAWN_CUSTOM guard to promptServerType (#2065) 2026-03-01 12:41:32 -05:00
download-and-failure.test.ts refactor: resolve conflicts — merge packages/shared into packages/cli/src/shared (#2092) 2026-03-01 22:05:41 -08:00
fuzzy-key-matching.test.ts refactor: Remove dead code and stale references (#2017) 2026-02-28 02:07:48 -08:00
history-trimming.test.ts refactor: Remove dead code and stale references (#2017) 2026-02-28 02:07:48 -08:00
history.test.ts test: Remove duplicate and theatrical tests (#2058) 2026-03-01 08:20:44 -05:00
manifest-cache-lifecycle.test.ts test: Remove duplicate and theatrical tests (#2047) 2026-03-01 00:11:48 -05:00
manifest-integrity.test.ts test: Remove duplicate and theatrical tests (#2020) 2026-02-28 07:49:55 -05:00
manifest-type-contracts.test.ts test: Remove duplicate and theatrical tests (#2058) 2026-03-01 08:20:44 -05:00
manifest.test.ts test: Remove duplicate and theatrical tests (#2020) 2026-02-28 07:49:55 -05:00
orchestrate.test.ts refactor: resolve conflicts — merge packages/shared into packages/cli/src/shared (#2092) 2026-03-01 22:05:41 -08:00
parse.test.ts refactor: resolve conflicts — merge packages/shared into packages/cli/src/shared (#2092) 2026-03-01 22:05:41 -08:00
preflight-credentials.test.ts test: centralize @clack/prompts mock in test-helpers.ts (#2090) 2026-03-01 20:27:24 -08:00
preload.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
prompt-file-security.test.ts test: fix always-pass and try/catch anti-patterns in test suite (#1962) 2026-02-26 16:16:04 -05:00
README.md docs: update __tests__/README.md to reflect current test structure (#2098) 2026-03-02 00:04:53 -05:00
run-path-credential-display.test.ts test: centralize @clack/prompts mock in test-helpers.ts (#2090) 2026-03-01 20:27:24 -08:00
script-failure-guidance.test.ts refactor: Remove dead code and stale references (#2017) 2026-02-28 02:07:48 -08:00
security-connection-validation.test.ts fix(security): replace validateLaunchCmd blocklist with allowlist (#2053) 2026-03-01 03:12:27 -05:00
security-edge-cases.test.ts test: Remove duplicate and theatrical tests (#2070) 2026-03-01 15:53:27 -05:00
security-encoding.test.ts refactor: Remove dead code and stale references (#2017) 2026-02-28 02:07:48 -08:00
security.test.ts test: fix always-pass and try/catch anti-patterns in test suite (#1962) 2026-02-26 16:16:04 -05:00
ssh-keys.test.ts test: centralize @clack/prompts mock in test-helpers.ts (#2090) 2026-03-01 20:27:24 -08:00
test-helpers.ts test: centralize @clack/prompts mock in test-helpers.ts (#2090) 2026-03-01 20:27:24 -08:00
unknown-flags.test.ts test: consolidate wasteful one-per-flag tests in unknown-flags suite (#2029) 2026-02-28 20:42:04 +00:00
update-check.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
with-retry-result.test.ts test: Remove duplicate and theatrical tests (#2009) 2026-02-28 00:08:57 -08:00

CLI Tests

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

Test Runner

Tests use Bun's built-in test runner (bun:test). Do NOT use vitest.

# Run all tests
bun test

# Run a specific file
bun test src/__tests__/manifest.test.ts

Test Files

Core manifest

  • manifest.test.tsagentKeys, cloudKeys, matrixStatus, countImplemented, loadManifest (cache/network)
  • manifest-integrity.test.ts — Structural validation: script files exist for implemented entries, no orphans
  • manifest-type-contracts.test.ts — Field type precision for every agent/cloud in the real manifest
  • manifest-cache-lifecycle.test.ts — Cache TTL, expiry, forced refresh

Commands: happy paths

  • cmdrun-happy-path.test.ts — Successful download, history recording, env var passing
  • cmd-interactive.test.ts — Interactive agent/cloud selection flow
  • cmd-listing-output.test.tscmdMatrix, cmdAgents, cmdClouds output formatting
  • cmdlast.test.tscmdLast: history display and resumption
  • cmdlist-integration.test.tscmdList with real history records
  • commands-display.test.tscmdAgentInfo (happy path), cmdHelp
  • commands-cloud-info.test.tscmdCloudInfo display
  • commands-update-download.test.tscmdUpdate, script download and execution

Commands: error paths

  • commands-error-paths.test.ts — Validation failures, unknown agents/clouds, prompt rejection
  • commands-name-suggestions.test.ts — Display name typo suggestions in errors
  • commands-swap-resolve.test.tsdetectAndFixSwappedArgs, resolveAndLog
  • commands-resolve-run.test.ts — Display name resolution in cmdRun
  • cmdrun-duplicate-detection.test.ts--name collision detection

Commands: utilities

  • commands-exported-utils.test.tsparseAuthEnvVars, getImplementedAgents, getMissingClouds, getErrorMessage, etc.
  • script-failure-guidance.test.tsgetScriptFailureGuidance, getSignalGuidance, buildRetryCommand
  • download-and-failure.test.ts — Download fallback pipeline, failure reporting
  • run-path-credential-display.test.tsprioritizeCloudsByCredentials, run-path validation

Security

  • security.test.tsvalidateIdentifier, validateScriptContent, validatePrompt (core cases)
  • security-edge-cases.test.ts — Boundary conditions and character-level edge cases
  • security-encoding.test.ts — Encoding edge cases, stripDangerousKeys
  • security-connection-validation.test.tsvalidateConnectionIP, validateUsername, validateServerIdentifier, validateLaunchCmd
  • prompt-file-security.test.tsvalidatePromptFilePath, validatePromptFileStats

Infrastructure

  • manifest-cache-lifecycle.test.ts — Cache lifecycle: write, read, expiry, forced refresh
  • history.test.ts — History read/write
  • history-trimming.test.ts — History trimming at size limits
  • clear-history.test.tsclearHistory, cmdListClear
  • ssh-keys.test.ts — SSH key discovery, generation, fingerprinting
  • update-check.test.ts — Auto-update check logic
  • with-retry-result.test.tswithRetry, wrapSshCall, Result constructors
  • orchestrate.test.tsrunOrchestration

Parsing and type utilities

  • parse.test.tsparseJsonWith, parseJsonRaw
  • fuzzy-key-matching.test.tsfindClosestKeyByNameOrKey, levenshtein, findClosestMatch, resolveAgentKey, resolveCloudKey
  • unknown-flags.test.ts — Unknown flag detection, KNOWN_FLAGS, expandEqualsFlags
  • custom-flag.test.ts--custom flag for AWS, GCP, Hetzner, DigitalOcean
  • credential-hints.test.tscredentialHints
  • cloud-credentials.test.tshasCloudCredentials
  • preflight-credentials.test.tspreflightCredentialCheck

Cloud-specific

  • aws.test.ts — AWS credential cache, SigV4 signing helpers
  • cloud-init.test.tsgetPackagesForTier, needsNode, needsBun, NODE_INSTALL_CMD
  • check-entity.test.ts / check-entity-messages.test.ts — Entity validation

Support files (not test files)

  • test-helpers.ts — Shared fixtures: createMockManifest, mockClackPrompts, setupTestEnvironment, etc.
  • preload.ts — Global test setup (temp dir isolation, env sandboxing)