Skip to content

refactor(core): decompose session-manager.test.ts into modular test files#728

Open
i-trytoohard wants to merge 1 commit intomainfrom
feat/724
Open

refactor(core): decompose session-manager.test.ts into modular test files#728
i-trytoohard wants to merge 1 commit intomainfrom
feat/724

Conversation

@i-trytoohard
Copy link
Collaborator

Summary

Closes #724

  • Decomposes the monolithic 5,032-line session-manager.test.ts into 7 focused, domain-specific test files plus shared helpers
  • Extracts parameterized shell mock installers into opencode-helpers.ts and shared mock factories into test-utils.ts
  • All 174 tests preserved and passing with zero changes to core logic

New file structure

File Tests Lines
spawn.test.ts 41 979
spawn-orchestrator.test.ts 31 1,061
query.test.ts 19 581
lifecycle.test.ts 23 699
communication.test.ts 18 556
restore.test.ts 19 617
claim-pr.test.ts 19 563
test-utils.ts 165
opencode-helpers.ts 149

Test plan

  • vitest run session-manager/ passes with 174 tests, 0 failures
  • No changes to production code
  • ESLint passes on all new files
  • TypeScript type-checks pass
  • Full build succeeds

🤖 Generated with Claude Code

…iles (#724)

The monolithic 5,032-line session-manager.test.ts has been split into
focused, domain-specific files to improve maintainability and enable
parallel test execution.

New structure:
- session-manager/test-utils.ts - shared mock factories and test setup
- session-manager/opencode-helpers.ts - parameterized shell mock installers
- session-manager/spawn.test.ts - 41 spawn tests
- session-manager/spawn-orchestrator.test.ts - 31 spawnOrchestrator tests
- session-manager/query.test.ts - 19 list + get tests
- session-manager/lifecycle.test.ts - 23 kill + cleanup tests
- session-manager/communication.test.ts - 18 send + remap tests
- session-manager/restore.test.ts - 19 restore tests
- session-manager/claim-pr.test.ts - 19 claimPR + PluginRegistry + isIssueNotFoundError tests

Total test count preserved at 174. Zero changes to core logic.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the packages/core SessionManager test suite by splitting the former monolithic session-manager.test.ts into multiple domain-focused test files and extracting shared helpers to reduce per-file complexity and improve maintainability.

Changes:

  • Added shared SessionManager test scaffolding (test-utils.ts) and shell-mock installers (opencode-helpers.ts).
  • Split SessionManager tests into focused modules (spawn, orchestrator spawn, query, lifecycle, communication, restore, claim PR).
  • Preserved existing behaviors/coverage while reorganizing test structure for readability and parallelism.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/core/src/tests/session-manager/test-utils.ts Shared test context/setup/teardown and mock plugin/registry factories.
packages/core/src/tests/session-manager/opencode-helpers.ts Test-only installers for mock opencode/git binaries used by SessionManager tests.
packages/core/src/tests/session-manager/spawn.test.ts Worker-session spawn behavior tests (branching, tracker integration, OpenCode mappings, prompt delivery).
packages/core/src/tests/session-manager/spawn-orchestrator.test.ts Orchestrator session spawn/reuse/delete/ignore strategy tests and config/launch behavior.
packages/core/src/tests/session-manager/query.test.ts list()/get() behaviors including metadata repair, activity detection, and OpenCode remapping.
packages/core/src/tests/session-manager/lifecycle.test.ts kill() and cleanup() behaviors including workspace safety and OpenCode cleanup semantics.
packages/core/src/tests/session-manager/communication.test.ts send()/delivery confirmation and remap() behaviors including OpenCode discovery flows.
packages/core/src/tests/session-manager/restore.test.ts restore() behaviors including workspace restore, archive restore, and post-launch metadata handling.
packages/core/src/tests/session-manager/claim-pr.test.ts claimPR() ownership/consolidation behavior plus some additional non-claimPR unit tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@harshitsinghbhandari
Copy link
Collaborator

This pull request depends on #720 and #722 merging first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Decompose session-manager.test.ts into Modular Test Files

3 participants