diff --git a/scripts/verify_browser_runtime.sh b/scripts/verify_browser_runtime.sh index dea65c96..5c3431aa 100755 --- a/scripts/verify_browser_runtime.sh +++ b/scripts/verify_browser_runtime.sh @@ -4,6 +4,7 @@ set -euo pipefail FRONTEND_URL="${1:-http://localhost:1202}" BACKEND_HEALTH_URL="${2:-}" API_URL="${FRONTEND_URL%/}/api/v1/projects" +ICON_URL="${FRONTEND_URL%/}/geointel-icon.svg" if ! command -v curl >/dev/null 2>&1; then echo "curl is required for browser runtime verification" >&2 @@ -13,14 +14,37 @@ fi echo "== GeoIntel browser runtime verification ==" echo "Frontend: ${FRONTEND_URL}" echo "API through frontend proxy: ${API_URL}" +echo "Icon: ${ICON_URL}" + +frontend_status="" +api_response="" +icon_status="" + +for attempt in $(seq 1 60); do + frontend_status="$(curl -fsS -o /dev/null -w "%{http_code}" "${FRONTEND_URL}" 2>/dev/null || true)" + icon_status="$(curl -fsS -o /dev/null -w "%{http_code}" "${ICON_URL}" 2>/dev/null || true)" + api_response="$(curl -fsS "${API_URL}" 2>/dev/null || true)" + + if [ "${frontend_status}" = "200" ] \ + && [ "${icon_status}" = "200" ] \ + && printf '%s' "${api_response}" | grep -q '"data"'; then + break + fi + + echo "Browser runtime not ready yet (${attempt}/60): frontend=${frontend_status:-none} icon=${icon_status:-none}" + sleep 2 +done -frontend_status="$(curl -fsS -o /dev/null -w "%{http_code}" "${FRONTEND_URL}")" if [ "${frontend_status}" != "200" ]; then - echo "Frontend returned HTTP ${frontend_status}, expected 200" >&2 + echo "Frontend returned HTTP ${frontend_status:-none}, expected 200" >&2 + exit 1 +fi + +if [ "${icon_status}" != "200" ]; then + echo "Icon returned HTTP ${icon_status:-none}, expected 200" >&2 exit 1 fi -api_response="$(curl -fsS "${API_URL}")" case "${api_response}" in *"&2