Context
PR for Phase 2 audit fix (refund correlation retry — branch fix/billing-refund-correlation-retry) introduces retryWithBackoff around the PaymentIntent metadata backfill call. The existing test should not throw when paymentIntents.update fails (non-fatal fallback) at modules/billing/tests/billing.webhook.checkout.unit.tests.js:286 now incurs ~600ms of real wall-clock delays per run because :
- Retry wraps
stripe.paymentIntents.update with backoff 200ms → 400ms → final
- The existing test mocks Stripe to throw, so all 3 retries fire with real
setTimeout
- Test still passes (the assertion is
.resolves.toBeUndefined()) but is now slow
Acceptance
- Switch the test to
jest.useFakeTimers() (or equivalent) + jest.runAllTimersAsync()
- Test still passes
- No real-timer delay incurred
Source
Discovered by spec reviewer on PR for Phase 2 audit fix (audit P1 — 2026-05-21).
Context
PR for Phase 2 audit fix (refund correlation retry — branch
fix/billing-refund-correlation-retry) introducesretryWithBackoffaround the PaymentIntent metadata backfill call. The existing testshould not throw when paymentIntents.update fails (non-fatal fallback)atmodules/billing/tests/billing.webhook.checkout.unit.tests.js:286now incurs ~600ms of real wall-clock delays per run because :stripe.paymentIntents.updatewith backoff 200ms → 400ms → finalsetTimeout.resolves.toBeUndefined()) but is now slowAcceptance
jest.useFakeTimers()(or equivalent) +jest.runAllTimersAsync()Source
Discovered by spec reviewer on PR for Phase 2 audit fix (audit P1 — 2026-05-21).