Fix Stripe CDN mock override and free-plan sync guards in E2E tests #83

Merged
will.anderson merged 1 commits from fix/stage-ci-paths into stage 2026-05-11 14:55:30 +00:00
Owner

What

  • Block real Stripe CDN (js.stripe.com/**) inside injectMockStripe() so the addInitScript mock is never overwritten by the async-loaded Stripe SDK
  • Replace all 8 waitForFunction(signUpWithEmail) calls in free-plan auth tests with waitForLoadState(domcontentloaded) — deferred scripts execute before DOMContentLoaded, so this is a tighter and more reliable sync point

Why this fixes CI

Group A (Stripe mock tests): The <script src="https://js.stripe.com/v3/" async> tag fires after Playwright injects the mock via addInitScript. The real Stripe SDK replaces window.Stripe, then checkout-stripe.js (defer) calls the real SDK with a fake client_secret, which fails silently — #stripe-mock-mounted never appears and submit-btn stays disabled forever. Blocking the CDN request entirely prevents the override.

Group B (free plan auth tests): The obfuscated checkout-auth.js (CI build) assigns window.signUpWithEmail via a decoded string table lookup. The waitForFunction poll sometimes wins the race but is fragile under CI timing. waitForLoadState(domcontentloaded) is structurally correct — deferred scripts are guaranteed to have executed by that event.

## What - Block real Stripe CDN (`js.stripe.com/**`) inside `injectMockStripe()` so the `addInitScript` mock is never overwritten by the async-loaded Stripe SDK - Replace all 8 `waitForFunction(signUpWithEmail)` calls in free-plan auth tests with `waitForLoadState(domcontentloaded)` — deferred scripts execute before DOMContentLoaded, so this is a tighter and more reliable sync point ## Why this fixes CI **Group A (Stripe mock tests):** The `<script src="https://js.stripe.com/v3/" async>` tag fires after Playwright injects the mock via `addInitScript`. The real Stripe SDK replaces `window.Stripe`, then `checkout-stripe.js` (defer) calls the real SDK with a fake `client_secret`, which fails silently — `#stripe-mock-mounted` never appears and `submit-btn` stays disabled forever. Blocking the CDN request entirely prevents the override. **Group B (free plan auth tests):** The obfuscated `checkout-auth.js` (CI build) assigns `window.signUpWithEmail` via a decoded string table lookup. The `waitForFunction` poll sometimes wins the race but is fragile under CI timing. `waitForLoadState(domcontentloaded)` is structurally correct — deferred scripts are guaranteed to have executed by that event.
will.anderson added 1 commit 2026-05-11 14:55:16 +00:00
- Block real Stripe CDN (js.stripe.com) in injectMockStripe() so the
  addInitScript mock is never overwritten by the async-loaded SDK
- Replace waitForFunction(signUpWithEmail) with waitForLoadState in
  all 8 free-plan auth tests; defer scripts run before DOMContentLoaded
  so the function is guaranteed present without polling for it
will.anderson merged commit 4b70e8c186 into stage 2026-05-11 14:55:30 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: neuron-technologies/neuron-web#83