Skip to content

Refactor oversized cross-cutting tests into slice-local and concern-named files #140

@j3l3n4-bot

Description

@j3l3n4-bot

Problem / context

test/wrapper.test.ts and test/core.test.ts have grown into oversized catch-all files.

That no longer fits the repository's vertical-slice direction. A substantial amount of command-owned behavior is still tested in broad cross-cutting files instead of living with the slice that owns the behavior. That weakens ownership, makes refactors noisier, and makes it harder to see what is truly cross-cutting versus what belongs to a single command slice.

This refactor should move tests toward thinner, more self-sufficient vertical slices while keeping only genuinely shared runtime-boundary behavior in shared test locations.

Desired outcome

Move command-owned tests into the relevant slices where that makes sense, and replace the giant cross-cutting test files with smaller, specifically named files organized by concern so implementation does not have to guess the intended structure.

Scope

In scope

  • reduce or eliminate test/wrapper.test.ts as a large catch-all file
  • reduce or eliminate test/core.test.ts as a large catch-all file
  • move command-owned behavior tests into the relevant command slices under src/commands/...
  • treat the following placement rule as required guidance, not an implementation guess:
    • put tests with the owning slice when they verify:
      • command validation
      • command-specific request shaping
      • command-specific response shaping
      • command-specific success/failure paths
    • keep tests outside slices only when they verify:
      • wrapper / OpenCode boundary behavior
      • caller / context resolution
      • config / auth path forwarding
      • runtime routing
      • shared auth / config loading behavior
      • shared error envelopes
  • split remaining shared coverage into multiple concern-oriented files under locations such as test/wrapper/ and test/core/
  • use explicit concern-based names for shared test files rather than broad layer-bucket names
  • acceptable naming style examples include:
    • test/wrapper/opencode-context.test.ts
    • test/wrapper/path-overrides.test.ts
    • test/wrapper/wrapper-logging.test.ts
    • test/core/runtime-routing.test.ts
    • test/core/shared-error-mapping.test.ts
    • test/core/auth-config-loading.test.ts
  • preserve or improve current behavior coverage during the refactor

Out of scope

  • redesigning runtime architecture
  • changing public command behavior
  • reducing meaningful coverage just to make files smaller
  • broad test-framework changes unrelated to this refactor

Acceptance criteria

  • command-specific tests currently living in test/wrapper.test.ts and test/core.test.ts are moved into the relevant slices where appropriate
  • slice-local placement follows this rule: command validation, command-specific request shaping, command-specific response shaping, and command-specific success/failure paths live with the owning slice
  • only genuinely cross-cutting tests remain outside the slices
  • remaining cross-cutting tests are split into multiple specifically named files organized by concern
  • no new generic replacement catch-all file is introduced
  • shared test file naming is explicit and concern-based rather than generic names like core.test.ts or wrapper.test.ts
  • the resulting layout makes ownership clearer between slice-local tests and shared runtime-boundary tests
  • test, lint, typecheck, and build all pass after the refactor

Docs impact

  • Docs impact: none
  • Details: test organization refactor only unless implementation reveals durable guidance worth documenting

ADR needed?

  • ADR needed: no
  • Details: this is a refactor to better align tests with the existing vertical-slice direction rather than a new architecture decision

Dependencies / sequencing notes

  • keep this as a single issue on purpose to avoid repeated Greg/Klarissa handoff overhead and context loss across one tightly related refactor
  • command-specific tests should continue following the existing slice-local pattern already established in src/commands/...
  • small scoped helpers are acceptable when they support a clear concern, but do not replace giant files with one giant shared helper module

Risks / open questions / non-goals

  • avoid replacing two giant files with one new giant file or one vague shared test bucket
  • avoid moving truly shared behavior into slices where ownership would become misleading
  • preserve meaningful behavior coverage while improving structure and ownership clarity

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions