arbret/scripts/e2e.sh
counterweight c89e0312fa
Phase 0.3: Update E2E tests for cleanup
- Delete counter.spec.ts and random-jobs.spec.ts
- Rewrite permissions.spec.ts for new permission structure
- Update scripts/e2e.sh: remove worker.py execution
- Update generated api.ts types
2025-12-22 18:13:24 +01:00

58 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
set -e
cd "$(dirname "$0")/.."
# Cleanup function to kill background processes
cleanup() {
kill $BACKEND_PID 2>/dev/null || true
}
# Ensure cleanup runs on exit (normal, error, or interrupt)
trap cleanup EXIT
# Load environment variables if .env exists
if [ -f .env ]; then
set -a
source .env
set +a
fi
# Kill any existing backend
pkill -f "uvicorn main:app" 2>/dev/null || true
sleep 1
# Seed the database with roles and test users
cd backend
echo "Seeding database..."
uv run python seed.py
cd ..
# Start backend (SECRET_KEY should be set via .envrc or environment)
cd backend
uv run uvicorn main:app --port 8000 --log-level warning &
BACKEND_PID=$!
cd ..
# Wait for backend
sleep 2
# Generate API types from OpenAPI schema
echo "Generating API types..."
cd frontend
npm run generate-api-types
cd ..
# Run tests (suppress Node.js color warnings)
# If TEST argument is provided, use it as a file pattern
cd frontend
if [ -n "$1" ]; then
NODE_NO_WARNINGS=1 npx playwright test "$1"
else
NODE_NO_WARNINGS=1 npm run test:e2e
fi
EXIT_CODE=$?
# Cleanup is handled by trap EXIT
exit $EXIT_CODE