test(triggers): add unit tests for github trigger utilities and agent result handler#315
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 — Clean, well-structured unit tests that correctly exercise the source implementations.
I verified the tests against the source code in src/triggers/github/utils.ts and src/triggers/shared/agent-result-handler.ts:
- github-utils tests: Correctly test all exported pure functions against the actual regex patterns (
TRELLO_CARD_URL_REGEX,JIRA_ISSUE_KEY_REGEX). Edge cases (null input, multiple matches, word boundaries) are well-covered. TheextractWorkItemIdandrequireWorkItemIddelegation tests correctly reflect thepm.type === 'jira'branching logic. - agent-result-handler tests: The
safeOperationmock correctly bypasses the wrapper to test the inner callback logic. ThegetPMProvidermock works correctly since it's called inside thesafeOperationcallback. The rounding test (1.123456 + 0.987654 = 2.1111) matches the actualMath.round(x * 10000) / 10000logic. Both Trello and JIRA cost field resolution paths are tested, including skip-conditions (no field configured, zero cost, undefined cost). - Test conventions follow existing patterns in
tests/unit/triggers/. - All CI checks pass.
One minor observation (not blocking): the comment on line 128 of github-utils.test.ts ("Should not match partial strings") is slightly misleading — the test actually demonstrates that word boundaries correctly truncate the match at NOTAKEY-123 rather than including -MORE. The expectation is correct; it's just the comment phrasing that's a bit ambiguous.
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
This PR adds comprehensive unit tests for two critical utility modules in the trigger system:
src/triggers/github/utils.ts— URL parsing and work item extraction logic (was at 53.22% coverage)src/triggers/shared/agent-result-handler.ts— Result artifact handling and cost accumulation (was at 0% coverage)Test Coverage
github-utils.test.ts (27 tests):
extractTrelloCardId— null input, no URL, valid URL with/without slug, multiple URLs, alphanumeric IDshasTrelloCardUrl— truthy/falsy casesextractJiraIssueKey— null input, no key found, valid keys, embedded keys, word boundariesextractWorkItemId— Trello vs JIRA delegation, null handlingrequireWorkItemId— returns null with logging when no ID, returns ID when presentagent-result-handler.test.ts (9 tests):
handleAgentResultArtifacts— cost accumulation, rounding to 4 decimalsKey Test Patterns
getPMProviderandsafeOperationfor side-effect teststests/unit/triggers/conventionsRelated
Trello Card: https://trello.com/c/6993804d370da297fe1d6da8