-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move e2e tests to a separate package
- [x] Update synpress - [x] Use module package for e2e tests
- Loading branch information
Showing
22 changed files
with
1,336 additions
and
2,775 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const path = require("path"); | ||
|
||
module.exports = { | ||
root: true, | ||
env: { | ||
node: true, | ||
jest: true, | ||
}, | ||
extends: ["../../.eslintrc.js", "plugin:playwright/playwright-test"], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
project: path.resolve(__dirname, "./tsconfig.json"), | ||
sourceType: "module", | ||
typescript: true, | ||
ecmaVersion: 2022, | ||
experimentalDecorators: true, | ||
requireConfigFile: false, | ||
ecmaFeatures: { | ||
classes: true, | ||
impliedStrict: true, | ||
}, | ||
warnOnUnsupportedTypeScriptVersion: true, | ||
}, | ||
overrides: [ | ||
{ | ||
files: ["./test/*.ts"], | ||
rules: { | ||
"playwright/prefer-lowercase-title": "error", | ||
"playwright/prefer-to-be": "error", | ||
"playwright/prefer-to-have-length": "error", | ||
"playwright/prefer-strict-equal": "error", | ||
"playwright/max-nested-describe": ["error", { max: 1 }], | ||
"playwright/no-restricted-matchers": [ | ||
"error", | ||
{ | ||
toBeFalsy: "Use `toBe(false)` instead.", | ||
not: null, | ||
}, | ||
], | ||
}, | ||
}, | ||
], | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.cache-synpress |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "maci-platform-interface-e2e", | ||
"version": "0.0.1", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"build:cache": "synpress", | ||
"build:cache:force": "synpress --force", | ||
"build:cache:headless": "synpress --headless", | ||
"types": "tsc -p tsconfig.json --noEmit", | ||
"install:chromium": "playwright install chromium", | ||
"test:playwright:headful": "playwright test", | ||
"test:playwright:headless": "HEADLESS=true playwright test", | ||
"test:playwright:headless:ui": "HEADLESS=true playwright test --ui" | ||
}, | ||
"dependencies": { | ||
"@playwright/test": "^1.48.2", | ||
"@synthetixio/synpress": "^4.0.3", | ||
"dotenv": "^16.4.5" | ||
}, | ||
"devDependencies": { | ||
"@synthetixio/synpress-tsconfig": "^0.0.4", | ||
"eslint-plugin-playwright": "^2.0.1", | ||
"@types/node": "^22.9.0", | ||
"typescript": "^5.6.3" | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Import necessary Synpress modules and setup | ||
import { testWithSynpress } from "@synthetixio/synpress"; | ||
import { MetaMask, metaMaskFixtures } from "@synthetixio/synpress/playwright"; | ||
|
||
import basicSetup from "./wallet-setup/basic.setup"; | ||
|
||
// Create a test instance with Synpress and BasicSetup | ||
const test = testWithSynpress(metaMaskFixtures(basicSetup)); | ||
|
||
// Extract expect function from test | ||
const { expect } = test; | ||
|
||
// Define a basic test case | ||
test("should connect wallet properly", async ({ context, page, extensionId }) => { | ||
// Create a new MetaMask instance | ||
const metamask = new MetaMask(context, page, basicSetup.walletPassword, extensionId); | ||
|
||
// Navigate to the homepage | ||
await page.goto("/"); | ||
|
||
// Click the connect button | ||
await page.getByRole("button", { name: "Connect wallet" }).first().click(); | ||
await page.getByTestId("rk-wallet-option-io.metamask").click(); | ||
|
||
// Connect MetaMask to the dapp | ||
await metamask.connectToDapp(); | ||
await metamask.confirmSignature(); | ||
await metamask.approveNewNetwork(); | ||
await metamask.approveSwitchNetwork(); | ||
|
||
// Verify the connected account address | ||
await expect(page.getByText(/0xf3.+2266/)).toBeInViewport({ timeout: 20000 }); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import dotenv from "dotenv"; | ||
|
||
dotenv.config(); | ||
|
||
export const NETWORKS = { | ||
optimismSepolia: { | ||
chainId: 11155420, | ||
name: "OP Sepolia", | ||
rpcUrl: `https://opt-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_ID!}`, | ||
symbol: "ETH", | ||
}, | ||
}; | ||
|
||
// Define a test seed phrase and password | ||
// Don't use it for production, only for e2e testing | ||
export const SEED_PHRASE = process.env.TEST_MNEMONIC || "test test test test test test test test test test test junk"; | ||
export const PASSWORD = process.env.WALLET_PASSWORD || "Tester@1234"; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { defineWalletSetup } from "@synthetixio/synpress"; | ||
import { MetaMask } from "@synthetixio/synpress/playwright"; | ||
|
||
import { PASSWORD, SEED_PHRASE } from "../constants"; | ||
|
||
// Define the basic wallet setup | ||
export default defineWalletSetup(PASSWORD, async (context, walletPage) => { | ||
// Create a new MetaMask instance | ||
const metamask = new MetaMask(context, walletPage, PASSWORD); | ||
|
||
// Import the wallet using the seed phrase | ||
await metamask.importWallet(SEED_PHRASE); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { defineWalletSetup } from "@synthetixio/synpress"; | ||
import { MetaMask, getExtensionId } from "@synthetixio/synpress/playwright"; | ||
import "dotenv/config"; | ||
|
||
import { PASSWORD, SEED_PHRASE } from "../constants"; | ||
|
||
export default defineWalletSetup(PASSWORD, async (context, walletPage) => { | ||
// This is a workaround for the fact that the MetaMask extension ID changes. | ||
// This workaround won't be needed in the near future! 😁 | ||
const extensionId = await getExtensionId(context, "MetaMask"); | ||
|
||
const metamask = new MetaMask(context, walletPage, PASSWORD, extensionId); | ||
|
||
await metamask.importWallet(SEED_PHRASE); | ||
|
||
const page = await context.newPage(); | ||
|
||
// Go to a locally hosted MetaMask Test Dapp. | ||
await page.goto(process.env.DEMO_URL || "http://localhost:3000"); | ||
|
||
await page.getByRole("button", { name: "Connect wallet" }).first().click(); | ||
await page.getByTestId("rk-wallet-option-io.metamask").click(); | ||
|
||
await metamask.connectToDapp(["Account 1"]); | ||
await metamask.confirmSignature(); | ||
await metamask.approveNewNetwork(); | ||
await metamask.approveSwitchNetwork(); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "@synthetixio/synpress-tsconfig/base.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"esModuleInterop": true, | ||
"sourceMap": false | ||
}, | ||
"include": ["test"] | ||
} |
This file contains 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.