fix(e2e): align local E2E setup with CI or document CI-only validation
This commit is contained in:
parent
04693d6bd7
commit
de2af0fb58
3 changed files with 85 additions and 1 deletions
|
|
@ -40,6 +40,8 @@ In CI (cd.yml), the smoke job runs after deploy when `STAGING_URL` (secret or va
|
|||
- **Chat server** (optionnel) : pour les tests Chat complets (envoi de message). Sans chat server, les tests Chat font du smoke (load UI, état déconnecté).
|
||||
- **Compte de test** : voir `e2e/utils/test-helpers.ts` : `TEST_USERS.default` (ou `TEST_EMAIL`, `TEST_PASSWORD`).
|
||||
|
||||
**Validation v0.101** : les E2E sont validés en **CI** (`.github/workflows/ci.yml`). En local, les credentials Postgres/RabbitMQ peuvent différer (voir `veza-backend-api/.env`). Script d'aide : `./scripts/run-e2e-local.sh` depuis la racine du repo (prérequis : `make infra-up`, backend démarré sur 18080, `veza.fr` dans `/etc/hosts`).
|
||||
|
||||
## Lancer les E2E
|
||||
|
||||
```bash
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ Ces routes affichent un placeholder "Coming Soon". **Ne pas développer** pour v
|
|||
- [x] `go test ./...` (backend) — 0 échec
|
||||
- [x] `npm test -- --run` (frontend) — 0 échec (validate-light)
|
||||
- [x] `npm run test:storybook` — 0 erreur console/réseau
|
||||
- [ ] E2E auth, smoke, playlists, search — 0 échec (CI only)
|
||||
- [ ] E2E auth, smoke, playlists, search — 0 échec (validé en CI ; local : `./scripts/run-e2e-local.sh`)
|
||||
|
||||
### 5.3 Qualité
|
||||
|
||||
|
|
|
|||
82
scripts/run-e2e-local.sh
Executable file
82
scripts/run-e2e-local.sh
Executable file
|
|
@ -0,0 +1,82 @@
|
|||
#!/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
|
||||
Loading…
Reference in a new issue