Skip to content

test(triggers): add unit coverage for runAgentWithCredentials in webhook-execution#1053

Merged
aaight merged 1 commit intodevfrom
feature/webhook-execution-unit-tests
Mar 25, 2026
Merged

test(triggers): add unit coverage for runAgentWithCredentials in webhook-execution#1053
aaight merged 1 commit intodevfrom
feature/webhook-execution-unit-tests

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 25, 2026

Summary

  • Adds tests/unit/triggers/shared/webhook-execution.test.ts with 16 unit tests covering runAgentWithCredentials in src/triggers/shared/webhook-execution.ts
  • Verifies early return when agentType is falsy (null or empty string)
  • Verifies GitHub persona token lookup uses the resolved agent type
  • Verifies the exact nesting order: injectLlmApiKeys → integration.withCredentials → withGitHubToken → runAgentExecutionPipeline
  • Verifies default executionConfig is derived from integration.type when omitted and explicit config is passed through unchanged
  • Verifies the LLM env restore function always runs (via finally) on both success and failure paths

Test plan

  • vitest run --project unit-triggers tests/unit/triggers/shared/webhook-execution.test.ts — 16 tests pass
  • Full unit-triggers suite — 738 tests pass across 43 files
  • Lint check passes (biome check .)
  • TypeScript type check passes (tsc --noEmit)

Trello card: https://trello.com/c/WSMttx4T/565-as-a-developer-i-want-unit-coverage-for-shared-webhook-credential-execution-so-that-trigger-handlers-preserve-cleanup-and-creden

🤖 Generated with Claude Code

🕵️ claude-code · claude-sonnet-4-6 · run details

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

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

LGTM — Clean, well-structured unit test file that accurately covers the runAgentWithCredentials function.

The 16 tests comprehensively verify:

  • Early return guard for falsy agentType
  • Correct arguments to getPersonaToken and withGitHubToken
  • The exact credential nesting order matching the source's call sequence
  • Default vs explicit executionConfig passthrough (using ??, not spread)
  • finally-based LLM env cleanup on both success and failure paths
  • Error propagation from nested callbacks

Test structure follows project conventions (hoisted mocks, vi.mock pattern, fixture helpers, file path mirrors source). The vitest global clearMocks: true handles inter-test mock isolation, making the explicit mockRestoreLlmEnv.mockClear() in beforeEach redundant but harmless. All CI checks pass.

🕵️ claude-code · claude-opus-4-6 · run details

@aaight aaight merged commit e5f0a56 into dev Mar 25, 2026
9 checks passed
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.

2 participants