Skip to content

Latest commit

 

History

History
45 lines (36 loc) · 2.82 KB

File metadata and controls

45 lines (36 loc) · 2.82 KB

Billing Invoice E2E PR Notes

Summary

  • Expanded tests/integration/billing.test.ts to cover end-to-end invoice generation, settlement success paths, retry/failure paths, concurrency behavior, and malformed-event edge cases.
  • Fixed the pg-mem-backed integration helpers so the database-backed invoice tests execute against synchronous db.public queries instead of silently returning empty results.
  • Added same-instance batch serialization in RevenueSettlementService so concurrent runBatch() calls do not double-process the same unsettled events within a single service instance.

Test Output Summary

  • npm run lint
    • Passed with 0 errors.
    • Repo still has 93 existing lint warnings outside this change set.
  • npm run typecheck
    • Passed.
  • npx jest tests/integration/billing.test.ts --runInBand
    • Passed: 1 suite, 26 tests.
  • npm test
    • Still failing outside this task area, even when rerun outside the sandbox.
    • Observed unrelated failures include tests/integration/billing-http.test.ts, src/__tests__/developerRevenue.test.ts, and src/__tests__/ipAllowlist.test.ts.
    • Those failures are primarily authorization and allowlist expectation mismatches, not regressions introduced by the invoice-generation changes.

Security And Data-Integrity Notes

  • Billing idempotency is still enforced with request_id uniqueness plus the billing service transaction boundary that persists a pending row before external settlement side effects.
  • Failed payout attempts leave usage events unsettled so they can be retried; tests verify failed settlements are recorded without falsely marking events as paid.
  • The new RevenueSettlementService serialization guard protects against duplicate processing from concurrent runBatch() calls on the same service instance.
  • Database-backed invoice integration tests now exercise real settlement persistence and settled-event linkage instead of relying on async helpers that could mask data-loss bugs.
  • SQL used by the integration-only pg-mem helpers escapes interpolated string literals before executing direct db.public statements.

Suggested PR Paste

Validation summary:
- npm run lint: passed with 0 errors (93 pre-existing repo warnings remain)
- npm run typecheck: passed
- npx jest tests/integration/billing.test.ts --runInBand: passed (26/26)
- npm test: still failing in unrelated existing suites outside the billing invoice E2E change (observed in billing-http, developerRevenue, and ipAllowlist tests)

Security/data-integrity notes:
- request_id idempotency and pending-row transaction boundaries remain covered
- failed settlements stay retryable and are not marked as paid
- concurrent same-instance settlement batches are serialized to avoid duplicate processing
- DB-backed invoice tests now use real pg-mem-backed persistence paths for settlement linkage