@@ -9,7 +9,7 @@ import { expect } from 'chai';
99import sinon from 'sinon' ;
1010import { AgentInboundHandler } from '../services/agent-inbound-handler.service' ;
1111import { BridgeExecutorService , BridgeExecutorParams } from '../services/bridge-executor.service' ;
12- import { AgentCredentialService } from '../services/agent-credential .service' ;
12+ import { AgentConfigResolver } from '../services/agent-config-resolver .service' ;
1313import { AgentEventEnum } from '../dtos/agent-event.enum' ;
1414import {
1515 setupAgentTestContext ,
@@ -20,6 +20,15 @@ import {
2020} from './helpers/agent-test-setup' ;
2121import { signSlackRequest , buildSlackChallenge } from './helpers/providers/slack' ;
2222
23+ function mockSentMessage ( ) {
24+ return {
25+ addReaction : async ( ) => { } ,
26+ removeReaction : async ( ) => { } ,
27+ edit : async ( ) => mockSentMessage ( ) ,
28+ delete : async ( ) => { } ,
29+ } ;
30+ }
31+
2332function mockThread ( id : string , channelId = 'C_TEST' ) {
2433 return {
2534 id,
@@ -28,6 +37,7 @@ function mockThread(id: string, channelId = 'C_TEST') {
2837 startTyping : async ( ) => { } ,
2938 subscribe : async ( ) => { } ,
3039 toJSON : ( ) => ( { id, platform : 'slack' , channelId, serialized : true } ) ,
40+ createSentMessageFromMessage : ( ) => mockSentMessage ( ) ,
3141 } ;
3242}
3343
@@ -48,7 +58,7 @@ function mockMessage(opts: { id?: string; userId: string; text: string; fullName
4858describe ( 'Agent Webhook - inbound flow #novu-v2' , ( ) => {
4959 let ctx : AgentTestContext ;
5060 let inboundHandler : AgentInboundHandler ;
51- let credentialService : AgentCredentialService ;
61+ let configResolver : AgentConfigResolver ;
5262 let bridgeCalls : BridgeExecutorParams [ ] ;
5363
5464 before ( ( ) => {
@@ -58,7 +68,7 @@ describe('Agent Webhook - inbound flow #novu-v2', () => {
5868 beforeEach ( async ( ) => {
5969 ctx = await setupAgentTestContext ( ) ;
6070 inboundHandler = testServer . getService ( AgentInboundHandler ) ;
61- credentialService = testServer . getService ( AgentCredentialService ) ;
71+ configResolver = testServer . getService ( AgentConfigResolver ) ;
6272
6373 bridgeCalls = [ ] ;
6474 const bridgeExecutor = testServer . getService ( BridgeExecutorService ) ;
@@ -68,7 +78,7 @@ describe('Agent Webhook - inbound flow #novu-v2', () => {
6878 } ) ;
6979
7080 async function invokeInbound ( threadId : string , message : ReturnType < typeof mockMessage > , event = AgentEventEnum . ON_MESSAGE ) {
71- const config = await credentialService . resolve ( ctx . agentId , ctx . integrationIdentifier ) ;
81+ const config = await configResolver . resolve ( ctx . agentId , ctx . integrationIdentifier ) ;
7282 const thread = mockThread ( threadId ) ;
7383 await inboundHandler . handle ( ctx . agentId , config , thread as any , message as any , event ) ;
7484 }
0 commit comments