@@ -1049,6 +1049,88 @@ describe('Webhook Trigger API Route', () => {
10491049 expect ( dispatchResolvedWebhookTargetMock ) . not . toHaveBeenCalled ( )
10501050 } )
10511051
1052+ it ( 'continues past a missing credential to another valid legacy credential' , async ( ) => {
1053+ testData . webhooks . push (
1054+ {
1055+ id : 'missing-legacy-slack-webhook' ,
1056+ provider : 'slack' ,
1057+ path : 'shared-legacy-slack-path' ,
1058+ routingKey : 'missing-credential' ,
1059+ isActive : true ,
1060+ providerConfig : {
1061+ triggerId : 'slack_webhook' ,
1062+ credentialId : 'missing-credential' ,
1063+ ingressMode : 'legacy_custom_bot' ,
1064+ } ,
1065+ workflowId : 'test-workflow-id' ,
1066+ } ,
1067+ {
1068+ id : 'valid-legacy-slack-webhook' ,
1069+ provider : 'slack' ,
1070+ path : 'shared-legacy-slack-path' ,
1071+ routingKey : 'valid-credential' ,
1072+ isActive : true ,
1073+ providerConfig : {
1074+ triggerId : 'slack_webhook' ,
1075+ credentialId : 'valid-credential' ,
1076+ ingressMode : 'legacy_custom_bot' ,
1077+ } ,
1078+ workflowId : 'test-workflow-id' ,
1079+ }
1080+ )
1081+ verifySlackCustomBotCredentialRequestMock . mockImplementation (
1082+ async ( { credentialId } : { credentialId : string } ) =>
1083+ credentialId === 'missing-credential' ? new NextResponse ( null , { status : 404 } ) : null
1084+ )
1085+
1086+ const response = await POST ( createMockRequest ( 'POST' , { type : 'event_callback' } ) , {
1087+ params : Promise . resolve ( { path : 'shared-legacy-slack-path' } ) ,
1088+ } )
1089+
1090+ expect ( response . status ) . toBe ( 200 )
1091+ expect ( dispatchSlackCustomBotCredentialMock ) . toHaveBeenCalledOnce ( )
1092+ expect ( dispatchSlackCustomBotCredentialMock ) . toHaveBeenCalledWith (
1093+ expect . objectContaining ( { credentialId : 'valid-credential' } )
1094+ )
1095+ } )
1096+
1097+ it ( 'continues to a direct webhook when every legacy credential is unavailable' , async ( ) => {
1098+ testData . webhooks . push (
1099+ {
1100+ id : 'missing-legacy-slack-webhook' ,
1101+ provider : 'slack' ,
1102+ path : 'shared-direct-path' ,
1103+ routingKey : 'missing-credential' ,
1104+ isActive : true ,
1105+ providerConfig : {
1106+ triggerId : 'slack_webhook' ,
1107+ credentialId : 'missing-credential' ,
1108+ ingressMode : 'legacy_custom_bot' ,
1109+ } ,
1110+ workflowId : 'test-workflow-id' ,
1111+ } ,
1112+ {
1113+ id : 'direct-webhook' ,
1114+ provider : 'generic' ,
1115+ path : 'shared-direct-path' ,
1116+ isActive : true ,
1117+ providerConfig : { requireAuth : false } ,
1118+ workflowId : 'test-workflow-id' ,
1119+ }
1120+ )
1121+ verifySlackCustomBotCredentialRequestMock . mockResolvedValueOnce (
1122+ new NextResponse ( null , { status : 404 } )
1123+ )
1124+
1125+ const response = await POST ( createMockRequest ( 'POST' , { type : 'event_callback' } ) , {
1126+ params : Promise . resolve ( { path : 'shared-direct-path' } ) ,
1127+ } )
1128+
1129+ expect ( response . status ) . toBe ( 200 )
1130+ expect ( dispatchSlackCustomBotCredentialMock ) . not . toHaveBeenCalled ( )
1131+ expect ( dispatchResolvedWebhookTargetMock ) . toHaveBeenCalledOnce ( )
1132+ } )
1133+
10521134 it ( 'propagates a legacy fan-out failure when no target queues successfully' , async ( ) => {
10531135 testData . webhooks . push ( {
10541136 id : 'legacy-slack-webhook' ,
0 commit comments