Skip to content

[Refactoring] Split src/docker-manager.test.ts into focused test files #2474

@github-actions

Description

@github-actions

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.tsgenerateDockerCompose tests (~3,300 lines → still large but scoped)
  • src/container-lifecycle.test.tsstartContainers, runAgentCommand, stopContainers, fastKillAgentContainer tests (~700 lines)
  • src/cleanup.test.tswriteConfigs, 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 ·

  • expires on Jul 3, 2026, 6:39 AM UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions