Repository navigation
Expand file tree
/
Copy pathci-frontend-test-playwright
More file actions
executable file
·78 lines (64 loc) · 2.47 KB
/
Copy pathci-frontend-test-playwright
File metadata and controls
executable file
·78 lines (64 loc) · 2.47 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
70
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
set -e # Exit on error
export FS_ENV=test
dir=$(dirname "$0")
# shellcheck source=./__common.sh
source "$dir"/__common.sh
SCRIPT_START=$SECONDS
log-header "CI: Playwright E2E Tests"
echo ""
# Setup PHP environment
log-header "Setting up PHP environment"
bin/console foodsharing:setup
# Configure PHP-FPM paths for CI
tmpfile=$(mktemp)
sed "s#/app#$CI_PROJECT_DIR#g" /usr/local/etc/php-fpm.d/fpm.conf > "$tmpfile"
cat "$tmpfile" > /usr/local/etc/php-fpm.d/fpm.conf
rm "$tmpfile"
# Start PHP-FPM in background
php-fpm -R 2> php_fpm_err.log &
PHP_FPM_PID=$!
# Start mail queue worker
bin/console foodsharing:mailqueueworker &
MAIL_WORKER_PID=$!
# Trap to cleanup background processes on exit
trap "kill $PHP_FPM_PID $MAIL_WORKER_PID 2>/dev/null || true" EXIT
# Initialize database
log-header "Initializing database"
DB_START=$SECONDS
mariadb -u root -proot -hdb --execute="drop database if exists foodsharing; create database foodsharing"
vendor/bin/phinx migrate
vendor/bin/codecept foodsharing:test-seed
echo "✓ Database ready (${SECONDS}s elapsed)"
# Wait for assets
log-header "Waiting for assets"
ASSET_START=$SECONDS
wait-for-assets
echo "✓ Assets ready (${SECONDS}s elapsed)"
# Create database dump for Codeception
log-header "Creating database dump"
mariadb-dump --user root --password=root -hdb foodsharing > dump.sql
echo "✓ Dump created"
# Run Playwright tests
log-header "Running Playwright tests"
cd tests/e2e
# Install dependencies
npm install -g yarn@1.22.22 --force
yarn install --frozen-lockfile
# The CI image ships the browsers under $PLAYWRIGHT_BROWSERS_PATH. Installing
# only the engine this project needs keeps the step a no-op there and a small
# download anywhere else. The Safari projects are not in the CI matrix today,
# but they are defined in playwright.config.ts, so keep their engine mapped.
case "${PROJECT}" in
*Firefox*) browser=firefox ;;
*Safari*) browser=webkit ;;
*) browser=chromium ;;
esac
npx playwright install "${browser}"
PLAYWRIGHT_JUNIT_OUTPUT_NAME=../../tests/_output/report-playwright.xml \
npx playwright test --project="${PROJECT}"
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ E2E tests completed"
echo "⏱️ Total time: $((SECONDS - SCRIPT_START))s"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"