Skip to content

Commit b4d5e16

Browse files
committed
fix: e2e tests
1 parent 9317322 commit b4d5e16

File tree

5 files changed

+62
-14
lines changed

5 files changed

+62
-14
lines changed

.github/workflows/e2e.yml

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ jobs:
3131
aztec-up 3.0.0-devnet.20251212
3232
aztec start --local-network &
3333
34+
- name: Wait for local network to be ready
35+
run: |
36+
echo "Waiting for Aztec node to be ready..."
37+
timeout 300 bash -c 'until curl -s http://localhost:8080/status > /dev/null 2>&1; do sleep 5; echo "Waiting..."; done'
38+
echo "Aztec node is ready!"
39+
3440
- name: Install dependencies
3541
run: yarn install
3642

@@ -40,5 +46,30 @@ jobs:
4046
- name: Build
4147
run: yarn build
4248

43-
- name: Run tests
44-
run: yarn test
49+
- name: Deploy contracts (prep for test)
50+
run: PROVER_ENABLED=false yarn deploy-contracts
51+
52+
- name: Start static server
53+
run: |
54+
echo "Starting static server..."
55+
yarn serve:static &
56+
SERVER_PID=$!
57+
echo $SERVER_PID > server.pid
58+
echo "Server PID: $SERVER_PID"
59+
echo "Waiting for server to be ready..."
60+
timeout 60 bash -c 'until curl -sf http://127.0.0.1:3000 > /dev/null 2>&1; do sleep 2; echo "Waiting..."; done'
61+
echo "Server is up!"
62+
63+
- name: Run Playwright tests
64+
run: yarn playwright test --reporter=list
65+
env:
66+
CI: true
67+
FORCE_COLOR: 1
68+
69+
- name: Stop server
70+
if: always()
71+
run: |
72+
if [ -f server.pid ]; then
73+
kill $(cat server.pid) || true
74+
rm server.pid
75+
fi

app/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ document.addEventListener('DOMContentLoaded', async () => {
5656
// Get existing account
5757
displayStatusMessage('Checking for existing account...');
5858
const account = await wallet.connectExistingAccount();
59-
await displayAccount();
59+
displayAccount();
6060

6161
// Refresh tally if account exists
6262
if (account) {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"build-app": "webpack --mode production",
1818
"build": "yarn build-contracts && yarn build-app",
1919
"serve": "webpack serve --mode production --port ${PORT:-3000}",
20+
"serve:static": "npx serve app/dist -l ${PORT:-3000}",
2021
"prep-test": "PROVER_ENABLED=false yarn deploy-contracts && yarn build-app",
2122
"test": "yarn prep-test && yarn playwright test",
2223
"lint": "prettier --check ./src"

playwright.config.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ export default defineConfig({
3333
},
3434
],
3535

36-
webServer: {
37-
command: 'PORT=3000 yarn serve',
38-
url: 'http://127.0.0.1:3000',
39-
reuseExistingServer: !process.env.CI,
40-
timeout: 30_000,
41-
},
36+
// In CI, server is started manually in the workflow for better visibility
37+
// Locally, Playwright handles starting the dev server
38+
webServer: process.env.CI
39+
? undefined
40+
: {
41+
command: 'PORT=3000 yarn serve',
42+
url: 'http://127.0.0.1:3000',
43+
reuseExistingServer: true,
44+
timeout: 120_000,
45+
},
4246
});

tests/e2e.spec.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,23 @@ const proofTimeout = 250_000;
66
test.beforeAll(async () => {
77
// Make sure the node is running
88
const nodeUrl = process.env.AZTEC_NODE_URL || 'http://localhost:8080';
9-
const nodeResp = await fetch(nodeUrl + '/status');
10-
if (!nodeResp.ok) {
11-
throw new Error(
12-
`Failed to connect to node. This test assumes you have a local network running at ${nodeUrl}.`
13-
);
9+
const controller = new AbortController();
10+
const timeoutId = setTimeout(() => controller.abort(), 30_000); // 30 second timeout
11+
12+
try {
13+
const nodeResp = await fetch(nodeUrl + '/status', { signal: controller.signal });
14+
clearTimeout(timeoutId);
15+
if (!nodeResp.ok) {
16+
throw new Error(
17+
`Failed to connect to node. This test assumes you have a local network running at ${nodeUrl}.`
18+
);
19+
}
20+
} catch (error) {
21+
clearTimeout(timeoutId);
22+
if (error.name === 'AbortError') {
23+
throw new Error(`Timeout connecting to node at ${nodeUrl}. Is the local network running?`);
24+
}
25+
throw error;
1426
}
1527
});
1628

0 commit comments

Comments
 (0)