- Update scripts/e2e.sh to start worker alongside backend - Create frontend/e2e/random-jobs.spec.ts with 3 tests: - Counter increment creates random job outcome visible to admin - Admin can view empty random jobs list - Regular user cannot access random jobs page
57 lines
1 KiB
Bash
Executable file
57 lines
1 KiB
Bash
Executable file
#!/bin/bash
|
|
set -e
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
# 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=$!
|
|
|
|
# Start worker for job processing
|
|
uv run python worker.py &
|
|
WORKER_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
|
|
kill $BACKEND_PID 2>/dev/null || true
|
|
kill $WORKER_PID 2>/dev/null || true
|
|
|
|
exit $EXIT_CODE
|
|
|