feat: implement Synpress E2E testing pipeline with MetaMask wallet au… - #121
Open
Paranoa-dev wants to merge 1 commit into
Open
feat: implement Synpress E2E testing pipeline with MetaMask wallet au…#121Paranoa-dev wants to merge 1 commit into
Paranoa-dev wants to merge 1 commit 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
Contributor
|
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. |
Contributor
|
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 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.
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