mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-10-31 18:19:43 +00:00
fix(e2e): align browser harness with local stack
This commit is contained in:
1 parent
db5980c9bd
commit
cf19d23d8a
20 files changed
+267
-85
No files matched your search
+44
-2
@@ -107,7 +107,7 @@ LOCAL_ADMIN_SERVICE_TOKEN="${ADMIN_API_SERVICE_TOKEN:-local-sauci-admin-service-
|
||||
LOCAL_MCP_API_KEY="${SAUCI_MCP_API_KEY:-local-sauci-mcp-only}"
|
||||
|
||||
SERVERS=(
|
||||
"api|PORT=$API_PORT DATABASE_URL=$LOCAL_DATABASE_URL MEDIA_ROOT=$ROOT/.local/media MEDIA_SIGNING_SECRET=local-media-signing-secret-change-me-123456 MEDIA_PUBLIC_BASE_URL=http://127.0.0.1:$API_PORT npm run dev -w @sauci/api"
|
||||
"api|PORT=$API_PORT DATABASE_URL=$LOCAL_DATABASE_URL CORS_ALLOWED_ORIGINS=http://127.0.0.1:$WEB_PORT MEDIA_ROOT=$ROOT/.local/media MEDIA_SIGNING_SECRET=local-media-signing-secret-change-me-123456 MEDIA_PUBLIC_BASE_URL=http://127.0.0.1:$API_PORT npm run dev -w @sauci/api"
|
||||
"worker|DATABASE_URL=$LOCAL_DATABASE_URL CLASSIFIER_ENABLED=false MEDIA_ROOT=$ROOT/.local/media MEDIA_SIGNING_SECRET=local-media-signing-secret-change-me-123456 MEDIA_PUBLIC_BASE_URL=http://127.0.0.1:$API_PORT npm run dev:worker -w @sauci/api"
|
||||
"web|env NEXT_PUBLIC_API_URL=$LOCAL_API_URL npm run dev -w @sauci/web -- --port $WEB_PORT"
|
||||
"admin|env VITE_API_URL=/ SAUCI_ADMIN_API_PROXY=$LOCAL_API_URL npm run dev -w @sauci/admin -- --host 127.0.0.1 --port $ADMIN_PORT"
|
||||
@@ -161,6 +161,13 @@ assert_local_database() {
|
||||
[ "$POSTGRES_PORT" = "54320" ] || die "Destructive reset requires the dedicated local PostgreSQL port 54320."
|
||||
}
|
||||
|
||||
assert_loopback_database() {
|
||||
case "$LOCAL_DATABASE_URL" in
|
||||
postgresql://*@127.0.0.1:*/*|postgresql://*@localhost:*/*) ;;
|
||||
*) die "Refusing E2E fixture operations against non-loopback URL: $LOCAL_DATABASE_URL" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
assert_allowed_auth() {
|
||||
local verdict
|
||||
verdict="$(node - "$AUTH_URL" <<'NODE'
|
||||
@@ -569,6 +576,40 @@ cmd_seed() {
|
||||
ok "Local migrations applied and configured fixtures created"
|
||||
}
|
||||
|
||||
wait_for_e2e_service() {
|
||||
local name="$1" url="$2" attempts=0
|
||||
command -v curl >/dev/null 2>&1 || die "curl is required for E2E health checks."
|
||||
until curl --fail --silent --show-error "$url" >/dev/null 2>&1; do
|
||||
attempts=$((attempts + 1))
|
||||
[ "$attempts" -lt 60 ] || die "Timed out waiting for local $name at $url"
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
cmd_e2e() {
|
||||
if [ "${SAUCI_E2E_REUSE:-false}" = "true" ]; then
|
||||
preflight
|
||||
assert_loopback_database
|
||||
[ -n "$AUTH_URL" ] || die "SUPABASE_AUTH_URL (or EXPO_PUBLIC_SUPABASE_URL) is required when reusing the local stack."
|
||||
assert_allowed_auth
|
||||
else
|
||||
cmd_up
|
||||
fi
|
||||
|
||||
wait_for_e2e_service "API" "$LOCAL_API_URL/health/live"
|
||||
wait_for_e2e_service "web" "http://127.0.0.1:$WEB_PORT/"
|
||||
wait_for_e2e_service "admin" "http://127.0.0.1:$ADMIN_PORT/"
|
||||
wait_for_e2e_service "MCP" "http://127.0.0.1:$MCP_PORT/health"
|
||||
|
||||
(cd "$ROOT" && env \
|
||||
E2E_DATABASE_URL="$LOCAL_DATABASE_URL" \
|
||||
E2E_API_URL="$LOCAL_API_URL" \
|
||||
WEB_URL="http://127.0.0.1:$WEB_PORT" \
|
||||
ADMIN_URL="http://127.0.0.1:$ADMIN_PORT" \
|
||||
MCP_URL="http://127.0.0.1:$MCP_PORT" \
|
||||
npm run test -w @sauci/e2e)
|
||||
}
|
||||
|
||||
cmd_native() {
|
||||
local platform="$1"
|
||||
preflight
|
||||
@@ -591,9 +632,10 @@ case "${1:-up}" in
|
||||
attach) tmux attach -t "$SESSION" ;;
|
||||
reset) cmd_reset ;;
|
||||
seed) cmd_seed ;;
|
||||
e2e) cmd_e2e ;;
|
||||
ios|android) cmd_native "$1" ;;
|
||||
help|-h|--help)
|
||||
echo "usage: scripts/dev-local.sh up|down [--all]|status|logs <service>|restart <service>|attach|reset|seed|ios|android"
|
||||
echo "usage: scripts/dev-local.sh up|down [--all]|status|logs <service>|restart <service>|attach|reset|seed|e2e|ios|android"
|
||||
;;
|
||||
*) die "unknown command '$1'" ;;
|
||||
esac
|
||||
Reference in new issue
Block a user