spawn/packages/cli/src/__tests__
A 4e1467a521
fix: remove broken clone_cli() — go straight to pre-built binary (#1873)
* fix: remove broken clone_cli() — go straight to pre-built binary

The clone_cli() function (added before the monorepo migration, PR #1853)
only fetches top-level .ts files via the GitHub Contents API. Since the
monorepo reorganised source code into subdirectories (aws/, fly/, hetzner/,
shared/, etc.), clone_cli() silently downloads an incomplete source tree.
bun run build then always fails because cross-directory imports cannot
resolve, and the installer falls through to the pre-built binary anyway.

Every install was burning ~12 unnecessary GitHub API requests (rate-limited
at 60/hr for unauthenticated clients) and several seconds of wasted bun
install + failed build time.

Fix: remove clone_cli() entirely, replace build_and_install() with a
direct binary download. Behaviour is identical for all users (binary path
was already the universal outcome); installs are now faster and cheaper on
the API rate limit.

Agent: code-health
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test: update install.sh tests for simplified binary-only installer

Remove tests for clone_cli() and source builds which were removed in
the parent commit. Add tests verifying the direct binary download
approach and asserting that the old clone/build code is gone.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* style: fix biome format errors in commands.ts and duplicate-detection test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 01:19:30 -08:00
..
aws.test.ts feat: Result monad in shared + Claude Code fixtures + SPA Result adoption (#1858) 2026-02-23 22:48:51 -08:00
check-entity-messages.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
check-entity.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
clear-history.test.ts style: enforce separated type imports via biome (#1870) 2026-02-24 00:16:03 -08:00
cloud-credentials.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
cloud-info.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
cmd-interactive.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
cmd-listing-output.test.ts style: enforce separated type imports via biome (#1870) 2026-02-24 00:16:03 -08:00
cmdlast.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
cmdlist-integration.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
cmdrun-duplicate-detection.test.ts fix: remove broken clone_cli() — go straight to pre-built binary (#1873) 2026-02-24 01:19:30 -08:00
cmdrun-happy-path.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
commands-cloud-info.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
commands-display.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
commands-error-paths.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
commands-exported-utils.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
commands-name-suggestions.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
commands-output.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
commands-resolve-run.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
commands-swap-resolve.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
commands-update-download.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
commands.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
credential-hints.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
custom-flag.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
do-oauth.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
download-and-failure.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
fly.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
fuzzy-key-matching.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
history-trimming.test.ts style: enforce separated type imports via biome (#1870) 2026-02-24 00:16:03 -08:00
history.test.ts fix: replace 9 CommonJS require() calls with ESM import in history test (#1871) 2026-02-24 00:16:22 -08:00
install-script-validation.test.ts fix: remove broken clone_cli() — go straight to pre-built binary (#1873) 2026-02-24 01:19:30 -08:00
integration.test.ts style: enforce separated type imports via biome (#1870) 2026-02-24 00:16:03 -08:00
manifest-cache-lifecycle.test.ts style: enforce separated type imports via biome (#1870) 2026-02-24 00:16:03 -08:00
manifest-helpers.test.ts style: enforce separated type imports via biome (#1870) 2026-02-24 00:16:03 -08:00
manifest-integrity.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
manifest-type-contracts.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
manifest-validation.test.ts style: enforce separated type imports via biome (#1870) 2026-02-24 00:16:03 -08:00
manifest.test.ts style: enforce separated type imports via biome (#1870) 2026-02-24 00:16:03 -08:00
matrix-compact-footer.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
parse.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
preflight-credentials.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -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 feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
README.md feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
resolve-prompt.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
run-path-credential-display.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
script-failure-guidance.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
security-connection-validation.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
security-edge-cases.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
security-encoding.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
security.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
ssh-keys.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
test-helpers.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08:00
unknown-flags.test.ts feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -08: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 feat: Bun workspace monorepo — packages/cli + packages/shared (#1853) 2026-02-23 22:07:05 -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