refactor: split cli.test.ts by feature area into co-located test files#2557
refactor: split cli.test.ts by feature area into co-located test files#2557
Conversation
|
| Metric | Base | PR | Delta |
|---|---|---|---|
| Lines | 86.45% | 86.53% | 📈 +0.08% |
| Statements | 86.38% | 86.46% | 📈 +0.08% |
| Functions | 90.61% | 80.51% | 📉 -10.10% |
| Branches | 79.23% | 79.27% | 📈 +0.04% |
📁 Per-file Coverage Changes (1 files)
| File | Lines (Before → After) | Statements (Before → After) |
|---|---|---|
src/container-lifecycle.ts |
86.1% → 87.2% (+1.09%) | 86.3% → 87.4% (+1.08%) |
Coverage comparison generated by scripts/ci/compare-coverage.ts
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR refactors the CLI unit test suite by splitting the previously monolithic src/cli.test.ts into smaller, feature-focused test files co-located with their corresponding modules. This improves test organization and makes it easier to maintain and extend coverage as the CLI continues to grow.
Changes:
- Added dedicated test suites for
domain-utils,option-parsers, andapi-proxy-config, moving module-specific tests out ofcli.test.ts. - Simplified
cli.test.tsto only cover behavior that lives directly incli.ts(e.g., Commander config, help formatting, secret redaction,handlePredownloadAction). - Extended
dns-resolver.test.tswith direct coverage of theDEFAULT_DNS_SERVERSconstant and updated import style.
Show a summary per file
| File | Description |
|---|---|
| src/option-parsers.test.ts | New, module-scoped tests for option parsing/validation helpers previously tested via cli.test.ts. |
| src/domain-utils.test.ts | New, module-scoped tests for domain parsing, IP validation, agent image validation/presets, and default API targets. |
| src/api-proxy-config.test.ts | New, module-scoped tests for API proxy configuration/validation and GHEC/GHES domain extraction helpers. |
| src/dns-resolver.test.ts | Adds direct assertion for DEFAULT_DNS_SERVERS and imports it directly from dns-resolver. |
| src/cli.test.ts | Reduced to CLI-owned responsibilities (program/help/config, redaction, validateFormat, handlePredownloadAction). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/5 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
| Metric | Base | PR | Delta |
|---|---|---|---|
| Lines | 86.45% | 86.53% | 📈 +0.08% |
| Statements | 86.38% | 86.46% | 📈 +0.08% |
| Functions | 90.61% | 80.51% | 📉 -10.10% |
| Branches | 79.23% | 79.27% | 📈 +0.04% |
📁 Per-file Coverage Changes (2 files)
| File | Lines (Before → After) | Statements (Before → After) |
|---|---|---|
src/container-cleanup.ts |
77.3% → 77.5% (+0.12%) | 77.0% → 77.1% (+0.11%) |
src/container-lifecycle.ts |
86.1% → 87.2% (+1.09%) | 86.3% → 87.4% (+1.08%) |
Coverage comparison generated by scripts/ci/compare-coverage.ts
Smoke Test Results✅ GitHub MCP: api-proxy X-Initiator fix, one-shot-token musl fix Status: PASS
|
🔥 Smoke Test: Copilot BYOK — PASS
Running in BYOK offline mode ( Author:
|
🔬 Smoke Test Results
PR: refactor: split cli.test.ts by feature area into co-located test files Overall: FAIL — pre-step outputs (
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
|
🔮 Codex smoke: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
Smoke Test Results
Overall: FAIL — service containers are not accessible from this environment.
|
Chroot Version Comparison — Smoke Test Results
Overall: ❌ Not all tests passed (Python and Node.js versions differ between host and chroot environment).
|
src/cli.test.tshad grown to 2,909 lines testing 15+ unrelated concerns under a singledescribe('cli')block, including functions already extracted to separate modules (domain-utils.ts,option-parsers.ts,api-proxy-config.ts).Changes
src/domain-utils.test.ts(new) —parseDomains,parseDomainsFile,isValidIPv4/IPv6,validateAgentImage,processAgentImageOption,AGENT_IMAGE_PRESETS,DEFAULT_*_API_TARGETconstantssrc/option-parsers.test.ts(new) —parseEnvironmentVariables,parseVolumeMounts,escapeShellArg/joinShellArgs,parseDnsServers,parseDnsOverHttps,processLocalhostKeyword,buildRateLimitConfig,validateRateLimitFlags,validateAllowHostPorts/ServicePorts,applyHostServicePortsConfig,parseMemoryLimit,parseAgentTimeout,checkDockerHost,formatItem, and related validatorssrc/api-proxy-config.test.ts(new) —validateApiProxyConfig,validateAnthropicCacheTailTtl,validateApiTargetInAllowedDomains,emitApiProxyTargetWarnings,emitCliProxyStatusLogs,warnClassicPATWithCopilotModel,resolveApiTargetsToAllowedDomains(including GHEC/GHES variants),extractGhes/GhecDomains*src/dns-resolver.test.ts(extended) — addeddescribe('DEFAULT_DNS_SERVERS')block, importing directly from./dns-resolverinstead of via dynamic./cliimportsrc/cli.test.ts(reduced 2,909 → 327 lines) — retains only tests for things genuinely incli.ts: secret redaction, log level validation, Commander.js program configuration, argument parsing, work directory generation,validateFormat, help text formatting,handlePredownloadActionThe two duplicate
describeblocks (hasRateLimitOptionsandformatItem) were merged into single blocks with all unique test cases preserved.