/test — Full Stack Validation
Run a comprehensive test suite across the entire Clawforge stack. Each phase is independent — if one fails, record the failure and continue to the next phase. Print a summary table at the end.
Pre-flight
- •Detect the repo root (look for
package.jsonwith"name": "clawforge") - •Kill any stale processes on ports 3000, 4000, and 5432:
code
lsof -ti:3000 | xargs kill -9 2>/dev/null || true lsof -ti:4000 | xargs kill -9 2>/dev/null || true
- •Initialize a results tracker — for each phase, store PASS, FAIL, or SKIP
Phase 1: Unit Tests
Run the server package's unit tests:
pnpm --filter @clawforge/server test
Pass criteria: exit code 0
Phase 2: Web Dev Server Smoke Test
- •Kill anything on port 3000:
bash
lsof -ti:3000 | xargs kill -9 2>/dev/null || true
- •Start the web dev server in background:
bash
pnpm --filter @clawforge/web dev & WEB_PID=$!
- •Poll
http://localhost:3000every 3 seconds, up to 60 seconds total - •Verify the response body contains
<htmlor<!DOCTYPE - •Kill the dev server:
bash
kill $WEB_PID 2>/dev/null || true lsof -ti:3000 | xargs kill -9 2>/dev/null || true
Pass criteria: HTTP response received and contains HTML content within 60s
Phase 3: API Health Check
- •Start a standalone postgres container:
bash
docker run -d --name clawforge-test-pg \ -e POSTGRES_USER=postgres \ -e POSTGRES_PASSWORD=postgres \ -e POSTGRES_DB=clawforge \ -p 5432:5432 \ postgres:16-alpine
- •Wait for postgres to be ready (poll
pg_isreadyup to 30s):bashuntil docker exec clawforge-test-pg pg_isready -U postgres; do sleep 2; done
- •Export required env vars:
bash
export DATABASE_URL="postgresql://postgres:postgres@localhost:5432/clawforge" export BETTER_AUTH_SECRET="test-secret" export BETTER_AUTH_URL="http://localhost:4000" export WEB_URL="http://localhost:3000" export GOOGLE_CLIENT_ID="test" export GOOGLE_CLIENT_SECRET="test" export PORT=4000
- •Start the API dev server in background:
bash
pnpm --filter @clawforge/api dev & API_PID=$!
- •Poll
http://localhost:4000/healthevery 3 seconds, up to 30 seconds - •Verify response contains
"status":"ok" - •Clean up:
bash
kill $API_PID 2>/dev/null || true lsof -ti:4000 | xargs kill -9 2>/dev/null || true docker rm -f clawforge-test-pg 2>/dev/null || true
Pass criteria: /health returns {"status":"ok","service":"api"} within 30s
Phase 4: Docker Integration Test
- •Clean up prior state:
bash
docker compose -f infra/clawforge-server/docker-compose.yml down -v 2>/dev/null || true
- •Export dummy env vars for compose:
bash
export BETTER_AUTH_SECRET="test-secret" export GOOGLE_CLIENT_ID="test" export GOOGLE_CLIENT_SECRET="test"
- •Build and start all services:
bash
docker compose -f infra/clawforge-server/docker-compose.yml up --build -d
- •Wait for all services to become healthy — poll
docker compose psfor up to 120 seconds, checking that postgres, api, and web are all healthy - •Verify endpoints:
- •
http://localhost:3000returns HTML content - •
http://localhost:4000/healthreturns"status":"ok"
- •
- •Tear down:
bash
docker compose -f infra/clawforge-server/docker-compose.yml down -v
Pass criteria: all three services healthy, both endpoints respond correctly
Phase 5: Package npm Tarball
- •Remove any existing tarballs:
bash
rm -f *.tgz
- •Run the pack script:
bash
pnpm pack
- •Verify a
.tgzfile was created:bashls *.tgz
Pass criteria: a clawforge-*.tgz file exists after packing
Phase 6: Global Install / Uninstall
- •Uninstall any previous global install (ignore errors):
bash
npm uninstall -g clawforge 2>/dev/null || true
- •Install from the tarball:
bash
npm install -g ./clawforge-*.tgz
- •Verify the CLI works:
bash
clawforge --help
Pass criteria: clawforge --help exits 0 and prints help text
Phase 7: Fresh Install Test in /tmp
- •Copy the repo to a temp directory (excluding build artifacts):
bash
rsync -a --exclude node_modules --exclude .next --exclude dist \ --exclude bundle --exclude '*.tgz' --exclude .open-next \ ./ /tmp/clawforge-test-copy/
- •Install dependencies in the copy:
bash
cd /tmp/clawforge-test-copy && pnpm install --frozen-lockfile
- •Run unit tests in the copy:
bash
cd /tmp/clawforge-test-copy && pnpm --filter @clawforge/server test
- •Remove the copy:
bash
rm -rf /tmp/clawforge-test-copy
Pass criteria: pnpm install and unit tests succeed in the fresh copy
Phase 8: Cleanup
Run all cleanup steps (ignore errors on each):
lsof -ti:3000 | xargs kill -9 2>/dev/null || true lsof -ti:4000 | xargs kill -9 2>/dev/null || true docker compose -f infra/clawforge-server/docker-compose.yml down -v 2>/dev/null || true docker rm -f clawforge-test-pg 2>/dev/null || true # Commented to keep installed clawforge package # npm uninstall -g clawforge 2>/dev/null || true rm -f *.tgz rm -rf /tmp/clawforge-test-copy
Results Summary
Print a formatted summary table:
╔══════════════════════════════════════════╦════════╗ ║ Phase ║ Result ║ ╠══════════════════════════════════════════╬════════╣ ║ 1. Unit Tests ║ PASS ║ ║ 2. Web Dev Server Smoke Test ║ PASS ║ ║ 3. API Health Check ║ FAIL ║ ║ 4. Docker Integration Test ║ SKIP ║ ║ 5. Package npm Tarball ║ PASS ║ ║ 6. Global Install / Uninstall ║ PASS ║ ║ 7. Fresh Install Test in /tmp ║ PASS ║ ║ 8. Cleanup ║ PASS ║ ╠══════════════════════════════════════════╬════════╣ ║ OVERALL ║ FAIL ║ ╚══════════════════════════════════════════╩════════╝
- •PASS: all phases passed
- •FAIL: one or more phases failed — list which ones
- •SKIP: phase was skipped (e.g., Docker not available)
For any failed phase, include a brief explanation of what went wrong.