@@ -177,8 +177,7 @@ describe('DELETE /api/v1/creators/:id/webhooks/:webhookId', () => {
177177 . delete ( `/api/v1/creators/${ creatorId } /webhooks/${ webhookId } ` )
178178 . set ( authHeaders ( 'DELETE' , `/api/v1/creators/${ creatorId } /webhooks/${ webhookId } ` , creatorId ) ) ;
179179
180- expect ( deleteRes . status ) . toBe ( 200 ) ;
181- expect ( deleteRes . body . success ) . toBe ( true ) ;
180+ expect ( deleteRes . status ) . toBe ( 204 ) ;
182181
183182 const verifyRes = await supertest ( app )
184183 . get ( `/api/v1/creators/${ creatorId } /webhooks` )
@@ -195,6 +194,48 @@ describe('DELETE /api/v1/creators/:id/webhooks/:webhookId', () => {
195194
196195 expect ( res . status ) . toBe ( 404 ) ;
197196 } ) ;
197+
198+ it ( 'stops future deliveries when a webhook is deleted (#506)' , async ( ) => {
199+ // Register a webhook and confirm it exists
200+ const webhook = await prisma . webhook . create ( {
201+ data : {
202+ id : 'webhook-deletion-test-506' ,
203+ creatorId,
204+ callbackUrl : 'https://example.com/deleted-hook' ,
205+ events : { set : [ 'BUY' , 'SELL' ] } ,
206+ } ,
207+ } ) ;
208+
209+ // Delete the webhook and assert the response is 204
210+ const deleteRes = await supertest ( app )
211+ . delete ( `/api/v1/creators/${ creatorId } /webhooks/${ webhook . id } ` )
212+ . set ( authHeaders ( 'DELETE' , `/api/v1/creators/${ creatorId } /webhooks/${ webhook . id } ` , creatorId ) ) ;
213+
214+ expect ( deleteRes . status ) . toBe ( 204 ) ;
215+
216+ // Webhook record no longer exists after deletion
217+ const deletedWebhook = await prisma . webhook . findUnique ( { where : { id : webhook . id } } ) ;
218+ expect ( deletedWebhook ) . toBeNull ( ) ;
219+
220+ // Simulate a trade event after deletion
221+ const { dispatchWebhookEvent } = await import ( './webhook.service' ) ;
222+ await dispatchWebhookEvent ( {
223+ type : 'buy' ,
224+ creatorId,
225+ buyerOrSellerAddress : 'GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF' ,
226+ amount : '100' ,
227+ price : '10.5' ,
228+ feePaid : '0.5' ,
229+ timestamp : new Date ( ) . toISOString ( ) ,
230+ } ) ;
231+
232+ // Assert no delivery attempt was made for the deleted webhook
233+ const events = await prisma . webhookEvent . findMany ( {
234+ where : { webhookId : webhook . id } ,
235+ } ) ;
236+
237+ expect ( events . length ) . toBe ( 0 ) ;
238+ } ) ;
198239} ) ;
199240
200241describe ( 'webhook dispatch' , ( ) => {
0 commit comments