Skip to content

test(payment): #53 subscription E2E seed fixture + un-skip grace-period & dup-guard#146

Merged
TortoiseWolfe merged 1 commit into
mainfrom
test/payment-subscription-e2e-fixtures
Jun 8, 2026
Merged

test(payment): #53 subscription E2E seed fixture + un-skip grace-period & dup-guard#146
TortoiseWolfe merged 1 commit into
mainfrom
test/payment-subscription-e2e-fixtures

Conversation

@TortoiseWolfe

Copy link
Copy Markdown
Owner

What

Adds a subscription seed fixture to the E2E harness and un-skips two payment tests that only needed a seeded row (no credentials), plus regenerates the stale skip-index doc from ground truth.

Fixture (tests/e2e/utils/test-user-factory.ts)

seedIsolatedSubscription(status, opts) / deleteIsolatedSubscription / openSubscriptionsAs — mirrors the existing messaging seedIsolated* pattern: a throwaway keyed user + injectable session + a service-role subscriptions insert. No payment provider involved (same direct-insert path the #5 webhooks use), so it needs zero Stripe/PayPal creds.

One non-obvious correctness detail: the subscriptions.template_user_id FK is NO ACTION (not cascade) and deleteTestUser doesn't touch subscriptions, so cleanup deletes the subscription row before the user — otherwise the auth-user delete fails on the FK.

Un-skipped tests (02-paypal-subscription.spec.ts)

  • should show grace period warning — seeds a grace_period row (expires +5d), opens /account/subscriptions as that user, asserts the "Grace period: 5 days remaining" countdown + Grace Period badge through real RLS.
  • should prevent duplicate subscriptions — seeds one live row, asserts a 2nd live insert is rejected with 23505 on idx_subscriptions_one_live_per_user.

Cancel (drives the cancel-subscription Edge Function) and failed-retry (needs PayPal sandbox keys) stay skipped with accurate reasons.

Verification

Playwright browsers aren't installed in the container (project policy), so I verified the test logic directly against the cloud backend:

  • Grace-period rendering — drove the exact openSubscriptionsAs flow via the Playwright MCP with a fresh throwaway user → confirmed 5 days remaining + badge render.
  • Duplicate-prevention — ran the fixture's exact insert SQL + 2nd-live insert against the live DB → confirmed 23505 + the index name, and that cleanup (sub-then-user) succeeds.
  • pnpm run type-check ✅, pnpm run lint ✅.

Doc (docs/payment-e2e-skip-index.md)

Regenerated from ground truth: the doc claimed 34 skips with stale line numbers/reasons; actual is 27 (post-un-skip), reclassified by true blocker (cred / fixture / route / feature / won't-fix). Notes that the payment Edge Functions are now deployed to prod, so the backend is no longer a blocker — only sandbox creds + a few front-end surfaces remain.

Part of #53.

🤖 Generated with Claude Code

…od & dup-guard

Adds seedIsolatedSubscription/deleteIsolatedSubscription/openSubscriptionsAs to
the e2e test-user-factory (mirrors the messaging seedIsolated* pattern: throwaway
keyed user + injectable session + service-role subscriptions insert). Cleanup
deletes the subscription row BEFORE the user — the subscriptions FK is NO ACTION
(not cascade) and deleteTestUser doesn't touch subscriptions, so the auth-user
delete would otherwise fail on the FK.

Un-skips two 02-paypal-subscription tests that only needed a seeded row (no creds):
- "should show grace period warning" — seeds a grace_period row, opens
  /account/subscriptions as that user, asserts the "5 days remaining" countdown
  + badge through real RLS. Verified end-to-end via the Playwright MCP against the
  cloud backend.
- "should prevent duplicate subscriptions" — seeds one live row, asserts a 2nd
  live insert is rejected with 23505 on idx_subscriptions_one_live_per_user.
  Verified against the live DB.

Leaves cancel (drives the cancel-subscription Edge Function) and failed-retry
(needs PayPal sandbox keys) skipped with accurate reasons.

Regenerates docs/payment-e2e-skip-index.md from ground truth: the doc claimed 34
skips with stale line numbers/reasons; actual is 27 (post-un-skip), reclassified
by true blocker (cred / fixture / route / feature / won't-fix). Notes that the
payment Edge Functions are now deployed to prod, so the backend is no longer a
blocker — only sandbox creds + a few front-end surfaces remain.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@TortoiseWolfe TortoiseWolfe merged commit 78a5051 into main Jun 8, 2026
17 checks passed
@TortoiseWolfe TortoiseWolfe deleted the test/payment-subscription-e2e-fixtures branch June 8, 2026 20:02
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.

2 participants