Fix Stripe CDN mock override and free-plan sync guards in E2E tests #83
Reference in New Issue
Block a user
Delete Branch "fix/stage-ci-paths"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
js.stripe.com/**) insideinjectMockStripe()so theaddInitScriptmock is never overwritten by the async-loaded Stripe SDKwaitForFunction(signUpWithEmail)calls in free-plan auth tests withwaitForLoadState(domcontentloaded)— deferred scripts execute before DOMContentLoaded, so this is a tighter and more reliable sync pointWhy this fixes CI
Group A (Stripe mock tests): The
<script src="https://js.stripe.com/v3/" async>tag fires after Playwright injects the mock viaaddInitScript. The real Stripe SDK replaceswindow.Stripe, thencheckout-stripe.js(defer) calls the real SDK with a fakeclient_secret, which fails silently —#stripe-mock-mountednever appears andsubmit-btnstays disabled forever. Blocking the CDN request entirely prevents the override.Group B (free plan auth tests): The obfuscated
checkout-auth.js(CI build) assignswindow.signUpWithEmailvia a decoded string table lookup. ThewaitForFunctionpoll 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.