refactor(core): decompose session-manager.test.ts into modular test files#728
Open
i-trytoohard wants to merge 1 commit intomainfrom
Open
refactor(core): decompose session-manager.test.ts into modular test files#728i-trytoohard wants to merge 1 commit intomainfrom
i-trytoohard wants to merge 1 commit intomainfrom
Conversation
…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>
There was a problem hiding this comment.
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.
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #724
session-manager.test.tsinto 7 focused, domain-specific test files plus shared helpersopencode-helpers.tsand shared mock factories intotest-utils.tsNew file structure
spawn.test.tsspawn-orchestrator.test.tsquery.test.tslifecycle.test.tscommunication.test.tsrestore.test.tsclaim-pr.test.tstest-utils.tsopencode-helpers.tsTest plan
vitest run session-manager/passes with 174 tests, 0 failures🤖 Generated with Claude Code