Refactoring Opportunity
Summary
- File:
src/docker-manager.test.ts
- Current size: 5,472 lines
- Responsibilities identified: 7+ distinct test suites in one file
Evidence
The test file mirrors the mixed responsibilities of src/docker-manager.ts and is extremely hard to navigate:
| Describe block |
Approx. lines |
subnetsOverlap, validateIdNotInSystemRange, misc utilities |
lines 19–319 |
generateDockerCompose |
lines 320–3634 (~3,300 lines) |
writeConfigs |
lines 3635–3979 |
startContainers |
lines 3980–4179 |
stopContainers / fastKillAgentContainer |
lines 4180–4350 |
runAgentCommand |
lines 4351–4560 |
cleanup |
lines 4561–5472 |
The generateDockerCompose describe block alone is ~3,300 lines — larger than most source files in the repo. It contains nested describes for env file, host access, API proxy sidecar, DNS-over-HTTPS, CLI proxy, NO_PROXY baseline, and more.
Proposed Split
src/docker-manager.test.ts (5,472 lines) could be split to match the proposed source module splits (see issue #2473):
src/host-env.test.ts — utility/host-env function tests (~300 lines)
src/compose-generator.test.ts — generateDockerCompose tests (~3,300 lines → still large but scoped)
src/container-lifecycle.test.ts — startContainers, runAgentCommand, stopContainers, fastKillAgentContainer tests (~700 lines)
src/cleanup.test.ts — writeConfigs, cleanup, collectDiagnosticLogs tests (~700 lines)
Even without splitting the source module, the test file should be split to allow Jest --testPathPattern targeting and faster contributor navigation.
Affected Callers
No imports from test files; splitting is purely organizational. Jest configuration in jest.config.js picks up all *.test.ts files automatically.
Effort Estimate
Medium — mechanical split with shared beforeEach/mock setup that needs careful extraction.
Benefits
- Running
npx jest compose-generator isolates ~3,300 lines of tests vs. running the full 5,472-line file
- Reduces PR diff noise — changes to lifecycle rarely touch compose generation
- Mirrors source structure for easier navigation
Detected by Refactoring Scanner workflow. Run date: 2026-05-04
Generated by Refactoring Opportunity Scanner · ● 233.7K · ◷
Refactoring Opportunity
Summary
src/docker-manager.test.tsEvidence
The test file mirrors the mixed responsibilities of
src/docker-manager.tsand is extremely hard to navigate:subnetsOverlap,validateIdNotInSystemRange, misc utilitiesgenerateDockerComposewriteConfigsstartContainersstopContainers/fastKillAgentContainerrunAgentCommandcleanupThe
generateDockerComposedescribe block alone is ~3,300 lines — larger than most source files in the repo. It contains nested describes for env file, host access, API proxy sidecar, DNS-over-HTTPS, CLI proxy,NO_PROXYbaseline, and more.Proposed Split
src/docker-manager.test.ts(5,472 lines) could be split to match the proposed source module splits (see issue #2473):src/host-env.test.ts— utility/host-env function tests (~300 lines)src/compose-generator.test.ts—generateDockerComposetests (~3,300 lines → still large but scoped)src/container-lifecycle.test.ts—startContainers,runAgentCommand,stopContainers,fastKillAgentContainertests (~700 lines)src/cleanup.test.ts—writeConfigs,cleanup,collectDiagnosticLogstests (~700 lines)Even without splitting the source module, the test file should be split to allow Jest
--testPathPatterntargeting and faster contributor navigation.Affected Callers
No imports from test files; splitting is purely organizational. Jest configuration in
jest.config.jspicks up all*.test.tsfiles automatically.Effort Estimate
Medium — mechanical split with shared
beforeEach/mock setup that needs careful extraction.Benefits
npx jest compose-generatorisolates ~3,300 lines of tests vs. running the full 5,472-line fileDetected by Refactoring Scanner workflow. Run date: 2026-05-04