refactor(tests): migrate trigger tests to shared mocks and factories#1002
Merged
refactor(tests): migrate trigger tests to shared mocks and factories#1002
Conversation
nhopeatall
approved these changes
Mar 23, 2026
Collaborator
nhopeatall
left a comment
There was a problem hiding this comment.
LGTM — Clean mechanical refactoring that consistently replaces 15 inline mock declarations and payload constructions with shared mocks (sharedMocks.ts) and factory functions (factories.ts). No test logic or assertions were changed.
The changes are well-structured:
- Import ordering follows the documented convention (vitest → sharedMocks → vi.mock → SUT imports)
- Files using
vi.hoisted()(trello-comment-mention,github-pr-comment-mention) correctly keep their custom hoisted mocks while adopting shared mocks for common modules - The removal of the unused
TrelloStatusChangedPlanningTriggerimport fromstatus-changed.test.tsis a legitimate cleanup - All 7 CI checks pass including 681 trigger tests
🕵️ claude-code · claude-opus-4-6 · run details
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
sharedMocks.tsinstead of inline mock declarationsmockConfigProvider,mockTrelloClientModule,mockJiraClientModule,mockAcknowledgmentsModule,mockReactionsModule)config-resolverandtrigger-checkmocks withmockConfigResolverModuleandmockTriggerCheckModulemockLoggermockGitHubClientModulemakeCheckSuitePayload/makeFailurePayloadhelpers withcreateCheckSuitePayload()factorymakeReviewPayloadhelper withcreateReviewPayload()factorycreateTrelloActionPayload()factoryCard: https://trello.com/c/R6FlbHLC/520-as-a-developer-i-want-trigger-tests-migrated-to-shared-mocks-and-factories-so-that-they-are-shorter-and-consistent
Test plan
npx vitest run --project unit-triggers— all 681 trigger tests passnpx biome check— no lint errorsnpx tsc --noEmit— no type errorsKey decisions
vitest) due to Vitest's hoisting behavior —vi.mock()factories reference the shared mock values and need them to be initialized before other importsmakeSynchronizePayload,makeReviewRequestedPayload, andmakeCheckSuitePayload(where they're highly customized per test) were kept as local helpers wrapping the factory functionsTrelloStatusChangedBacklogTriggertests were rewritten from scratch with factory-based payloads (the original used inline payload constructions throughout)🤖 Generated with Claude Code
🕵️ claude-code · claude-sonnet-4-6 · run details