chore: enhance the tests

This commit is contained in:
Nathnael
2026-07-21 13:10:44 +00:00
parent 20a6ef7906
commit eb36aab05f
6 changed files with 279 additions and 47 deletions

View File

@@ -3,13 +3,14 @@
# vanishes on `down`), seeded test users. Requires the same .npmrc as the main
# docker-compose.yaml (GitHub Packages auth for @tria-plc).
#
# Up (build + wait healthy): docker compose -f docker-compose.e2e.yaml up -d --build --wait
# Headless run in container: docker compose -f docker-compose.e2e.yaml --profile cypress run --rm cypress
# Interactive from host: pnpm --filter @edr/freight-e2e cy:open
# Teardown: docker compose -f docker-compose.e2e.yaml down -v --remove-orphans
# Preferred entrypoint: the launcher (auto-up + free-port picking):
# pnpm e2e:freight:run|open|ci|up|down → e2e/freight/scripts/e2e.mjs
#
# Host ports (chosen to never collide with the dev stacks — 5273/5283/3221 are
# taken by the second dev checkout in ~/projects/nathnael/edr-platform):
# Host ports are env-parameterized (E2E_*_PORT). Defaults below avoid the dev
# stacks (5273/5283/3221 are taken by the second dev checkout in
# ~/projects/nathnael/edr-platform); when a default is busy the launcher scans
# upward for a free port and remembers the choice in e2e/freight/.e2e-ports.json
# while the stack is up:
# freight-api 3101 portal 5373 backoffice 5383
# postgres 5533 minio 9310 (console 9311)
name: edr-freight-e2e
@@ -24,7 +25,7 @@ services:
tmpfs:
- /var/lib/postgresql/data
ports:
- "5533:5432"
- "${E2E_DB_PORT:-5533}:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U edr_e2e -d edr_freight_e2e"]
interval: 2s
@@ -40,8 +41,8 @@ services:
tmpfs:
- /data
ports:
- "9310:9000"
- "9311:9001"
- "${E2E_MINIO_PORT:-9310}:9000"
- "${E2E_MINIO_CONSOLE_PORT:-9311}:9001"
healthcheck:
test: ["CMD", "mc", "ready", "local"]
interval: 5s
@@ -107,9 +108,9 @@ services:
# SMS strategy has no kill switch and defaults to a real dev endpoint —
# blackhole it so e2e never sends SMS (failures are logged, non-fatal).
OZIKING_SMS_URL: http://127.0.0.1:9/sms
FREIGHT_PORTAL_URL: http://localhost:5373
FREIGHT_PORTAL_URL: http://localhost:${E2E_PORTAL_PORT:-5373}
ports:
- "3101:3001"
- "${E2E_API_PORT:-3101}:3001"
healthcheck:
# Boot runs 240+ migrations + seeders on first start — generous start_period.
test:
@@ -132,9 +133,10 @@ services:
TURBO_FILTER: "@edr/freight-portal"
APP_PATH: apps/edr-freight-web/portal
# Baked at build time: browser (host or host-networked cypress
# container) reaches the API through the published host port.
VITE_API_URL: http://localhost:3101
VITE_BASE_API_URL: http://localhost:3101
# container) reaches the API through the published host port. A
# non-default API port therefore forces a web image rebuild.
VITE_API_URL: http://localhost:${E2E_API_PORT:-3101}
VITE_BASE_API_URL: http://localhost:${E2E_API_PORT:-3101}
VITE_USER_MANAGEMENT_BASE: /_um
VITE_GOOGLE_MAPS_API_KEY: ""
VITE_POSTHOG_KEY: ""
@@ -142,7 +144,7 @@ services:
secrets:
- npmrc
ports:
- "5373:80"
- "${E2E_PORTAL_PORT:-5373}:80"
freight-backoffice-e2e:
build:
@@ -151,8 +153,8 @@ services:
args:
TURBO_FILTER: "@edr/freight-backoffice"
APP_PATH: apps/edr-freight-web/backoffice
VITE_API_URL: http://localhost:3101
VITE_BASE_API_URL: http://localhost:3101
VITE_API_URL: http://localhost:${E2E_API_PORT:-3101}
VITE_BASE_API_URL: http://localhost:${E2E_API_PORT:-3101}
VITE_USER_MANAGEMENT_BASE: /_um
VITE_GOOGLE_MAPS_API_KEY: ""
VITE_POSTHOG_KEY: ""
@@ -160,7 +162,7 @@ services:
secrets:
- npmrc
ports:
- "5383:80"
- "${E2E_BACKOFFICE_PORT:-5383}:80"
# Headless runner — opt-in via `--profile cypress`. host network so the
# in-container browser uses the exact same localhost URLs as `cypress open`
@@ -180,7 +182,10 @@ services:
entrypoint: ["cypress", "run", "--browser", "chrome"]
environment:
CI: "true"
E2E_DB_URL: postgres://edr_e2e:edr_e2e@localhost:5533/edr_freight_e2e
E2E_DB_URL: postgres://edr_e2e:edr_e2e@localhost:${E2E_DB_PORT:-5533}/edr_freight_e2e
CYPRESS_BASE_URL: http://localhost:${E2E_BACKOFFICE_PORT:-5383}
CYPRESS_API_URL: http://localhost:${E2E_API_PORT:-3101}
CYPRESS_PORTAL_URL: http://localhost:${E2E_PORTAL_PORT:-5373}
volumes:
- .:/repo