Skip to content

test(api-service): add E2E tests for agent webhook and reply flows fixes NV-7356#10709

Merged
ChmaraX merged 1 commit intonextfrom
nv-7356-agent-e2e-tests
Apr 14, 2026
Merged

test(api-service): add E2E tests for agent webhook and reply flows fixes NV-7356#10709
ChmaraX merged 1 commit intonextfrom
nv-7356-agent-e2e-tests

Conversation

@ChmaraX
Copy link
Copy Markdown
Contributor

@ChmaraX ChmaraX commented Apr 14, 2026

Summary

Adds E2E test coverage for the two untested sides of the conversational agents feature:

  • Inbound webhook flow (agent-webhook.e2e.ts) — conversation creation, participant resolution (platform_user vs subscriber), thread reuse, bridge payload shape verification, Slack signature rejection, conversation lifecycle (reopen resolved, participant upgrade)
  • Reply endpoint (agent-reply.e2e.ts) — reply/update persistence, metadata signals with cumulative 64KB limit, resolve lifecycle with onResolve bridge callback, combined reply+signals+resolve in single request

Shared test infrastructure under helpers/ with provider-specific helpers isolated in helpers/providers/slack.ts for easy extension to Teams/WhatsApp.

Approach

  • Inbound tests call AgentInboundHandler.handle() directly with mock Thread/Message objects, bypassing the Chat SDK's Slack API calls while still exercising the full orchestration: credential resolution → subscriber resolution → conversation service → activity persistence → bridge executor
  • Reply tests POST to the real /v1/agents/:agentId/reply endpoint with ChatSdkService.postToConversation and BridgeExecutorService.execute stubbed via sinon (auto-restored by global afterEach)
  • Challenge verification and signature rejection tests hit the real webhook endpoint since those are handled by the Chat SDK before any API calls

Test plan

  • 9 webhook tests passing
  • 8 reply tests passing
  • 7 existing CRUD tests still passing (no regression)

@linear
Copy link
Copy Markdown

linear bot commented Apr 14, 2026

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This pull request introduces comprehensive end-to-end test coverage for conversational agents functionality. It adds test suites for reply and webhook endpoints, helper utilities for setting up agent test contexts and seeding conversations, and Slack webhook payload builders with signing utilities.

Changes

Cohort / File(s) Summary
Reply Endpoint Tests
apps/api/src/app/agents/e2e/agent-reply.e2e.ts
E2E tests for /v1/agents/:agentId/reply endpoint validating message persistence, conversation state transitions, metadata signaling, resolve flow with bridge callbacks, and combined payload handling.
Webhook Endpoint Tests
apps/api/src/app/agents/e2e/agent-webhook.e2e.ts
E2E tests for inbound webhook flow covering Slack verification, conversation creation with participant types, thread handling, bridge invocation assertions, and conversation lifecycle transitions (reopening/upgrading participants).
Test Infrastructure
apps/api/src/app/agents/e2e/helpers/agent-test-setup.ts, apps/api/src/app/agents/e2e/helpers/providers/slack.ts
Helper modules providing setupAgentTestContext(), conversation/endpoint seeding utilities, and Slack-compatible webhook payload builders with HMAC-SHA256 signing functions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • scopsy
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title follows the Conventional Commits format with valid type 'test' and scope 'api-service', includes a descriptive message in imperative mood, and properly references the Linear ticket with 'fixes NV-7356' at the end.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ChmaraX ChmaraX force-pushed the nv-7356-agent-e2e-tests branch from 466d7b7 to 60cb954 Compare April 14, 2026 13:12
Base automatically changed from conversation-agents to next April 14, 2026 13:26
@ChmaraX ChmaraX force-pushed the nv-7356-agent-e2e-tests branch from 60cb954 to c08fc8d Compare April 14, 2026 13:31
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 14, 2026

Deploy Preview for dashboard-v2-novu-staging canceled.

Name Link
🔨 Latest commit c08fc8d
🔍 Latest deploy log https://app.netlify.com/projects/dashboard-v2-novu-staging/deploys/69de41b380d5720008e6d385

Comment on lines +1 to +10
import {
AgentIntegrationRepository,
AgentRepository,
ChannelConnectionRepository,
ChannelEndpointRepository,
ConversationActivityRepository,
ConversationRepository,
ConversationStatusEnum,
IntegrationRepository,
} from '@novu/dal';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant