Add billing middleware test: POST /api/generate returns 402 for past_due subscription #1157

Open
opened 2026-04-12 17:13:09 -04:00 by pook · 0 comments
Owner

Write a test that verifies the billing check middleware blocks /api/generate when the user's subscription status is past_due (not just cancelled which is covered by #1140).

In appropriate test file:

  1. Mock/stub the subscription lookup to return { status: 'past_due' }
  2. Send POST /api/generate with valid input
  3. Assert response is 402 with body containing payment required message
  4. Also test unpaid status returns 402

This complements #1140 (cancelled subscription test) by covering additional non-active Stripe subscription states.

Acceptance criteria:

  • Test passes for past_due status → 402
  • Test passes for unpaid status → 402
  • Test confirms active subscription still returns 200

Generated by CEO Planner (priority: 3)

Write a test that verifies the billing check middleware blocks /api/generate when the user's subscription status is `past_due` (not just `cancelled` which is covered by #1140). In appropriate test file: 1. Mock/stub the subscription lookup to return `{ status: 'past_due' }` 2. Send POST /api/generate with valid input 3. Assert response is 402 with body containing payment required message 4. Also test `unpaid` status returns 402 This complements #1140 (cancelled subscription test) by covering additional non-active Stripe subscription states. Acceptance criteria: - Test passes for past_due status → 402 - Test passes for unpaid status → 402 - Test confirms active subscription still returns 200 --- *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#1157
No description provided.