Skip to content

Commit 189e5de

Browse files
authored
chore: e2e tests (#69)
* chore: e2e tests for txns * fix: update data test ids * fix: update tests * fix: actions * fix: actions * fix: actions * fix: actions * fix: actions * fix: increase timeout * fix: increase timeout * fix: add timeouts and video recording * fix: reduce wait timeout * fix: timeouts * fix: timeouts * fix: add video recording * fix: remove switch network popup * fix: double call metamask * fix: double call metamask * fix: double call metamask * fix: double call metamask * fix: local networ rpc change * fix: local networ rpc change * fix: local networ rpc change * ci: trigger e2e workflow * fix: reject internal blockchain trnsactions * fix: e2e wallet setpup * fix: e2e wallet setpup * fix: tokenId * fix: token id
1 parent 291913b commit 189e5de

44 files changed

Lines changed: 22888 additions & 8825 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/e2e.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
workflow_dispatch: # allow manual trigger
9+
10+
jobs:
11+
e2e:
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 60
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
cache: 'npm'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Install Playwright browsers
29+
run: npx playwright install chromium --with-deps
30+
31+
# ── Hardhat node ─────────────────────────────────────────────────────
32+
- name: Start Hardhat node
33+
run: npx hardhat node &
34+
env:
35+
# Give the node a moment before we use it
36+
NODE_OPTIONS: --max-old-space-size=4096
37+
38+
- name: Wait for Hardhat node
39+
run: npx wait-on http://127.0.0.1:8545 --timeout 180000
40+
41+
- name: Deploy contracts and mint tokens
42+
run: node e2e/setup-contracts.cjs
43+
44+
# ── Dev server ───────────────────────────────────────────────────────
45+
- name: Start dev server
46+
run: npm run dev &
47+
env:
48+
VITE_APP_NETWORK: local
49+
VITE_NETWORK_TYPE: testnet
50+
VITE_RPC_URL_1337: http://127.0.0.1:8545
51+
52+
- name: Wait for dev server
53+
run: npx wait-on http://localhost:5173 --timeout 180000
54+
55+
# ── MetaMask wallet cache ────────────────────────────────────────────
56+
# Cache the wallet setup so it is not rebuilt on every run.
57+
- name: Cache MetaMask wallet
58+
id: metamask-cache
59+
uses: actions/cache@v4
60+
with:
61+
path: .cache-synpress
62+
key: metamask-wallet-${{ hashFiles('e2e/wallet-setup/**') }}
63+
64+
- name: Build MetaMask wallet cache
65+
if: steps.metamask-cache.outputs.cache-hit != 'true'
66+
timeout-minutes: 10
67+
run: npm run e2e:setup-wallet -- --headless
68+
env:
69+
HEADLESS: 'true'
70+
71+
# ── E2E tests ────────────────────────────────────────────────────────
72+
- name: Start Xvfb virtual display
73+
run: |
74+
Xvfb :99 -screen 0 1280x720x24 >/dev/null 2>&1 &
75+
sleep 1
76+
77+
- name: Install ffmpeg
78+
run: sudo apt-get install -y ffmpeg
79+
80+
- name: Start screen recording
81+
run: |
82+
ffmpeg -f x11grab -video_size 1280x720 -framerate 15 \
83+
-i :99 -c:v libx264 -preset ultrafast -pix_fmt yuv420p \
84+
/tmp/e2e-recording.mp4 &
85+
echo $! > /tmp/ffmpeg.pid
86+
87+
- name: Run E2E tests
88+
run: npm run e2e
89+
env:
90+
DISPLAY: ':99'
91+
CI: 'true'
92+
93+
- name: Stop screen recording
94+
if: always()
95+
run: |
96+
kill $(cat /tmp/ffmpeg.pid) 2>/dev/null || true
97+
sleep 2
98+
99+
# ── Artifacts ────────────────────────────────────────────────────────
100+
- name: Upload Playwright report
101+
if: always()
102+
uses: actions/upload-artifact@v4
103+
with:
104+
name: playwright-report
105+
path: playwright-report/
106+
retention-days: 7
107+
108+
- name: Upload screen recording
109+
if: always()
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: screen-recording
113+
path: /tmp/e2e-recording.mp4
114+
retention-days: 7
115+
if-no-files-found: ignore
116+
117+
- name: Upload screenshots on failure
118+
if: failure()
119+
uses: actions/upload-artifact@v4
120+
with:
121+
name: test-results
122+
path: test-results/
123+
retention-days: 7
124+
if-no-files-found: ignore

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ trustvc-cms/.sanity
3838
# Misc
3939
*.pem
4040
*.tsbuildinfo
41+
42+
# Playwright / Synpress
43+
.cache-synpress
44+
playwright-report
45+
test-results
46+
cache

e2e/fixtures.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { testWithSynpress } from '@synthetixio/synpress'
2+
import { MetaMask, metaMaskFixtures } from '@synthetixio/synpress/playwright'
3+
import BasicSetup from './wallet-setup/basic.setup'
4+
5+
const test = testWithSynpress(metaMaskFixtures(BasicSetup))
6+
const { expect } = test
7+
8+
export { test, expect, MetaMask, BasicSetup }

0 commit comments

Comments
 (0)