Skip to content

Commit ada1821

Browse files
committed
Merge remote-tracking branch 'upstream/main' into test/firmware-service-tests
2 parents ae2d1cf + dfaae6c commit ada1821

File tree

14 files changed

+2631
-84
lines changed

14 files changed

+2631
-84
lines changed

.gitignore

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,16 @@ tools/centrifugo
55
*.tar.gz
66
*.env
77
*.http
8-
/dist
98
.claude/
109
.gemini/
1110
.pnpm-store/
1211

12+
# Build outputs (root level only)
13+
/dist
14+
1315
# Generated WASM package (rebuild with wasm-pack)
1416
src/ui/src/core/pkg/
1517

1618
# Research and documentation files (generated, not part of source)
1719
*.md
1820
!README.md
19-
20-
# E2E Test Artifacts
21-
src/ui/playwright-report/
22-
src/ui/test-results/
23-
temp/

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,28 @@ Run `./build-and-deploy-image.sh --help` for all available options.
174174
### Testing
175175

176176
```bash
177-
# Run backend tests
177+
# Run all unit tests (backend + core)
178178
cargo test --features mock
179179

180-
# Run Crux Core tests
181-
cargo test -p omnect-ui-core
180+
# Run E2E tests (automated setup - starts Centrifugo + frontend dev server)
181+
./scripts/run-e2e-tests.sh
182182

183-
# Lint
183+
# Run E2E tests in Docker container (isolated environment)
184+
./scripts/test-e2e-in-container.sh
185+
186+
# Lint all code
184187
cargo clippy --all-targets --features mock
185188
```
186189

190+
#### Troubleshooting E2E Tests
191+
192+
If you encounter permission errors when running E2E tests (typically after running Docker-based tests), clean up files created by root:
193+
194+
```bash
195+
# Clean all E2E test artifacts with permission issues
196+
sudo rm -rf temp/certs src/ui/dist src/ui/test-results src/ui/playwright-report
197+
```
198+
187199
### VSCode Integration
188200

189201
The project includes VSCode launch configurations optimized for development:

scripts/run-e2e-tests.sh

Lines changed: 74 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,32 @@ set -e
33

44
# Internal script to run E2E tests inside the container
55

6+
# Cleanup function to kill spawned processes
7+
cleanup() {
8+
echo "🧹 Cleaning up processes..."
9+
[ -n "$FRONTEND_PID" ] && kill $FRONTEND_PID 2>/dev/null || true
10+
[ -n "$CENTRIFUGO_PID" ] && kill $CENTRIFUGO_PID 2>/dev/null || true
11+
}
12+
trap cleanup EXIT
13+
614
echo "🔧 Setting up test environment..."
715

8-
# 0. Ensure bun is installed (needed for UI)
16+
# 0. Kill any stale Vite/bun processes from previous runs
17+
echo "🧹 Cleaning up stale processes..."
18+
pkill -9 -f "vite.*--port 5173" 2>/dev/null || true
19+
pkill -9 -f "bun run.*5173" 2>/dev/null || true
20+
pkill -9 -f "node.*vite.*5173" 2>/dev/null || true
21+
sleep 2
22+
23+
# 1. Ensure bun is installed (needed for UI)
924
if ! command -v bun &> /dev/null; then
1025
echo "⚠️ Bun not found, installing..."
1126
curl -fsSL https://bun.sh/install | bash
1227
export BUN_INSTALL="$HOME/.bun"
1328
export PATH="$BUN_INSTALL/bin:$PATH"
1429
fi
1530

16-
# 1. Ensure Centrifugo is available (using the tool script if needed)
31+
# 2. Ensure Centrifugo is available (using the tool script if needed)
1732
if ! command -v centrifugo &> /dev/null; then
1833
echo "⚠️ Centrifugo not found in PATH, checking tools directory..."
1934
if [ ! -f "tools/centrifugo" ]; then
@@ -22,15 +37,24 @@ if ! command -v centrifugo &> /dev/null; then
2237
export PATH=$PATH:$(pwd)/tools
2338
fi
2439

25-
# 2. Start Centrifugo directly (Backend is mocked, but we need real WS)
40+
# 3. Start Centrifugo directly (Backend is mocked, but we need real WS)
2641
echo "🚀 Starting Centrifugo..."
2742
# Using the config from backend/config/centrifugo_config.json
2843
CENTRIFUGO_CONFIG="src/backend/config/centrifugo_config.json"
2944

3045
# Generate self-signed certs for testing if missing
3146
mkdir -p temp/certs
32-
if [ ! -f "temp/certs/server.cert.pem" ]; then
47+
if [ ! -f "temp/certs/server.cert.pem" ] || [ ! -r "temp/certs/server.key.pem" ]; then
48+
echo "🔐 Generating self-signed certificates..."
49+
# Check if old certs exist with wrong permissions
50+
if [ -f "temp/certs/server.cert.pem" ] && [ ! -w "temp/certs/server.cert.pem" ]; then
51+
echo "❌ Error: Old certificates exist with wrong permissions (likely created by root)"
52+
echo " Please run: sudo rm -rf temp/certs"
53+
exit 1
54+
fi
55+
rm -f temp/certs/server.cert.pem temp/certs/server.key.pem
3356
openssl req -newkey rsa:2048 -nodes -keyout temp/certs/server.key.pem -x509 -days 365 -out temp/certs/server.cert.pem -subj "/CN=localhost" 2>/dev/null
57+
chmod 644 temp/certs/server.key.pem temp/certs/server.cert.pem
3458
fi
3559

3660
# Env vars for Centrifugo
@@ -59,28 +83,52 @@ for i in {1..30}; do
5983
sleep 1
6084
done
6185

62-
# 3. Serve the Frontend
86+
# 4. Serve the Frontend
6387
echo "🌐 Starting Frontend Dev Server..."
6488
cd src/ui
89+
6590
# Install dependencies if needed (container might not have node_modules)
6691
if [ ! -d "node_modules" ]; then
6792
echo "📦 Installing UI dependencies..."
6893
bun install
6994
fi
7095

71-
# Start vite dev server in background
72-
bun run dev --port 5173 > /tmp/vite.log 2>&1 &
96+
# Check for permission issues with dist directory or its subdirectories
97+
if [ -d "dist" ]; then
98+
if [ ! -w "dist" ] || find dist -type d ! -writable 2>/dev/null | grep -q .; then
99+
echo "❌ Error: dist directory has wrong permissions (likely created by root)"
100+
echo " Please run: sudo rm -rf src/ui/dist"
101+
kill $CENTRIFUGO_PID || true
102+
exit 1
103+
fi
104+
fi
105+
106+
# Build the frontend for preview mode (eliminates Vite dev optimization issues)
107+
# Note: Using default base path (/) for preview server, not /static for production backend
108+
echo "🏗️ Building frontend..."
109+
if bun run build-preview > /tmp/vite-build.log 2>&1; then
110+
echo "✅ Frontend build complete!"
111+
else
112+
echo "❌ Frontend build failed!"
113+
cat /tmp/vite-build.log
114+
kill $CENTRIFUGO_PID || true
115+
exit 1
116+
fi
117+
118+
# Start Vite preview server (serves production build)
119+
echo "🚀 Starting Vite preview server..."
120+
bun run preview --port 5173 > /tmp/vite.log 2>&1 &
73121
FRONTEND_PID=$!
74122

75-
# Wait for Frontend
76-
echo "⏳ Waiting for Frontend..."
123+
# Wait for preview server
124+
echo "⏳ Waiting for preview server..."
77125
for i in {1..30}; do
78126
if curl -s http://localhost:5173 > /dev/null; then
79-
echo "Frontend is ready!"
127+
echo "Preview server is ready!"
80128
break
81129
fi
82130
if [ $i -eq 30 ]; then
83-
echo "Frontend failed to start."
131+
echo "Preview server failed to start."
84132
cat /tmp/vite.log
85133
kill $FRONTEND_PID || true
86134
kill $CENTRIFUGO_PID || true
@@ -89,8 +137,22 @@ for i in {1..30}; do
89137
sleep 1
90138
done
91139

92-
# 4. Run Playwright Tests
140+
# 5. Run Playwright Tests
93141
echo "🧪 Running Playwright Tests..."
142+
143+
# Check for permission issues with Playwright test results
144+
if [ -d "test-results" ] && [ ! -w "test-results" ]; then
145+
echo "❌ Error: Playwright test-results directory has wrong permissions (likely created by root)"
146+
echo " Please run: sudo rm -rf src/ui/test-results src/ui/playwright-report"
147+
kill $FRONTEND_PID || true
148+
kill $CENTRIFUGO_PID || true
149+
exit 1
150+
fi
151+
152+
# Install Playwright browsers (always run to ensure correct version)
153+
echo "📦 Ensuring Playwright browsers are installed..."
154+
npx playwright install chromium
155+
94156
# BASE_URL is set for playwright.config.ts
95157
export BASE_URL="http://localhost:5173"
96158

src/app/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ pub mod update;
99
#[cfg(target_arch = "wasm32")]
1010
pub mod wasm;
1111

12-
#[cfg(test)]
13-
mod tests;
14-
1512
use crux_core::Command;
1613

1714
// Using deprecated Capabilities API for Http (kept for Effect enum generation)

src/app/src/tests.rs

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)