AvanzaCast/scripts/smoke_studio_session.sh

35 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Smoke test: crea una sesión en backend-api y abre el studio URL en el navegador (Linux: xdg-open)
# Usage: ./scripts/smoke_studio_session.sh <room> [username]
set -euo pipefail
ROOM=${1:-smoke-test}
USERNAME=${2:-smoke-user}
BACKEND=${BACKEND_API:-http://localhost:4000}
echo "Creating session for room=$ROOM username=$USERNAME via ${BACKEND}/api/session"
resp=$(curl -s -X POST -H "Content-Type: application/json" -d "{\"room\": \"${ROOM}\", \"username\": \"${USERNAME}\"}" "${BACKEND}/api/session")
if [ -z "$resp" ]; then
echo "No response from backend"
exit 1
fi
echo "Response: $resp"
studioUrl=$(echo "$resp" | python3 -c "import sys, json; print(json.load(sys.stdin).get('studioUrl',''))")
if [ -z "$studioUrl" ]; then
echo "studioUrl not found in response"
exit 1
fi
echo "Opening studio URL: $studioUrl"
if command -v xdg-open >/dev/null 2>&1; then
xdg-open "$studioUrl"
elif command -v gnome-open >/dev/null 2>&1; then
gnome-open "$studioUrl"
else
echo "Open this URL in your browser: $studioUrl"
fi
echo "Smoke test completed (manual verification required: studio should auto-fetch token and connect)."