@@ -137,6 +137,7 @@ describe('dispatchWebhookEvent', () => {
137137 beforeEach ( ( ) => {
138138 jest . useFakeTimers ( ) ;
139139 global . fetch = jest . fn ( ) ;
140+ jest . spyOn ( Math , 'random' ) . mockReturnValue ( 0 ) ;
140141 } ) ;
141142
142143 afterEach ( ( ) => {
@@ -313,17 +314,25 @@ describe('dispatchWebhookEvent', () => {
313314 } ) ,
314315 'Webhook delivery failed, retrying'
315316 ) ;
316- expect ( logger . error ) . toHaveBeenCalledWith (
317+ const exhaustionLogCalls = ( logger . error as jest . Mock ) . mock . calls . filter (
318+ ( [ , message ] ) =>
319+ message === 'Webhook delivery exhausted all retries, flagged as failing'
320+ ) ;
321+ expect ( exhaustionLogCalls ) . toHaveLength ( 1 ) ;
322+
323+ const [ exhaustionLogFields ] = exhaustionLogCalls [ 0 ] ;
324+ expect ( exhaustionLogFields ) . toEqual (
317325 expect . objectContaining ( {
318326 webhook_id : 'wh-1' ,
319327 creator_id : 'creator-1' ,
320328 event_type : 'sell' ,
321329 total_attempts : envConfig . WEBHOOK_RETRY_MAX_ATTEMPTS ,
322330 last_error_code : 'Network error' ,
323331 flagged_at : expect . any ( String ) ,
324- } ) ,
325- 'Webhook delivery exhausted all retries, flagged as failing'
332+ } )
326333 ) ;
334+ expect ( exhaustionLogFields . callback_url ) . toBeUndefined ( ) ;
335+ expect ( exhaustionLogFields . callbackUrl ) . toBeUndefined ( ) ;
327336
328337 // Verify attempt log was emitted for every retry attempt (success: false, response_status: null)
329338 for ( let attempt = 1 ; attempt <= envConfig . WEBHOOK_RETRY_MAX_ATTEMPTS ; attempt ++ ) {
0 commit comments