## test(web): Playwright E2E smoke — deploy, fund, whitelist, pay via injected test signer - #21
Conversation
|
@samad13 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
… injected test signer Closes #11
|
Merged to To get it running I pushed one follow-up commit (
With those, the smoke spec passes end-to-end against testnet in ~50s: connect → deploy → fund → whitelist → pay. Points should follow once the issue is marked completed on the Wave side. |
Context
The web app has an extensive vitest unit-test suite but zero browser-level tests. Regressions in wiring — hash routing, lazy chunks, wallet modal, and the connect → deploy → fund → whitelist → pay happy path — were only caught by hand today.
Scope
web/with a minimal config (one project, chromium is enough; auto-starts vite dev server)window.__PRISM_TEST_SIGNER__via Playwright'saddInitScript. The adapter lives atsrc/lib/walletSigner.ts's seam (walletKit.ts), gating the path behind two checks so it can never leak into production:VITE_ENABLE_TEST_SIGNER === "true"(compile-timeimport.meta.envliteral — dead code is tree-shaken)window.__PRISM_TEST_SIGNER__global is present (Playwright-only)workflow_dispatchonly (manual trigger). Testnet RPC flakiness means it does not gate every PR yetweb/with full run instructionsAcceptance Criteria
PLAYWRIGHT_TEST_WALLET_SECRET; ≥ 25 XLM covers deploy+fund+fee headroomPLAYWRIGHT_TEST_WALLET_SECRETenv var +secrets.PLAYWRIGHT_TEST_WALLET_SECRETin workflowVITE_ENABLE_TEST_SIGNER) AND runtime global (window.__PRISM_TEST_SIGNER__)web/README.md→E2E · Playwright smokesectionFiles
New:
web/playwright.config.ts— 1 chromium project; dev server starts vite withVITE_ENABLE_TEST_SIGNER=true; retains trace/screenshots/video on failure; 180s timeouts for testnet RPCweb/src/lib/testSigner.ts— Injection adapter: validates build flag + runtime global; returns Keypair-backedKitSignerthat signs via stellar-sdk directly (no wallet popup)web/tests/e2e/prismTest.ts—PrismPagepage-object helper + signer/context fixtures (signer, injected init script, typed UI actions)web/tests/e2e/smoke.spec.ts— Serial smoke spec: landing no errors → connect → friendbot → deploy 50/10 → fund 20 XLM → whitelist SERVICE → pay 1 XLM → assert balance ≤ 19 & zero uncaught page errors.github/workflows/e2e-playwright.yml—workflow_dispatch: deps install,playwright install --with-deps chromium, run spec, uploadplaywright-report/+test-results/as 14-day artifact on failureModified:
web/src/lib/walletKit.ts—connect()short-circuits to the injected address (skips authModal);walletSignerFor()returns the injected Keypair signer when address matchesweb/src/state/toast.tsx— Addsdata-toast-kind="success\|error\|info"for robust, non-brittle on-chain outcome assertionsweb/package.json— Addstest:e2e/test:e2e:installscripts;@playwright/testto devDepsweb/.gitignore— Ignoresplaywright-report/andtest-results/web/.env.example— DocumentsVITE_ENABLE_TEST_SIGNER(dev/test-only) andPLAYWRIGHT_TEST_WALLET_SECRET(CLI-only, never sent to bundle)web/README.md— Full E2E section: one-time setup, key generation + friendbot funding, run commands, 9-step spec walkthrough, gating diagram, CI setup instructionsWhy two gating layers?
import.meta.env.VITE_ENABLE_TEST_SIGNER === "true"as a literal during build. Without the flag it becomesundefined === "true"=false, and every test-signer branch is dead code that Vite/Rollup tree-shakes out of the production bundle entirely.testSignerAvailable()additionally requireswindow.__PRISM_TEST_SIGNER__— a global that Playwright injects viaaddInitScriptbefore app code runs. In a real browser, no global = no-op.How to run locally
How to run in CI
PLAYWRIGHT_TEST_WALLET_SECRETwith a funded testnet keytestnet-e2ewith reviewers to gate each run (avoids draining the shared key)chromium)Tested
npm install/ actual Playwright run couldn't be executed locally — dependency install and browser download are delegated to the first reviewer with a funded testnet key and free disk (per the README "One-time setup" steps)Closes #11