Add E2E billing gate test: unpaid blocked, paid allowed on /api/generate #1128

Open
opened 2026-04-12 16:02:57 -04:00 by pook · 0 comments
Owner

Write a test file (e.g., tests/billing-gate.test.ts) that verifies the subscription status check middleware behavior on POST /api/generate. Test two scenarios:

  1. User without active subscription → request returns 403 with JSON error
  2. User with active subscription → request passes through to handler (mock the OpenAI call)

Mock the database query for subscription status. Use the project's existing test framework (check package.json). This validates that the billing gate actually protects the revenue-generating endpoint.

Acceptance criteria:

  • Test file created with both test cases
  • Tests pass when run via npm test
  • Uses existing test utilities and patterns from the project

Generated by CEO Planner (priority: 2)

Write a test file (e.g., tests/billing-gate.test.ts) that verifies the subscription status check middleware behavior on POST /api/generate. Test two scenarios: 1. User without active subscription → request returns 403 with JSON error 2. User with active subscription → request passes through to handler (mock the OpenAI call) Mock the database query for subscription status. Use the project's existing test framework (check package.json). This validates that the billing gate actually protects the revenue-generating endpoint. Acceptance criteria: - Test file created with both test cases - Tests pass when run via npm test - Uses existing test utilities and patterns from the project --- *Generated by CEO Planner (priority: 2)*
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#1128
No description provided.