83 lines
3 KiB
Bash
83 lines
3 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
# E2E local — aligné sur la CI (.github/workflows/ci.yml)
|
||
|
|
# Prérequis : make infra-up, backend démarré, veza.fr dans /etc/hosts
|
||
|
|
#
|
||
|
|
# La CI utilise : DATABASE_URL=postgresql://veza:devpassword@localhost:15432/veza
|
||
|
|
# Si votre .env ou docker-compose utilise un autre mot de passe (ex: password),
|
||
|
|
# utilisez DATABASE_URL correspondant pour migrations et create_test_user.
|
||
|
|
#
|
||
|
|
# Validation v0.101 : les E2E sont validés en CI. En local, ce script peut
|
||
|
|
# échouer si les credentials (Postgres, RabbitMQ) ne correspondent pas à la CI.
|
||
|
|
|
||
|
|
set -e
|
||
|
|
|
||
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||
|
|
cd "$ROOT"
|
||
|
|
|
||
|
|
# Détecter DATABASE_URL : priorité à l'env
|
||
|
|
# CI utilise devpassword. Si .env local a DB_PASSWORD=password ou postgres://veza:password, utiliser :
|
||
|
|
# DATABASE_URL="postgresql://veza:password@localhost:15432/veza?sslmode=disable" ./scripts/run-e2e-local.sh
|
||
|
|
if [ -z "$DATABASE_URL" ]; then
|
||
|
|
if [ -f veza-backend-api/.env ] && grep -qE "DB_PASSWORD=password|postgres.*:password@" veza-backend-api/.env 2>/dev/null; then
|
||
|
|
export DATABASE_URL="postgresql://veza:password@localhost:15432/veza?sslmode=disable"
|
||
|
|
else
|
||
|
|
export DATABASE_URL="postgresql://veza:devpassword@localhost:15432/veza?sslmode=disable"
|
||
|
|
fi
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Credentials E2E (identiques à la CI)
|
||
|
|
export TEST_EMAIL="${TEST_EMAIL:-e2e@test.com}"
|
||
|
|
export TEST_PASSWORD="${TEST_PASSWORD:-Xk9\$mP2#vL7@nQ4!wR8}"
|
||
|
|
export TEST_USERNAME="${TEST_USERNAME:-e2e}"
|
||
|
|
|
||
|
|
echo "=== E2E local (auth, smoke, playlists, search) ==="
|
||
|
|
echo "DATABASE_URL: ${DATABASE_URL%%:*}:****"
|
||
|
|
echo "TEST_EMAIL: $TEST_EMAIL"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
# Vérifier veza.fr
|
||
|
|
if ! grep -q "veza.fr" /etc/hosts 2>/dev/null; then
|
||
|
|
echo "⚠️ veza.fr doit être dans /etc/hosts (ex: echo '127.0.0.1 veza.fr' | sudo tee -a /etc/hosts)"
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Vérifier infra
|
||
|
|
if ! docker exec veza_postgres pg_isready -U veza 2>/dev/null; then
|
||
|
|
echo "⚠️ Postgres non prêt. Lancer : make infra-up"
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Migrations
|
||
|
|
echo "[1/4] Migrations..."
|
||
|
|
cd veza-backend-api
|
||
|
|
go run cmd/migrate_tool/main.go up 2>/dev/null || true
|
||
|
|
cd ..
|
||
|
|
|
||
|
|
# Créer le user E2E
|
||
|
|
echo "[2/4] Création user E2E..."
|
||
|
|
cd veza-backend-api
|
||
|
|
go run cmd/tools/create_test_user/main.go
|
||
|
|
cd ..
|
||
|
|
|
||
|
|
# Vérifier backend
|
||
|
|
echo "[3/4] Vérification backend..."
|
||
|
|
if ! curl -sf http://localhost:18080/api/v1/health >/dev/null 2>&1; then
|
||
|
|
echo "⚠️ Backend non démarré sur 18080. Démarrer :"
|
||
|
|
echo " cd veza-backend-api && APP_PORT=18080 DATABASE_URL=\"\$DATABASE_URL\" REDIS_URL=redis://localhost:16379 \\"
|
||
|
|
echo " JWT_SECRET=dev-secret-key-minimum-32-characters-long RABBITMQ_URL=amqp://veza:devpassword@localhost:15672/ \\"
|
||
|
|
echo " DISABLE_RATE_LIMIT_FOR_TESTS=true ACCOUNT_LOCKOUT_EXEMPT_EMAILS=e2e@test.com go run cmd/api/main.go"
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Lancer E2E
|
||
|
|
echo "[4/4] Lancement Playwright..."
|
||
|
|
cd apps/web
|
||
|
|
PORT=5174 VITE_API_URL='/api/v1' VITE_DOMAIN=veza.fr VITE_BACKEND_PORT=18080 \
|
||
|
|
PLAYWRIGHT_BASE_URL='http://localhost:5174' CI=true \
|
||
|
|
npx playwright test \
|
||
|
|
e2e/tests/auth.spec.ts \
|
||
|
|
e2e/tests/smoke.spec.ts \
|
||
|
|
e2e/tests/playlists.spec.ts \
|
||
|
|
e2e/tests/search.spec.ts \
|
||
|
|
--project=chromium
|