SPB Git

Repository Public

e2e.sh 2.0 KB 26 lines shellscript

1#!/bin/bash2# End-to-end run against a throw-away database and a PRODUCTION build: migrate, bootstrap, start an SMTP sink,3# the worker and `next start`, then run Playwright.   scripts/e2e.sh [playwright args]4# E2E_PORT (default 8661) moves the server when the port is taken by another project.5# E-mails go through the real SMTP transport to scripts/e2e-smtp-sink.ts, which records what it receives.6set -euo pipefail7cd "$(dirname "$0")/.."8export DATABASE_URL="${E2E_DATABASE_URL:-postgres://127.0.0.1:5432/sp_calendar_e2e}"9PORT_E2E="${E2E_PORT:-8661}"10export APP_URL="http://localhost:$PORT_E2E" APP_SECRET="e2e-secret-e2e-secret-e2e-secret-0123456789" MAIL_TRANSPORT=smtp SMTP_URL="smtp://127.0.0.1:2526" MAIL_FROM="SP Calendar <calendar@example.test>" NODE_ENV=production11export PUBLIC_SUBMIT_PER_HOUR=500 PUBLIC_SUBMIT_PER_DAY=500   # the suite itself submits many requests from one address12export OWNER_EMAIL="owner@example.test" OWNER_NAME="Camille Tremblay" NEXT_TELEMETRY_DISABLED=113export SPCAL_TEST_OUTBOX="/tmp/spcal-e2e-outbox.jsonl" SETUP_URL_FILE="/tmp/spcal-e2e-setup-url.txt"14: > "$SPCAL_TEST_OUTBOX"15psql -q "$DATABASE_URL" -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;" >/dev/null 2>&116node_modules/.bin/tsx scripts/migrate.ts >/dev/null17node_modules/.bin/tsx scripts/bootstrap.ts >/dev/null18[ "${E2E_SKIP_BUILD:-}" = 1 ] || node_modules/.bin/next build > /tmp/spcal-e2e-build.log 2>&1 || { tail -30 /tmp/spcal-e2e-build.log; exit 1; }19node_modules/.bin/tsx scripts/e2e-smtp-sink.ts > /tmp/spcal-e2e-smtp.log 2>&1 & SINK=$!20node_modules/.bin/tsx src/worker/index.ts > /tmp/spcal-e2e-worker.log 2>&1 & WORKER=$!21node_modules/.bin/next start -p "$PORT_E2E" > /tmp/spcal-e2e-web.log 2>&1 & WEB=$!22trap 'kill $SINK $WORKER $WEB 2>/dev/null || true' EXIT23for _ in $(seq 1 60); do curl -sf -o /dev/null "$APP_URL/api/health" && break; sleep 1; done24curl -sf -o /dev/null "$APP_URL/api/health" || { echo "web did not start"; tail -20 /tmp/spcal-e2e-web.log; exit 1; }25PW_BASE_URL="$APP_URL" node_modules/.bin/playwright test "$@"26
Files main
Menu

Theme