mirror of
https://github.com/superdesigndev/treg.git
synced 2026-10-02 03:24:35 +08:00
The e2e server always took 127.0.0.1:18791, which is also the default port of a `treg serve` proxy, so two runs in parallel worktrees (or a run beside a proxy) collided: the second found the port taken, or its tests talked to the other run's server with the other build. playwright.config.ts now picks a port the OS reports free when the run starts and hands it to the server script and its workers through TREG_E2E_PORT, which also pins one by hand.
23 lines
1007 B
Bash
23 lines
1007 B
Bash
#!/usr/bin/env bash
|
|
# A disposable local database, with no dotenv file or external provider configuration.
|
|
# The port comes from frontend/playwright.config.ts, which picks a free one for each run.
|
|
set -euo pipefail
|
|
: "${TREG_E2E_PORT:?set by frontend/playwright.config.ts (or export one to run this by hand)}"
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
TEST_DIR="$(mktemp -d "${TMPDIR:-/tmp}/treg-browser.XXXXXX")"
|
|
trap 'rm -rf "$TEST_DIR"' EXIT
|
|
cd "$TEST_DIR"
|
|
export TREG_DATABASE_URL="sqlite+aiosqlite:///$TEST_DIR/test.db"
|
|
export TREG_PUBLIC_URL="http://127.0.0.1:$TREG_E2E_PORT"
|
|
export TREG_EMAIL_DEV_MODE=true
|
|
export TREG_FRONTEND_DEV=false
|
|
export TREG_PROMO_GRANT_MICRO=0
|
|
export TREG_RESEND_API_KEY=
|
|
export TREG_POSTHOG_KEY=
|
|
export TREG_INTERCOM_APP_ID=
|
|
export TREG_PLATFORM_PROVIDERS=
|
|
export PORT="$TREG_E2E_PORT"
|
|
export TREG_SECRET_KEY="$(uv run --project "$ROOT" python -m treg keygen)"
|
|
export TREG_SESSION_SECRET=local-disposable-browser-tests
|
|
uv run --project "$ROOT" python -m treg
|