-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from privacy-scaling-explorations/test/e2e-setup
test: setup e2e tests
- Loading branch information
Showing
27 changed files
with
4,626 additions
and
1,405 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,118 @@ | ||
name: E2E | ||
on: | ||
workflow_dispatch: | ||
|
||
schedule: | ||
- cron: "0 9 * * *" # run every day at 9:00 UTC | ||
|
||
push: | ||
branches: [main] | ||
pull_request: | ||
|
||
env: | ||
NEXT_PUBLIC_CHAIN_NAME: ${{ vars.NEXT_PUBLIC_CHAIN_NAME }} | ||
NEXT_PUBLIC_ADMIN_ADDRESS: ${{ vars.NEXT_PUBLIC_ADMIN_ADDRESS }} | ||
NEXT_PUBLIC_APPROVAL_SCHEMA: ${{ vars.NEXT_PUBLIC_APPROVAL_SCHEMA }} | ||
NEXT_PUBLIC_METADATA_SCHEMA: ${{ vars.NEXT_PUBLIC_METADATA_SCHEMA }} | ||
NEXT_PUBLIC_ROUND_ID: ${{ vars.NEXT_PUBLIC_ROUND_ID }} | ||
NEXT_PUBLIC_SKIP_APPROVED_VOTER_CHECK: false | ||
NEXT_PUBLIC_MACI_ADDRESS: ${{ vars.NEXT_PUBLIC_MACI_ADDRESS }} | ||
NEXT_PUBLIC_TALLY_URL: ${{ vars.NEXT_PUBLIC_TALLY_URL }} | ||
NEXT_PUBLIC_WALLETCONNECT_ID: ${{ secrets.NEXT_PUBLIC_WALLETCONNECT_ID }} | ||
NEXT_PUBLIC_FEEDBACK_URL: ${{ vars.NEXT_PUBLIC_FEEDBACK_URL }} | ||
NEXT_PUBLIC_MACI_START_BLOCK: ${{ vars.NEXT_PUBLIC_MACI_START_BLOCK }} | ||
NEXT_PUBLIC_MACI_SUBGRAPH_URL: ${{ vars.NEXT_PUBLIC_MACI_SUBGRAPH_URL }} | ||
NEXT_PUBLIC_EAS_CONTRACT_ADDRESS: ${{ vars.NEXT_PUBLIC_EAS_CONTRACT_ADDRESS }} | ||
NEXT_PUBLIC_EAS_SCHEMA_REGISTRY_ADDRESS: ${{ vars.NEXT_PUBLIC_EAS_SCHEMA_REGISTRY_ADDRESS }} | ||
NEXT_PUBLIC_SIGN_STATEMENT: ${{ vars.NEXT_PUBLIC_SIGN_STATEMENT }} | ||
NEXT_PUBLIC_TOKEN_NAME: ${{ vars.NEXT_PUBLIC_TOKEN_NAME }} | ||
NEXT_PUBLIC_MAX_VOTES_TOTAL: ${{ vars.NEXT_PUBLIC_MAX_VOTES_TOTAL }} | ||
NEXT_PUBLIC_MAX_VOTES_PROJECT: ${{ vars.NEXT_PUBLIC_MAX_VOTES_PROJECT }} | ||
NEXT_PUBLIC_EASSCAN_URL: ${{ vars.NEXT_PUBLIC_EASSCAN_URL }} | ||
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }} | ||
NEXT_PUBLIC_ALCHEMY_ID: ${{ secrets.NEXT_PUBLIC_ALCHEMY_ID }} | ||
NEXT_PUBLIC_START_DATE: ${{ vars.NEXT_PUBLIC_START_DATE }} | ||
NEXT_PUBLIC_REGISTRATION_END_DATE: ${{ vars.NEXT_PUBLIC_REGISTRATION_END_DATE }} | ||
NEXT_PUBLIC_REVIEW_END_DATE: ${{ vars.NEXT_PUBLIC_REVIEW_END_DATE }} | ||
NEXT_PUBLIC_VOTING_END_DATE: ${{ vars.NEXT_PUBLIC_VOTING_END_DATE }} | ||
NEXT_PUBLIC_RESULTS_DATE: ${{ vars.NEXT_PUBLIC_RESULTS_DATE }} | ||
NEXT_PUBLIC_POLL_MODE: ${{ vars.NEXT_PUBLIC_POLL_MODE }} | ||
TEST_MNEMONIC: ${{ secrets.TEST_MNEMONIC }} | ||
WALLET_PRIVATE_KEY: "" | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: [20] | ||
|
||
timeout-minutes: 120 | ||
runs-on: ubuntu-22.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: pnpm/action-setup@v4 | ||
with: | ||
version: 8 | ||
|
||
- name: Use Node.js 20 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: "pnpm" | ||
|
||
- name: Cache node modules | ||
uses: actions/cache@v4 | ||
continue-on-error: true | ||
with: | ||
path: | | ||
~/.pnpm-store | ||
node_modules | ||
/home/runner/.cache/Cypress | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-node- | ||
- name: Get installed Playwright version | ||
id: playwright-version | ||
run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package.json').devDependencies['@playwright/test'])")" >> $GITHUB_ENV | ||
|
||
- name: Cache playwright binaries | ||
uses: actions/cache@v4 | ||
id: playwright-cache | ||
continue-on-error: true | ||
with: | ||
path: | | ||
~/.cache/ms-playwright | ||
ms-playwright | ||
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} | ||
|
||
- name: Install dependencies | ||
run: |- | ||
pnpm install --frozen-lockfile --prefer-offline | ||
- name: Install Playwright Browsers | ||
if: steps.playwright-cache.outputs.cache-hit != 'true' | ||
run: |- | ||
pnpm run install:chromium | ||
- name: Build | ||
run: pnpm run build | ||
|
||
- name: Run Playwright tests | ||
uses: coactions/setup-xvfb@v1 | ||
with: | ||
run: pnpm run test:e2e | ||
|
||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
continue-on-error: true | ||
with: | ||
name: playwright-report | ||
path: ./playwright-report/ | ||
retention-days: 30 |
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 |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
|
||
# testing | ||
/coverage | ||
/playwright-report | ||
/test-results | ||
|
||
# next.js | ||
/.next/ | ||
|
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,4 @@ | ||
public-hoist-pattern[]=@types* | ||
public-hoist-pattern[]=cypress* | ||
public-hoist-pattern[]=@testing-library/cypress | ||
public-hoist-pattern[]=@synthetixio/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 |
---|---|---|
|
@@ -9,3 +9,5 @@ CODEOWNERS | |
.eslintignore | ||
zkeys | ||
public/mockServiceWorker.js | ||
playwright-report/ | ||
test-results/ |
File renamed without changes.
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,21 @@ | ||
import { test, expect } from "../playwright/fixtures"; | ||
|
||
test.describe("connect wallet", () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto("/"); | ||
}); | ||
|
||
test("should connect wallet using default metamask account", async ({ page }) => { | ||
await page.getByText(/Connect wallet/).click(); | ||
await page.getByTestId("rk-wallet-option-io.metamask").click(); | ||
|
||
const metamask = await page.context().waitForEvent("page"); | ||
await metamask.getByText("Next").click(); | ||
await metamask.getByTestId("page-container-footer-next").click(); | ||
|
||
await metamask.waitForTimeout(2_000); | ||
await metamask.getByTestId("page-container-footer-next").click(); | ||
|
||
await expect(page.getByText(/0xf3.+2266/)).toBeInViewport(); | ||
}); | ||
}); |
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,44 @@ | ||
import { defineConfig, devices } from "@playwright/test"; | ||
import dotenv from "dotenv"; | ||
|
||
dotenv.config(); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: "./e2e", | ||
timeout: process.env.CI ? 120_000 : 60_000, | ||
expect: { | ||
timeout: 15_000, | ||
}, | ||
maxFailures: 2, | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: 1, | ||
reporter: [["github"], ["list"], ["html", { open: "never" }]], | ||
use: { | ||
baseURL: process.env.DEMO_URL || "http://localhost:3000", | ||
trace: "on-first-retry", | ||
screenshot: "only-on-failure", | ||
headless: false, | ||
}, | ||
|
||
projects: [ | ||
{ | ||
name: "chromium", | ||
use: { ...devices["Desktop Chrome"] }, | ||
}, | ||
], | ||
webServer: !process.env.DEMO_URL | ||
? [ | ||
{ | ||
command: "pnpm run start", | ||
url: "http://localhost:3000", | ||
timeout: 120 * 1000, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
] | ||
: [], | ||
}); |
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,14 @@ | ||
import type { ChainConfig } from "@synthetixio/synpress/commands/metamask"; | ||
|
||
export const NETWORKS: Record<string, ChainConfig> = { | ||
optimismSepolia: { | ||
chainId: 11155420, | ||
name: "OP Sepolia", | ||
rpcUrl: `https://opt-sepolia.g.alchemy.com/v2/${process.env.NEXT_PUBLIC_ALCHEMY_ID!}`, | ||
symbol: "ETH", | ||
}, | ||
}; | ||
|
||
// Don't use it for production, only for e2e testing | ||
export const TEST_MNEMONIC = "test test test test test test test test test test test junk"; | ||
export const TEST_PASSWORD = "Tester@1234"; |
Oops, something went wrong.