test(pm): add comprehensive tests for PM lifecycle, factory, and context modules#313
Merged
zbigniewsobiecki merged 1 commit intodevfrom Feb 16, 2026
Merged
Conversation
Collaborator
|
🔍 Reviewing PR... |
aaight
approved these changes
Feb 16, 2026
Collaborator
aaight
left a comment
There was a problem hiding this comment.
LGTM — Tests are well-structured, correctly exercise all public APIs of the three modules, and the mocking strategy is sound. The safeOperation mock correctly bypasses error-swallowing to allow direct assertion on provider calls, the context.test.ts exercises the real AsyncLocalStorage implementation with proper concurrency and nesting scenarios, and the factory.test.ts correctly leverages Vitest's mock hoisting. All assertions match the source code.
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
src/pm/lifecycle.ts(PMLifecycleManager class and resolveProjectPMConfig function)src/pm/factory.ts(createPMProvider factory function)src/pm/context.ts(AsyncLocalStorage-based PM provider scoping)Test Coverage
PMLifecycleManager (
lifecycle.test.ts)prepareForAgent()- adds processing label, removes ready/processed labels, moves to inProgress for implementation agentshandleSuccess()- adds processed label, moves to inReview for implementation agents, adds PR comment when URL providedhandleFailure()- adds error label, posts error comment when message providedhandleBudgetExceeded()- removes processing label, adds error label, posts budget exceeded messagehandleBudgetWarning()- adds error label, posts budget warning messagecleanupProcessing()- removes processing labelhandleError()- adds error label and error commentresolveProjectPMConfig (
lifecycle.test.ts)createPMProvider (
factory.test.ts)PM Context (
context.test.ts)withPMProvider()- makes provider available within async contextgetPMProvider()- returns provider when in context, throws helpful error when notgetPMProviderOrNull()- returns provider when in context, returns null when not (no throw)Test Results
All 40 tests pass with 100% coverage:
lifecycle.ts: 100% statements, 97.29% branches, 100% functions, 100% linesfactory.ts: 100% coverage across all metricscontext.ts: 100% coverage across all metricsRelated
Fixes: https://trello.com/c/YA4xP5oD/13