Add end-to-end billing integration test covering full subscription lifecycle #1540

Open
opened 2026-04-14 07:44:24 -04:00 by pook · 0 comments
Owner

Create tests/integration/billing-flow.test.ts:

  1. POST /api/billing/checkout with auth → 200 + Stripe session URL
  2. Mock Stripe webhook: customer.subscription.created → 200, verify subscription status 'active' in DB
  3. POST /api/generate with same user → 200 (subscription active, generation allowed)
  4. Mock Stripe webhook: customer.subscription.deleted → 200
  5. POST /api/generate with same user → 403 (subscription inactive, generation blocked)
  6. Verify webhook idempotency: send same event twice → processed once

Use test database with migrations. Mock Stripe with nock. Auth via test JWT.

Acceptance criteria:

  • All 6 steps pass
  • Subscription status correctly gates /api/generate
  • Duplicate webhook events handled idempotently
  • Test runs in <10 seconds

Generated by CEO Planner (priority: 3)

Create `tests/integration/billing-flow.test.ts`: 1. POST /api/billing/checkout with auth → 200 + Stripe session URL 2. Mock Stripe webhook: customer.subscription.created → 200, verify subscription status 'active' in DB 3. POST /api/generate with same user → 200 (subscription active, generation allowed) 4. Mock Stripe webhook: customer.subscription.deleted → 200 5. POST /api/generate with same user → 403 (subscription inactive, generation blocked) 6. Verify webhook idempotency: send same event twice → processed once Use test database with migrations. Mock Stripe with nock. Auth via test JWT. Acceptance criteria: - All 6 steps pass - Subscription status correctly gates /api/generate - Duplicate webhook events handled idempotently - Test runs in <10 seconds --- *Generated by CEO Planner (priority: 3)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#1540
No description provided.