mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 11:08:12 +00:00
64 lines
2.5 KiB
Bash
Executable File
64 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# One command for the HR + Finance e2e suite:
|
|
# build → seed → (Playwright boots the stack) → run → report
|
|
#
|
|
# bash e2e-hr-finance/run.sh # everything
|
|
# bash e2e-hr-finance/run.sh --headed # watch it
|
|
# bash e2e-hr-finance/run.sh hr # only specs/hr
|
|
# SKIP_SEED=1 bash e2e-hr-finance/run.sh # re-run without re-seeding
|
|
#
|
|
# Requires DB_PASSWORD for the seeders. Everything else has a default.
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$ROOT"
|
|
|
|
export DB_NAME="${DB_NAME:-smart_office_e2e}"
|
|
export DB_HOST="${DB_HOST:-localhost}"
|
|
export DB_PORT="${DB_PORT:-5432}"
|
|
export DB_USER="${DB_USER:-postgres}"
|
|
|
|
# Local convenience default — CHANGE THIS to your actual local Postgres
|
|
# password, or just export DB_PASSWORD in your shell instead and leave this
|
|
# alone. Either way: NEVER commit this file with a real password in it. If
|
|
# you edit the line below, `git diff` it before any commit and revert it, or
|
|
# keep the password out of git entirely by exporting DB_PASSWORD instead.
|
|
export DB_PASSWORD="${DB_PASSWORD:-TradingTria@2090}"
|
|
|
|
# A checked-in password reaching the production replica would be a real
|
|
# incident, not an inconvenience. Refuse early and unmistakably.
|
|
if [[ "$DB_NAME" == "smart_office_prod" ]]; then
|
|
echo "refusing to run the e2e suite against smart_office_prod" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z "${DB_PASSWORD:-}" || "$DB_PASSWORD" == "CHANGE_ME_DB_PASSWORD" ]]; then
|
|
echo "DB_PASSWORD is required (the seeders connect to $DB_NAME) — edit the placeholder near the top of this script, or export DB_PASSWORD instead" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "==> Building the apps the suite boots"
|
|
# Playwright's webServer runs `start` for the APIs (dist/main.js), so they must
|
|
# be built first — `dev` would work too but recompiles on every run and races
|
|
# the health check.
|
|
pnpm turbo build --filter=@edr/hr-api --filter=@edr/finance-api
|
|
|
|
if [[ "${SKIP_SEED:-}" != "1" ]]; then
|
|
echo "==> Seeding module permissions (idempotent)"
|
|
node scripts/seed-module-permissions.cjs hr
|
|
node scripts/seed-module-permissions.cjs finance
|
|
|
|
echo "==> Seeding fixture personas (idempotent)"
|
|
node e2e-hr-finance/fixtures/seed-personas.cjs
|
|
fi
|
|
|
|
echo "==> Running Playwright"
|
|
# global-setup mints one storageState per persona; webServer boots the four
|
|
# services on their e2e ports (3105/3104/5285/5286) against $DB_NAME.
|
|
npx playwright test --config e2e-hr-finance/playwright.config.ts "$@"
|
|
|
|
echo
|
|
echo "==> Report: e2e-hr-finance-report/index.html"
|
|
echo " npx playwright show-report e2e-hr-finance-report"
|