Compare commits

..
Author SHA1 Message Date
Andrew BeveridgeandClaude Opus 4.5 275fc909f6 fix: E2E test issues - add Firestore index and fix job endpoint URL
- Add missing Firestore composite index for customer_email + made_for_you queries
  (required for test-webhook made-for-you order processing)
- Fix getJobDetails helper to use /api/jobs/{job_id} instead of /api/admin/jobs/{job_id}
  (the admin route doesn't have a GET method)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 21:52:34 -08:00
Andrew Beveridge ☄️andClaude Opus 4.5 fc781de5ad feat: add production E2E tests for payment webhook flows (#366)
## Summary
- Add test-webhook endpoint to internal API for E2E testing of Stripe
payment flows
- Create comprehensive E2E test suite for payment flows that were
previously untested
- The YouTube URL order test would have caught the 2026-01-28 bug where
workers were triggered before input_media_gcs_path was set

## Changes
- **Backend**: Add `/api/internal/test-webhook` endpoint that simulates
Stripe webhook events
  - Admin authentication required
  - Session IDs must start with `e2e-test-` prefix for safety
  - Reuses existing webhook handler logic
- **E2E Tests**: 
  - `stripe-credit-purchase.spec.ts` - Credit purchase flow
  - `stripe-made-for-you-search.spec.ts` - Made-for-you search orders
- `stripe-made-for-you-youtube.spec.ts` - Made-for-you YouTube URL
orders (critical)
  - `stripe-webhook-security.spec.ts` - Webhook security validation
- **Test Helpers**: `stripe-test-client.ts`, `test-cleanup.ts` for E2E
infrastructure
- **Unit Tests**: `test_internal_test_webhook.py` (11 passing, 2
skipped)

## Test plan
- [x] Backend unit tests pass (11 passed, 2 skipped)
- [x] Existing tests not affected (pre-existing failures in
cloud-mode-review.spec.ts)
- [ ] Production E2E tests run after deployment:
`KARAOKE_ADMIN_TOKEN=xxx npx playwright test
e2e/production/stripe-*.spec.ts`

<!-- @coderabbitai ignore -->

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-29 21:34:22 -08:00
2 changed files with 16 additions and 1 deletions

No files matched your search

+1 -1
View File
@@ -200,7 +200,7 @@ export async function getJobDetails(
adminToken: string,
apiUrl: string = URLS.production.api
): Promise<Record<string, unknown> | null> {
const response = await fetch(`${apiUrl}/api/admin/jobs/${jobId}`, {
const response = await fetch(`${apiUrl}/api/jobs/${jobId}`, {
headers: {
'Authorization': `Bearer ${adminToken}`,
},
+15
View File
@@ -61,6 +61,21 @@ def create_database() -> dict:
opts=pulumi.ResourceOptions(depends_on=[firestore_db]),
)
# Jobs: query by customer_email + made_for_you, order by created_at
# Used for finding existing made-for-you orders for a customer
resources["firestore_index_jobs_customer_mfy"] = firestore.Index(
"firestore-index-jobs-customer-mfy",
project=PROJECT_ID,
database=firestore_db.name,
collection="jobs",
fields=[
firestore.IndexFieldArgs(field_path="customer_email", order="ASCENDING"),
firestore.IndexFieldArgs(field_path="made_for_you", order="ASCENDING"),
firestore.IndexFieldArgs(field_path="created_at", order="DESCENDING"),
],
opts=pulumi.ResourceOptions(depends_on=[firestore_db]),
)
# Sessions: query by user_email + is_active, order by created_at
resources["firestore_index_sessions_active"] = firestore.Index(
"firestore-index-sessions-active",