-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathe2e.sh
More file actions
executable file
·69 lines (58 loc) · 2.3 KB
/
e2e.sh
File metadata and controls
executable file
·69 lines (58 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
#MISE description="Run end-to-end tests (Playwright); boots stack in test env, resets DB, runs tests"
#USAGE flag "--no-start" help="Skip compose up; only reset test DB and run Playwright (stack must already be up with e2e override)"
set -e
COMPOSE_FILES="-f docker-compose.yml -f docker-compose.e2e.yml"
NO_START="${usage_no_start:-false}"
BASE_URL="${BASE_URL:-http://127.0.0.1:8080}"
echo
echo "End-to-end tests (Playwright)"
echo "BASE_URL=${BASE_URL}"
echo
restore_dev_stack() {
echo ""
echo "Restoring dev stack (docker compose up -d)..."
docker compose up -d
}
if [ "${NO_START}" != "true" ]; then
trap restore_dev_stack EXIT
echo "Starting stack with e2e override..."
docker compose $COMPOSE_FILES up -d
echo "Waiting for MariaDB..."
for i in $(seq 1 30); do
if docker compose $COMPOSE_FILES exec -T mariadb mariadb -uroot -psecret -e "SELECT 1" 2>/dev/null; then
break
fi
echo "Waiting for MariaDB... ($i/30)"
sleep 2
done
echo "Waiting for app to respond on ${BASE_URL}..."
for i in $(seq 1 30); do
code=$(curl -s -o /dev/null -w "%{http_code}" "${BASE_URL}/" 2>/dev/null || true)
if [ "$code" = "200" ] || [ "$code" = "302" ]; then
break
fi
echo "Waiting for app... ($i/30)"
sleep 2
done
fi
echo "Resetting test database (drop, create, migrate)..."
docker compose $COMPOSE_FILES exec -T app php bin/console doctrine:database:drop --env=test --if-exists --force
docker compose $COMPOSE_FILES exec -T app php bin/console doctrine:database:create --env=test
docker compose $COMPOSE_FILES exec -T app php bin/console doctrine:migrations:migrate --no-interaction --env=test
echo "Creating default e2e user..."
docker compose $COMPOSE_FILES exec -T app php bin/console app:e2e:create-user e2e@example.com --password=e2e-secret
echo "Installing Playwright dependencies (if needed)..."
(cd tests/End2End && npm install)
(cd tests/End2End && npx playwright install chromium 2>/dev/null || true)
echo "Running Playwright tests..."
set +e
(cd tests/End2End && BASE_URL="$BASE_URL" npx playwright test)
PLAYWRIGHT_EXIT=$?
set -e
if [ $PLAYWRIGHT_EXIT -eq 0 ]; then
echo "E2E tests completed!"
else
echo "E2E tests failed (exit code $PLAYWRIGHT_EXIT)."
fi
exit $PLAYWRIGHT_EXIT