AvanzaCast/scripts/run-local-e2e.sh
Cesar Mendivil 8b458a3ddf feat: add initial LiveKit Meet integration with utility scripts, configs, and core components
- Add Next.js app structure with base configs, linting, and formatting
- Implement LiveKit Meet page, types, and utility functions
- Add Docker, Compose, and deployment scripts for backend and token server
- Provide E2E and smoke test scaffolding with Puppeteer and Playwright helpers
- Include CSS modules and global styles for UI
- Add postMessage and studio integration utilities
- Update package.json with dependencies and scripts for development and testing
2025-11-20 12:50:38 -07:00

68 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env zsh
set -euo pipefail
ROOT_DIR=$(cd "$(dirname "$0")/.." && pwd)
cd "$ROOT_DIR"
# Ensure backend is running (start in background if not)
HEALTH_URL="http://127.0.0.1:4000/health"
START_BACKEND="$ROOT_DIR/scripts/start-backend.sh background"
function wait_for_health() {
local tries=0
while [ $tries -lt 20 ]; do
if curl -sS -m 3 "$HEALTH_URL" >/dev/null 2>&1; then
echo "[ok] backend health ok"
return 0
fi
tries=$((tries+1))
echo "waiting for backend health... attempt $tries"
sleep 1
done
return 1
}
# Start backend if not healthy
if ! curl -sS -m 2 "$HEALTH_URL" >/dev/null 2>&1; then
echo "backend not healthy, starting..."
chmod +x "$ROOT_DIR/scripts/start-backend.sh"
"$ROOT_DIR/scripts/start-backend.sh" background || true
sleep 2
fi
if ! wait_for_health; then
echo "ERROR: backend did not become healthy"
echo "-- last backend logs --"
tail -n 200 "$ROOT_DIR/packages/backend-api/logs"/backend-*.log 2>/dev/null || true
exit 2
fi
# Create a session
ROOM="e2e-room-$(date +%s)"
USERNAME="e2e-user"
echo "Creating session for room=$ROOM user=$USERNAME"
CREATE_RESP=$(curl -sS -X POST "$HEALTH_URL"/../api/session -H "Content-Type: application/json" -d "{\"room\":\"$ROOM\",\"username\":\"$USERNAME\"}" ) || { echo "create session failed"; exit 3; }
echo "Create response: $CREATE_RESP"
# Parse id from response (fallback simple parse)
ID=$(echo "$CREATE_RESP" | sed -n 's/.*"id"[[:space:]]*:[[:space:]]*"\([^"]\+\)".*/\1/p')
if [ -z "$ID" ]; then
echo "Could not parse id from response. Full response:"; echo "$CREATE_RESP"; exit 4
fi
echo "Session id: $ID"
# Get token
TOKEN_RESP=$(curl -sS "http://127.0.0.1:4000/api/session/$ID/token" ) || { echo "get token failed"; exit 5; }
echo "Token response: $TOKEN_RESP"
# Optionally run puppeteer E2E if chrome remote is available
if curl -sS http://127.0.0.1:9222/json/version >/dev/null 2>&1; then
echo "Chrome remote debug available, running browser E2E script..."
PUPPETEER_BROWSER_URL=http://127.0.0.1:9222 BROADCAST_URL=http://localhost:5175 node packages/broadcast-panel/scripts/browser_e2e_local.cjs || true
echo "Browser E2E log:"
cat packages/broadcast-panel/tmp/browser_e2e_local.log 2>/dev/null || true
else
echo "Chrome remote debug not available; skipping browser E2E."
fi
echo "E2E finished"