#!/usr/bin/env bash # Playwright-E2E (Projekte api, web, throttle) gegen den laufenden Supabase-Stack im dind (Issue #38, D2). # Voraussetzungen: DOCKER_HOST/DOCKER_GW gesetzt, `supabase start` lief, Extra-GoTrue auf :9998 laeuft, # Web-Build in app/build/web. Die Supabase-Ports liegen im dind; ein TCP-Relay macht sie unter # 127.0.0.1 erreichbar, wie es die Tests und die Web-App (CORS/Origin, Site-URL localhost:3000) erwarten. # Der Spike (SPIKE_GOTRUE_URL) laeuft in CI bewusst nicht. set -euo pipefail : "${DOCKER_GW:?DOCKER_GW (dind-Gateway) fehlt}" : "${SUPABASE_ANON_KEY:?SUPABASE_ANON_KEY fehlt}" node e2e/support/tcp-forward.mjs "$DOCKER_GW" 54321 54322 54324 9998 & relay=$! trap 'kill "$relay" 2>/dev/null || true' EXIT # Warten, bis die Dienste HINTER dem Relay antworten (nicht nur der lokale Port); Timeout = Fehler. wait_http() { for _ in $(seq 1 60); do curl -fsS -o /dev/null --max-time 3 -H "apikey: ${SUPABASE_ANON_KEY}" "$1" 2>/dev/null && return 0 sleep 1 done echo "Timeout: $1 nicht erreichbar (Relay zu ${DOCKER_GW})" >&2 return 1 } wait_http "http://127.0.0.1:54321/auth/v1/health" || exit 1 # Kong -> GoTrue wait_http "http://127.0.0.1:54324/api/v1/info" || exit 1 wait_http "http://127.0.0.1:9998/health" || exit 1 pg_ok="" for _ in $(seq 1 60); do if (exec 3<>/dev/tcp/127.0.0.1/54322) 2>/dev/null; then pg_ok=1; break; fi sleep 1 done [ -n "$pg_ok" ] || { echo "Timeout: Postgres 54322 nicht erreichbar" >&2; exit 1; } export SUPABASE_URL=http://127.0.0.1:54321 export MAILPIT_URL=http://127.0.0.1:54324 export E2E_DB_URL=postgresql://postgres:postgres@127.0.0.1:54322/postgres export WEB_URL=http://localhost:3000 export THROTTLE_GOTRUE_URL=http://127.0.0.1:9998 export CI=true cd e2e npx playwright test --project=api --project=web --project=throttle