Skip to content

Commit b0d8fcc

Browse files
committed
fix: make backend wait on server start, change workflows to execute e2e tests
1 parent f94977d commit b0d8fcc

3 files changed

Lines changed: 84 additions & 14 deletions

File tree

.github/workflows/e2e-tests.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: E2E Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- develop
8+
- production
9+
- "frontend/**"
10+
- "testing-view/**"
11+
- "e2e/**"
12+
paths:
13+
- "frontend/testing-view/**"
14+
- "electron-app/**"
15+
- "e2e/**"
16+
- "pnpm-lock.yaml"
17+
- ".github/workflows/e2e-tests.yaml"
18+
19+
jobs:
20+
e2e:
21+
name: Playwright E2E Tests
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- uses: actions/setup-go@v5
27+
with:
28+
go-version: "1.23"
29+
30+
- name: Install Linux build dependencies
31+
run: sudo apt-get update && sudo apt-get install -y gcc
32+
33+
- name: Build backend binary
34+
working-directory: backend/cmd
35+
run: go build -o ../../electron-app/binaries/backend-linux-amd64 .
36+
env:
37+
CGO_ENABLED: 1
38+
39+
- uses: pnpm/action-setup@v4
40+
41+
- uses: actions/setup-node@v4
42+
with:
43+
node-version: "20"
44+
cache: "pnpm"
45+
46+
- name: Install dependencies
47+
run: pnpm install --frozen-lockfile
48+
49+
- name: Install Playwright dependencies
50+
run: pnpm --filter e2e exec playwright install --with-deps chromium
51+
52+
- name: Build testing-view (e2e mode)
53+
run: pnpm --filter testing-view build:e2e
54+
55+
- name: Run UI tests
56+
run: pnpm --filter e2e exec playwright test tests/ui
57+
58+
- name: Upload test report
59+
if: always()
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: playwright-report
63+
path: e2e/playwright-report/
64+
retention-days: 7

.github/workflows/frontend-tests.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ on:
1414
- "pnpm-lock.yaml"
1515
- ".github/workflows/frontend-tests.yaml"
1616

17-
push:
18-
branches:
19-
- "frontend/**"
20-
- "testing-view/**"
21-
- "competition-view/**"
22-
paths:
23-
- "frontend/**"
24-
- "pnpm-lock.yaml"
25-
- ".github/workflows/frontend-tests.yaml"
26-
2717
jobs:
2818
test:
2919
name: Run Frontend Tests

electron-app/src/processes/backend.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,26 @@ async function startBackend(logWindow = null) {
7575

7676
// Log stdout output from backend
7777
backendProcess.stdout.on("data", (data) => {
78-
logger.backend.info(`${data.toString().trim()}`);
78+
const text = data.toString().trim();
79+
logger.backend.info(text);
7980

8081
// Send log message to log window
8182
if (currentLogWindow && !currentLogWindow.isDestroyed()) {
82-
const htmlData = convert.toHtml(data.toString().trim());
83+
const htmlData = convert.toHtml(text);
8384
currentLogWindow.webContents.send("log", htmlData);
8485
}
86+
87+
// Resolve as soon as the TCP server confirms it is listening.
88+
// Matches: "..\pkg\transport\network\tcp\server.go:51 > listening"
89+
if (
90+
text.includes("tcp") &&
91+
text.includes("server.go") &&
92+
text.includes("listening")
93+
) {
94+
logger.backend.info("Backend ready (TCP server listening)");
95+
clearTimeout(startupTimer);
96+
resolve(backendProcess);
97+
}
8598
});
8699

87100
// Capture stderr output (where Go errors/panics are written)
@@ -130,10 +143,13 @@ async function startBackend(logWindow = null) {
130143
backendProcess = null;
131144
});
132145

133-
// If the backend didn't fail in this period of time, resolve the promise
146+
// Fallback: if the ready message never appears, resolve anyway after timeout
134147
const startupTimer = setTimeout(() => {
148+
logger.backend.warning(
149+
"Backend ready signal not received - resolving after timeout",
150+
);
135151
resolve(backendProcess);
136-
}, 3000);
152+
}, 5000);
137153
});
138154
}
139155

0 commit comments

Comments
 (0)