Skip to content

[Refactoring] Split src/cli.test.ts (2,909 lines) by feature area #2541

Description

@github-actions

Refactoring Opportunity

Summary

  • File: src/cli.test.ts
  • Current size: 2,909 lines
  • Responsibilities identified: 15+ distinct test areas under one describe('cli') block

Evidence

The file has a single describe('cli') block covering completely unrelated concerns:

line 9:   describe('domain parsing')
line 41:   describe('domain file parsing')
line 162:  describe('environment variable parsing')
line 231:  describe('secret redaction')
line 306:  describe('log level validation')
line 364:  describe('argument parsing with variadic args')
line 411:  describe('shell argument escaping')
line 476:  describe('work directory generation')
line 498:  describe('volume mount parsing')
line 672:  describe('IPv4 validation')
line 696:  describe('IPv6 validation')
line 728:  describe('DNS servers parsing')
line 771:  describe('parseDnsOverHttps')
line 805:  describe('isAgentImagePreset')
line 847:  describe('AGENT_IMAGE_PRESETS')
line 855:  describe('validateAgentImage')
line 1066: describe('processAgentImageOption')

Many of these test utility functions that have already been extracted to separate modules (domain-utils.ts, option-parsers.ts, dns-resolver.ts) — their tests should live alongside those modules.

Proposed Split

  • src/domain-utils.test.ts — domain parsing, domain file parsing, subdomain tests
  • src/option-parsers.test.ts — volume mount parsing, DNS parsing, image validation, shell escaping
  • src/dns-resolver.test.ts — DNS servers parsing, DoH parsing, DEFAULT_DNS_SERVERS
  • src/cli.test.ts — remaining tests for CLI argument handling, log level, work directory (~400 lines)

Effort Estimate

Low — test boundaries are clear and follow existing module extraction in the source. Most test groups are already independent.

Benefits

  • Tests are co-located with the modules they test (standard convention)
  • Each module's test file is navigable in isolation
  • Faster feedback when editing a specific utility module
  • Reduces cognitive overhead: cli.test.ts currently tests things that aren't in cli.ts

Detected by Refactoring Scanner workflow. Run date: 2026-05-05

Generated by Refactoring Opportunity Scanner · ● 350.4K ·

  • expires on Jul 4, 2026, 6:32 AM UTC

Metadata

Metadata

Assignees

Type

No type

Fields

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