Skip to content

fix(tests): un-quarantine billing route suites - #1655

Open
Mossad-esc wants to merge 1 commit into
CalloraOrg:mainfrom
Mossad-esc:fix/issue-1562-unquarantine-billing-suites
Open

Mossad-esc wants to merge 1 commit into
CalloraOrg:mainfrom
Mossad-esc:fix/issue-1562-unquarantine-billing-suites

Conversation

@Mossad-esc

Copy link
Copy Markdown

Summary

Repairs and un-quarantines the six /api/billing/* route suites (billing.test.ts, billing.ratelimit.test.ts, billing.openapi.test.ts, billing/deduct/bulk.test.ts, billing/disputes.test.ts, and billing/portal.test.ts) and removes them from jest.quarantine.json.

Root Causes & Changes

Production Bug Fix

  • src/routes/billing/portal.ts: Removed take: 1 from the paidInvoices query in GET /api/billing/portal/summary so totalPaid aggregates all paid invoices for the user rather than only the most recent one (while keeping orderBy so lastPaymentDate still reads the latest paid invoice).

OpenAPI Spec

  • docs/openapi.json: Added the missing 429 response definition (with Retry-After header and rateLimited example) to POST /api/billing/deduct. Verified with npm run validate:openapi.

Test & Quarantine Updates

  • src/routes/billing/portal.test.ts, src/routes/billing/disputes.test.ts, src/routes/billing.test.ts, src/routes/billing.ratelimit.test.ts: Switched authentication from bare x-user-id headers to Bearer JWTs (signTestToken and TEST_JWT_SECRET from tests/helpers/jwt.ts).
  • src/routes/billing.ratelimit.test.ts: Updated 429 assertion from res.body.code to res.body.error.code.
  • src/routes/billing.test.ts: Updated pagination assertions for the successEnvelope payload (res.body.data.data / res.body.data.meta), used a numeric BigInt-compatible cursor ID, and stabilized Date/x-request-id for the ETag 304 test.
  • src/routes/billing/deduct/bulk.test.ts: Updated mockPool.query to return a lease_token row on INSERT INTO idempotency_store so idempotencyMiddleware does not return 409 IDEMPOTENCY_IN_PROGRESS.
  • jest.quarantine.json: Removed the 6 suites (103/103 tests passing under npm test -- --runInBand).

Closes #1562

Switch billing route tests from bare x-user-id to Bearer JWTs, update error/envelope assertions, isolate idempotency mock in bulk deduct tests, add 429 response example for /api/billing/deduct in docs/openapi.json, and fix paid-invoice aggregation in portal summary.

Closes CalloraOrg#1562
@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@Mossad-esc Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Un-quarantine the billing route suites

1 participant