Compare commits
23 Commits
3aaffd2e67
...
docs/readm
| Author | SHA1 | Date | |
|---|---|---|---|
| fa8c646a5b | |||
| c96d012fef | |||
| 3f09573631 | |||
| 3cd807566a | |||
| ef8a4ae994 | |||
| 4c54503a81 | |||
| 62d339b58c | |||
| 23cad37e03 | |||
| 779fb7b387 | |||
| 48c54c2f32 | |||
| f5294f5290 | |||
| 11d0865fd3 | |||
| 14f4fb8d16 | |||
| cc2d4aea5c | |||
| 5a45a72dcf | |||
| ba3909ec68 | |||
| 805dc2fe32 | |||
| 81fe00bfb8 | |||
| 4707f0614c | |||
| c76c25fb5b | |||
| 1bb11ca92b | |||
| 4844b63c16 | |||
| 8b1edf53f0 |
Submodule HarborForge.Backend.Test updated: 477419cb57...b925b5c07e
Submodule HarborForge.Frontend.Test updated: 766f5ef33e...d65b23b118
135
README.md
135
README.md
@@ -1 +1,136 @@
|
|||||||
# HarborForge.Test
|
# HarborForge.Test
|
||||||
|
|
||||||
|
Integration / end-to-end test harness for the HarborForge platform. It
|
||||||
|
spins up the full stack (MySQL, AbstractWizard, HarborForge.Backend,
|
||||||
|
HarborForge.Frontend) in Docker and runs the backend and frontend test
|
||||||
|
suites against it.
|
||||||
|
|
||||||
|
Part of the [HarborForge](../README.md) platform.
|
||||||
|
|
||||||
|
## Layout
|
||||||
|
|
||||||
|
```
|
||||||
|
HarborForge.Test/
|
||||||
|
├── run-test.sh # Quick frontend E2E run (no rebuild)
|
||||||
|
├── run-test-frontend.sh # Full frontend E2E run (rebuild + optional port expose)
|
||||||
|
├── cleanup.sh # Tear down containers / wizard config volume
|
||||||
|
├── docker-compose-frontend.yml # Internal-only test stack
|
||||||
|
├── docker-compose-frontend-expose.yml# Same stack with ports bound to 127.0.0.1
|
||||||
|
├── .env.TEST # Default service ports
|
||||||
|
├── HarborForge.Backend.Test/ # git submodule — backend pytest suite
|
||||||
|
└── HarborForge.Frontend.Test/ # git submodule — frontend Playwright suite
|
||||||
|
```
|
||||||
|
|
||||||
|
The two test suites are git submodules (see `.gitmodules`). After cloning,
|
||||||
|
initialize them:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git submodule update --init --recursive
|
||||||
|
```
|
||||||
|
|
||||||
|
## What It Tests
|
||||||
|
|
||||||
|
### Backend — `HarborForge.Backend.Test` (pytest)
|
||||||
|
|
||||||
|
A standalone pytest suite that imports the backend code from
|
||||||
|
`../HarborForge.Backend/` via `tests/conftest.py` and runs against an
|
||||||
|
in-memory SQLite database for fast, isolated unit/integration tests.
|
||||||
|
Configured by `pyproject.toml` (`testpaths = ["tests"]`, verbose,
|
||||||
|
short tracebacks).
|
||||||
|
|
||||||
|
Coverage spans auth/JWT, users, projects, milestones, tasks, comments,
|
||||||
|
roles/permissions, the milestone and task state machines
|
||||||
|
(`test_milestone_actions.py`, `test_task_transitions.py`), proposals
|
||||||
|
(`test_propose.py`), the monitor endpoint, and miscellaneous endpoints
|
||||||
|
(notifications, activity log, API keys, dashboard).
|
||||||
|
|
||||||
|
Run it standalone:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python3 -m venv venv
|
||||||
|
source venv/bin/activate
|
||||||
|
pip install -r HarborForge.Backend.Test/requirements.txt
|
||||||
|
cd HarborForge.Backend.Test && pytest # or: pytest -v, pytest tests/test_auth.py
|
||||||
|
```
|
||||||
|
|
||||||
|
See `HarborForge.Backend.Test/README.md` for the full test breakdown.
|
||||||
|
|
||||||
|
### Frontend — `HarborForge.Frontend.Test` (Playwright)
|
||||||
|
|
||||||
|
A Playwright (`@playwright/test`) end-to-end suite that drives the running
|
||||||
|
frontend through a browser. Specs in `tests/` cover the setup wizard,
|
||||||
|
projects editor, milestones, tasks, role editor and proposals
|
||||||
|
(`wizard.spec.ts`, `project-editor.spec.ts`, `milestone.spec.ts`,
|
||||||
|
`task.spec.ts`, `role-editor.spec.ts`, `propose.spec.ts`,
|
||||||
|
`proposal-essential.spec.ts`). Its Docker image runs a helper proxy
|
||||||
|
(`server/proxy.mjs`) alongside `npx playwright test`.
|
||||||
|
|
||||||
|
> Note: the frontend's own Vitest unit tests live in the
|
||||||
|
> `HarborForge.Frontend` repo; this harness exercises the frontend through
|
||||||
|
> Playwright against the full Docker stack.
|
||||||
|
|
||||||
|
## Docker Test Stack
|
||||||
|
|
||||||
|
`docker-compose-frontend.yml` defines five services on a private
|
||||||
|
`test-network` bridge — `mysql` (MySQL 8, tmpfs storage), `wizard`
|
||||||
|
(AbstractWizard), `backend` (HarborForge.Backend), `frontend`
|
||||||
|
(HarborForge.Frontend), and `test` (the Playwright runner image built from
|
||||||
|
`HarborForge.Frontend.Test/`). Service ports default from `.env.TEST`
|
||||||
|
(`WIZARD_PORT=8080`, `MYSQL_PORT=3306`, `BACKEND_PORT=8000`,
|
||||||
|
`FRONTEND_PORT=3000`).
|
||||||
|
|
||||||
|
- `docker-compose-frontend.yml` — services are reachable only on the
|
||||||
|
internal network (wizard alone is bound to `127.0.0.1`).
|
||||||
|
- `docker-compose-frontend-expose.yml` — same stack, but mysql, wizard,
|
||||||
|
backend and frontend ports are also bound to `127.0.0.1` for debugging.
|
||||||
|
|
||||||
|
## Running the Tests
|
||||||
|
|
||||||
|
### Quick run (no rebuild)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./run-test.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Brings the stack up from `docker-compose-frontend.yml`, waits (up to ~60s)
|
||||||
|
for the frontend to answer HTTP 200, runs the `test` service once, then
|
||||||
|
tears everything down with `down -v`.
|
||||||
|
|
||||||
|
### Full run (rebuild, optional port exposure)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./run-test-frontend.sh # rebuild all images, run, auto-cleanup
|
||||||
|
./run-test-frontend.sh --expose-port on # use the *-expose.yml file, keep services up
|
||||||
|
./run-test-frontend.sh --expose-port off # default: cleanup after the run
|
||||||
|
```
|
||||||
|
|
||||||
|
It loads `.env.TEST`, rebuilds the frontend (with build arg
|
||||||
|
`VITE_API_BASE=http://backend:8000`), backend and test-runner images with
|
||||||
|
`--no-cache`, starts the stack, waits for the frontend, then runs the
|
||||||
|
`test` service with `WORKERS=1`. With `--expose-port on` it uses
|
||||||
|
`docker-compose-frontend-expose.yml` and leaves the stack running for
|
||||||
|
inspection.
|
||||||
|
|
||||||
|
### Cleanup
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./cleanup.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Stops and removes containers/networks (keeps images) and drops the
|
||||||
|
`harborforgetest_wizard_config` volume. The run scripts also call
|
||||||
|
`docker compose ... down -v` themselves on completion (except when port
|
||||||
|
exposure is on).
|
||||||
|
|
||||||
|
## CI Notes
|
||||||
|
|
||||||
|
- Both run scripts use `set -e` and propagate the test container's exit
|
||||||
|
code, so they are CI-friendly: a non-zero `TEST_EXIT_CODE` fails the job.
|
||||||
|
- `run-test-frontend.sh` suppresses build/startup output unless a step
|
||||||
|
fails, in which case it prints the tail of that step's log.
|
||||||
|
- Builds use `--no-cache` and remove prior `harborforge-test-*:dev` images
|
||||||
|
to guarantee a clean stack each run; MySQL uses `tmpfs` so no state
|
||||||
|
persists between runs.
|
||||||
|
- Ensure submodules are initialized
|
||||||
|
(`git submodule update --init --recursive`) before invoking the scripts
|
||||||
|
in CI.
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ services:
|
|||||||
restart: "no"
|
restart: "no"
|
||||||
environment:
|
environment:
|
||||||
VITE_API_BASE_URL: http://backend:${BACKEND_PORT:-8000}
|
VITE_API_BASE_URL: http://backend:${BACKEND_PORT:-8000}
|
||||||
|
VITE_WIZARD_PORT: ${WIZARD_PORT:-8080}
|
||||||
|
FRONTEND_DEV_MODE: ${FRONTEND_DEV_MODE:-1}
|
||||||
|
NODE_ENV: development
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:${FRONTEND_PORT:-3000}:${FRONTEND_PORT:-3000}"
|
- "127.0.0.1:${FRONTEND_PORT:-3000}:${FRONTEND_PORT:-3000}"
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
@@ -72,6 +72,9 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
# Use internal service name
|
# Use internal service name
|
||||||
VITE_API_BASE_URL: http://backend:${BACKEND_PORT:-8000}
|
VITE_API_BASE_URL: http://backend:${BACKEND_PORT:-8000}
|
||||||
|
VITE_WIZARD_PORT: ${WIZARD_PORT:-8080}
|
||||||
|
FRONTEND_DEV_MODE: ${FRONTEND_DEV_MODE:-1}
|
||||||
|
NODE_ENV: development
|
||||||
networks:
|
networks:
|
||||||
- test-network
|
- test-network
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Run frontend test with optional port exposure
|
# Run frontend test with optional port exposure
|
||||||
# Usage: ./run-test-frontend.sh [--expose-port {on|off}]
|
# Usage: ./run-test-frontend.sh [--expose-port {on|off}]
|
||||||
# Default: off
|
# Default:
|
||||||
#
|
# --expose-port off: Auto cleanup after test
|
||||||
# --expose-port on: Keep services running after test (manual cleanup required)
|
|
||||||
# --expose-port off: Auto cleanup after test (default)
|
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
@@ -54,28 +52,44 @@ fi
|
|||||||
|
|
||||||
echo "📦 Using compose file: $COMPOSE_FILE"
|
echo "📦 Using compose file: $COMPOSE_FILE"
|
||||||
|
|
||||||
|
run_quiet() {
|
||||||
|
local label="$1"
|
||||||
|
shift
|
||||||
|
local log_file
|
||||||
|
log_file=$(mktemp)
|
||||||
|
if "$@" >"$log_file" 2>&1; then
|
||||||
|
rm -f "$log_file"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
echo "❌ ${label} failed"
|
||||||
|
echo "--- ${label} log ---"
|
||||||
|
tail -n 200 "$log_file"
|
||||||
|
rm -f "$log_file"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# Clean any previous containers first
|
# Clean any previous containers first
|
||||||
echo "🧹 Cleaning up previous containers..."
|
echo "🧹 Cleaning up previous containers..."
|
||||||
docker compose -f "$COMPOSE_FILE" down -v 2>/dev/null || true
|
docker compose -f "$COMPOSE_FILE" down -v >/dev/null 2>&1 || true
|
||||||
|
|
||||||
# Build frontend with correct API base URL (force no cache, remove image first)
|
# Build frontend with correct API base URL (force no cache, remove image first)
|
||||||
echo "🔨 Building frontend..."
|
echo "🔨 Building frontend..."
|
||||||
docker rmi harborforge-test-frontend:dev 2>/dev/null || true
|
docker rmi harborforge-test-frontend:dev >/dev/null 2>&1 || true
|
||||||
docker compose -f "$COMPOSE_FILE" build --no-cache --build-arg VITE_API_BASE=http://backend:8000 frontend
|
run_quiet "frontend build" docker compose -f "$COMPOSE_FILE" build --no-cache --build-arg VITE_API_BASE=http://backend:8000 frontend
|
||||||
|
|
||||||
# Build backend (force no cache, remove image first)
|
# Build backend (force no cache, remove image first)
|
||||||
echo "🔨 Building backend..."
|
echo "🔨 Building backend..."
|
||||||
docker rmi harborforge-test-backend:dev 2>/dev/null || true
|
docker rmi harborforge-test-backend:dev >/dev/null 2>&1 || true
|
||||||
docker compose -f "$COMPOSE_FILE" build --no-cache backend
|
run_quiet "backend build" docker compose -f "$COMPOSE_FILE" build --no-cache backend
|
||||||
|
|
||||||
# Build test runner (force no cache, remove image first)
|
# Build test runner (force no cache, remove image first)
|
||||||
echo "🔨 Building test runner..."
|
echo "🔨 Building test runner..."
|
||||||
docker rmi harborforge-test-runner:dev 2>/dev/null || true
|
docker rmi harborforge-test-runner:dev >/dev/null 2>&1 || true
|
||||||
docker compose -f "$COMPOSE_FILE" build --no-cache test
|
run_quiet "test runner build" docker compose -f "$COMPOSE_FILE" build --no-cache test
|
||||||
|
|
||||||
# Start services
|
# Start services
|
||||||
echo "📦 Starting services..."
|
echo "📦 Starting services..."
|
||||||
docker compose -f "$COMPOSE_FILE" up -d
|
run_quiet "service startup" docker compose -f "$COMPOSE_FILE" up -d
|
||||||
|
|
||||||
# Wait for frontend to be ready
|
# Wait for frontend to be ready
|
||||||
echo "⏳ Waiting for services..."
|
echo "⏳ Waiting for services..."
|
||||||
@@ -96,7 +110,7 @@ fi
|
|||||||
|
|
||||||
echo "✅ Services ready!"
|
echo "✅ Services ready!"
|
||||||
|
|
||||||
# Run test
|
# Run test using the image default CMD so proxy startup stays inside Frontend.Test Dockerfile
|
||||||
echo "🧪 Running test..."
|
echo "🧪 Running test..."
|
||||||
docker compose -f "$COMPOSE_FILE" run --rm -e WORKERS=1 test
|
docker compose -f "$COMPOSE_FILE" run --rm -e WORKERS=1 test
|
||||||
TEST_EXIT_CODE=$?
|
TEST_EXIT_CODE=$?
|
||||||
@@ -108,7 +122,7 @@ if [[ "$EXPOSE_PORT" == "on" ]]; then
|
|||||||
echo " Use './run-test-frontend.sh --expose-port on' to cleanup"
|
echo " Use './run-test-frontend.sh --expose-port on' to cleanup"
|
||||||
echo " Or manually: docker compose -f $COMPOSE_FILE down -v"
|
echo " Or manually: docker compose -f $COMPOSE_FILE down -v"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
if [ $TEST_EXIT_CODE -eq 0 ]; then
|
if [ $TEST_EXIT_CODE -eq 0 ]; then
|
||||||
echo "✅ Test passed!"
|
echo "✅ Test passed!"
|
||||||
else
|
else
|
||||||
@@ -118,7 +132,7 @@ else
|
|||||||
echo ""
|
echo ""
|
||||||
echo "🧹 Cleaning up containers and volumes..."
|
echo "🧹 Cleaning up containers and volumes..."
|
||||||
docker compose -f "$COMPOSE_FILE" down -v
|
docker compose -f "$COMPOSE_FILE" down -v
|
||||||
|
|
||||||
if [ $TEST_EXIT_CODE -eq 0 ]; then
|
if [ $TEST_EXIT_CODE -eq 0 ]; then
|
||||||
echo "✅ Test passed!"
|
echo "✅ Test passed!"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user