feat: implement Synpress E2E testing pipeline with MetaMask wallet au… - #121
feat: implement Synpress E2E testing pipeline with MetaMask wallet au…#121Paranoa-dev wants to merge 2 commits into
Conversation
…tomation (closes Adamantine-guild#93) - Install and configure @synthetixio/synpress v4.1.2 for MetaMask automation - Add wallet setup fixture for importing test account seed phrase - Write E2E test for critical path: Connect Wallet -> Vault -> Deposit - Configure Playwright project targeting Synpress-enabled spec files - Add GitHub Actions workflow to build cache and run E2E tests on PRs - Add synpress:cache and test:e2e:synpress npm scripts - Create detailed documentation in docs/e2e-testing-pipeline.md
|
This PR has a workflow run awaiting approval, but it changes files inside Please review this PR manually before approving the workflow run. This is a safety measure because workflow changes can affect what runs with repository permissions. |
|
This PR cannot be merged automatically because it has merge conflicts. Please update the branch with the latest base branch and resolve the conflicts. After the conflicts are resolved and checks pass, the automation can review it again. |
|
This PR cannot be merged automatically because it has merge conflicts and one or more workflow checks failed. Please update the branch with the latest base branch, resolve the conflicts, and fix the failing workflow checks. After the conflicts are resolved and checks pass, the automation can review it again. |
…esting-93 # Conflicts: # package-lock.json
|
conflicts resolved |
|
Even with the conflicts resolved the pr has refused to merge |
E2E Testing Pipeline with Playwright + Synpress
Background
The application previously relied solely on basic unit tests with no automated browser tests that verify frontend wallet connection and transaction signing flows. Frequent UI updates occasionally broke core smart contract interaction flows, and manual regression testing before every deployment was tedious and error-prone.
Implementation Summary
This PR introduces a robust End-to-End testing pipeline utilizing Playwright and Synpress (a MetaMask automation wrapper) to simulate real user wallet interactions in a headless browser.
Files Added / Modified
e2e/wallet-setup/metamask.setup.tse2e/fixtures.tstestwith MetaMask automation fixtures (context,page,metamask,extensionId)e2e/deposit.spec.tsplaywright.config.ts.github/workflows/e2e-tests.ymlmainpackage.jsonsynpress:cache(builds MetaMask wallet cache) andtest:e2e:synpress(runs Synpress-gated tests).gitignore.cache-synpress/to ignore cached MetaMask extension binariesArchitecture
flowchart LR A[Wallet Setup<br/>metamask.setup.ts] --> B[Synpress CLI<br/>npx synpress] B --> C[Cached Browser Context<br/>/.cache-synpress/] C --> D[Playwright Fixtures<br/>e2e/fixtures.ts] D --> E[Synpress Test<br/>e2e/deposit.spec.ts] F[Next.js App] --> E G[MetaMask Extension] --> DHow It Works
Wallet Setup (
metamask.setup.ts): UsesdefineWalletSetupfrom Synpress to declare a test wallet with a known seed phrase (test test test test test test test test test test test junk) and password (Synpress123!).Cache Creation (
npx synpress e2e/wallet-setup --headless):/.cache-synpress/(hashed by wallet setup)Test Fixtures (
e2e/fixtures.ts):testWithSynpress(metaMaskFixtures(walletSetup))creates a customtestfunctioncontext(PersistentContext with MetaMask loaded),page(dapp page),metamask(MetaMask automation API),extensionId(for notification page targeting)E2E Test (
deposit.spec.ts):metamask.connectToDapp()to approve the connection in the MetaMask notification page/dashboardand locates the Vault Dashboard1.5as the stake amountCI Pipeline
The GitHub Actions workflow (
.github/workflows/e2e-tests.yml):fs.mkdtemp)Key Design Decisions
Synpress v4 with
metaMaskFixtures: Uses the official Synpress MetaMask fixture system which handles extension download, wallet import caching, and notification page automation.Separate fixture file: The
e2e/fixtures.tspattern keeps Synpress imports isolated from the base Playwright test, allowing existing non-MetaMask e2e tests (wallet-connect.spec.ts,vaults-responsive.spec.ts) to continue working unchanged.Headless cache build: The
--headlessflag ensures the MetaMask cache is built in CI without a display server.Simulated vault staking: Since the application's vault staking is currently frontend-only (setTimeout-based simulation), the test validates the UI flow end-to-end rather than on-chain state changes. The Synpress pipeline is proven for future real contract interactions.
Running Locally
Expanding the Test Suite
Add new test files in
e2e/that import from./fixtures:Available MetaMask actions via the
metamaskfixture:connectToDapp(accounts?)— approve dapp connectionconfirmTransaction(options?)— approve transaction (with gas settings)rejectTransaction()— reject transactionapproveTokenPermission(options?)— approve token spend allowancesignMessage()/rejectMessage()— sign/reject typed messagesswitchNetwork(networkName, isTestnet?)— switch MetaMask networkaddNetwork(network)— add custom network (e.g., Anvil local fork)closes #93