Files
ccs/tests
Kai (Tam Nhu) Tran 3fa4a342f9 test(bar): harden bar-probe auth coverage; drop dead proxy shim (#1555)
* test(bar): cover socket-level 401/403 auth detection and liveness-poll rogue rejection

Add two new describe blocks to bar-command.test.ts:

1. `defaultFindRunningServer: socket-level 401/403 classifies authRequired=true`
   Drives `net.connect` via mock.module('net') to verify that status lines
   401 and 403 off the wire set authRequired=true.  A correct-token 200 must
   not set authRequired.  Prior tests bypassed the real status-line parser by
   injecting authRequired via deps; these tests couple to the actual branch.

2. `defaultWaitForServerLive: rogue 200 without matching token is rejected`
   Uses the same net mock pattern to verify that a 200 carrying a wrong
   x-ccs-bar-token never causes the liveness poll to resolve (rogue reflector
   cannot pass).  Correct token resolves immediately.

Export `defaultWaitForServerLive` from launch-subcommand.ts so the direct
unit test can import it without forcing a full handleBarLaunch invocation.

Both test groups are behavior-coupled: removing the relevant branch in
production causes the tests to fail (verified under mutation).

* refactor(bar): drop dead ensureLoopbackNoProxy proxy shim

The probe now uses raw net.connect() which never consults proxy env vars
(undici was fully removed in an earlier PR).  ensureLoopbackNoProxy()
permanently mutated process-wide NO_PROXY/no_proxy on every discovery call
with no effect on the actual network path.

Verified zero remaining references to ensureLoopbackNoProxy outside the
declaration and call site that are now removed.
2026-06-16 09:30:01 -04:00
..

CCS Test Suite

Organization

tests/
├── unit/              # Module unit tests (Mocha)
│   ├── glmt/          # Legacy GLMT transformer/internal compatibility tests
│   └── delegation/    # Delegation module tests
├── npm/               # npm package tests (Mocha)
├── native/            # Native installation tests (bash/PowerShell)
│   ├── unix/          # Unix/Linux/macOS tests
│   └── windows/       # Windows PowerShell tests
├── integration/       # Integration + smoke tests
└── shared/            # Shared utilities
    ├── fixtures/      # Test configuration and environment
    ├── unit/          # Helper function tests
    ├── helpers.sh     # Bash test utilities
    └── test-data.js   # Test data for npm tests

Running Tests

bun run test           # All automated tests (unit + integration + npm)
bun run test:unit      # Unit tests only
bun run test:npm       # npm package tests
bun run test:native    # Native Unix tests (bash)

Test Categories

Unit Tests (unit/)

Module-level tests using Mocha framework:

  • unit/glmt/ - Legacy transformer internals kept for Cursor translation compatibility
  • unit/delegation/ - Permission mode, session manager, result formatter

npm Tests (npm/)

npm package functionality tests using Mocha:

  • postinstall.test.js - Postinstall behavior
  • cli.test.js - CLI argument parsing
  • cross-platform.test.js - Cross-platform compatibility
  • special-commands.test.js - Integration tests

Native Tests (native/)

Installation tests for curl|bash (Unix) and irm|iex (Windows):

  • native/unix/edge-cases.sh - Unix edge case tests
  • native/windows/edge-cases.ps1 - Windows edge case tests

Integration Tests (integration/)

Integration and smoke coverage for scenarios that exercise multiple layers:

  • Automated *.test.ts files run as part of bun run test:all and CI
  • Shell and standalone probe scripts remain on-demand for targeted debugging
  • cursor-daemon-lifecycle.test.ts - local daemon process + HTTP smoke coverage
  • image-analyzer-hook.test.ts - hook integration coverage
  • glmt-integration-test.sh - legacy GLMT compatibility smoke probe
  • symlink-chain-test.sh - Symlink chain handling
  • ux-integration-test.sh - CLI UX integration

Adding New Tests

  • Unit tests: Add to unit/<module>/ for isolated module behavior
  • npm tests: Add to npm/ for package behavior
  • Native tests: Add to native/unix/ or native/windows/
  • Integration tests: Add automated cross-layer smoke coverage to integration/*.test.ts