Skip to content

Commit 92aa2c9

Browse files
authored
Fix UI test timeouts, TypeScript compilation, dependency compatibility, and backend tests with isolated test suite using per-test mocking (#930)
1 parent 5a54ba4 commit 92aa2c9

14 files changed

Lines changed: 3125 additions & 657 deletions

.github/copilot-instructions.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,59 @@ yarn lint
188188
yarn lint:fix
189189
```
190190

191+
### Running UI Tests (yarn test:ui)
192+
193+
The UI tests require specific setup in the test environment:
194+
195+
**Prerequisites:**
196+
1. **Xvfb (X Virtual Framebuffer)** - Required for headless Electron testing
197+
```bash
198+
# Start Xvfb on display :99
199+
Xvfb :99 -screen 0 1024x720x24 -ac &
200+
export DISPLAY=:99
201+
```
202+
203+
2. **Mosquitto MQTT Broker** - Required for MQTT message testing
204+
```bash
205+
# Install mosquitto
206+
sudo apt-get install -y mosquitto mosquitto-clients
207+
208+
# Start mosquitto service
209+
sudo systemctl start mosquitto
210+
211+
# Verify it's running on port 1883
212+
sudo systemctl status mosquitto
213+
```
214+
215+
3. **@types/node** - Required for TypeScript compilation
216+
```bash
217+
yarn add -D @types/node
218+
```
219+
220+
**Running UI Tests:**
221+
```bash
222+
# Build the application first
223+
yarn build
224+
225+
# Run UI tests with proper display
226+
DISPLAY=:99 yarn test:ui
227+
```
228+
229+
**Common Issues:**
230+
- **"Timeout exceeded" in before hook**: Mosquitto is not running or not accessible on port 1883
231+
- **"Cannot find type definition file for 'node'"**: Run `yarn add -D @types/node`
232+
- **Electron fails to launch**: Xvfb is not running or DISPLAY variable not set
233+
- **Tests hang**: Check if old Electron/mosquitto processes are still running and kill them
234+
235+
**Environment Cleanup:**
236+
```bash
237+
# Kill old Electron processes
238+
ps aux | grep electron | grep -v grep | awk '{print $2}' | xargs kill -9 2>/dev/null
239+
240+
# Kill old mosquitto processes (if running custom instance)
241+
ps aux | grep mosquitto | grep -v grep | awk '{print $2}' | xargs kill -9 2>/dev/null
242+
```
243+
191244
## MCP Introspection Testing
192245

193246
The project supports MCP (Model Context Protocol) for automated testing with Playwright:

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
- name: Build
3434
run: yarn build
3535
- name: Run UI Tests
36+
timeout-minutes: 10
3637
run: ./scripts/runUiTests.sh
3738
- name: Upload Test Screenshots
3839
if: always()

backend/package.json

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
"description": "",
55
"main": "build/index.js",
66
"scripts": {
7-
"test": "mocha --require ts-node/register --require source-map-support/register --recursive ./src/*/**/*.spec.ts",
7+
"test": "NODE_PATH=../node_modules TS_NODE_PROJECT=./tsconfig.json mocha --require ts-node/register --require source-map-support/register --recursive ./src/*/**/*.spec.ts",
88
"build": "tsc",
9-
"test-inspect": "mocha --inspect-brk --require ts-node/register --require source-map-support/register --recursive ./src/*/**/*.spec.ts",
10-
"coverage": "nyc mocha --require ts-node/register --require source-map-support/register --recursive ./src/*/**/*.spec.ts",
11-
"debug": "ts-node --inspect ./src/index.ts",
12-
"postinstall": "yarn build"
9+
"test-inspect": "NODE_PATH=../node_modules TS_NODE_PROJECT=./tsconfig.json mocha --inspect-brk --require ts-node/register --require source-map-support/register --recursive ./src/*/**/*.spec.ts",
10+
"coverage": "NODE_PATH=../node_modules TS_NODE_PROJECT=./tsconfig.json nyc mocha --require ts-node/register --require source-map-support/register --recursive ./src/*/**/*.spec.ts",
11+
"debug": "ts-node --inspect ./src/index.ts"
1312
},
1413
"engines": {
1514
"node": ">=20"
@@ -38,12 +37,31 @@
3837
"sourceMap": true,
3938
"instrument": true
4039
},
41-
"peerDependencies": {
42-
"fs-extra": "^8.0.1",
43-
"js-base64": "^2.5.1",
44-
"long": "^4.0.0",
40+
"dependencies": {
41+
"@types/sha1": "^1.1.5",
42+
"builder-util-runtime": "^9",
43+
"fs-extra": "9",
44+
"js-base64": "^3.7.2",
4545
"lowdb": "^1.0.0",
46-
"mqtt": "^3.0.0",
47-
"protobufjs": "^6.11.4"
46+
"mqtt": "^4.3.6",
47+
"protobufjs": "^8.0.0",
48+
"sha1": "^1.1.1",
49+
"uuid": "^8.3.2"
50+
},
51+
"devDependencies": {
52+
"@types/chai": "^4.1.7",
53+
"@types/fs-extra": "8",
54+
"@types/lowdb": "^1.0.6",
55+
"@types/mocha": "^7.0.2",
56+
"@types/node": "^25.0.3",
57+
"@types/sha1": "^1.1.1",
58+
"@types/uuid": "^8.3.4",
59+
"chai": "^4.2.0",
60+
"electron": "29.2.0",
61+
"mocha": "^10.4.0",
62+
"nyc": "15",
63+
"source-map-support": "^0.5.9",
64+
"ts-node": "^10.9.2",
65+
"typescript": "^4.5.5"
4866
}
49-
}
67+
}

backend/tsconfig.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,21 @@
66
"strictNullChecks": true,
77
"outDir": "./build",
88
"strict": true,
9+
"module": "commonjs",
10+
"moduleResolution": "node",
11+
"target": "ES2017",
912
"lib": [
1013
"es2017",
1114
"dom"
1215
],
13-
"sourceMap": true
16+
"sourceMap": true,
17+
"esModuleInterop": true
18+
},
19+
"ts-node": {
20+
"compilerOptions": {
21+
"module": "commonjs"
22+
},
23+
"transpileOnly": true
1424
},
1525
"includes": [
1626
"src/**/*.ts"
@@ -20,6 +30,8 @@
2030
"node_modules",
2131
"src/**/*.spec.ts",
2232
"**/*.d.ts",
23-
"typings"
33+
"typings",
34+
"../events",
35+
"../app"
2436
]
2537
}

0 commit comments

Comments
 (0)