test(payment): #53 subscription E2E seed fixture + un-skip grace-period & dup-guard#146
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 messagingseedIsolated*pattern: a throwaway keyed user + injectable session + a service-rolesubscriptionsinsert. 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_idFK isNO ACTION(not cascade) anddeleteTestUserdoesn't touchsubscriptions, 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 agrace_periodrow (expires +5d), opens/account/subscriptionsas 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 with23505onidx_subscriptions_one_live_per_user.Cancel (drives the
cancel-subscriptionEdge 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:
openSubscriptionsAsflow via the Playwright MCP with a fresh throwaway user → confirmed5 days remaining+ badge render.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