feat: Add CI/CD (GitHub Actions), E2E tests (Playwright), deploy scripts (Fly.io + Vercel), admin dashboard, notifications dropdown, Postman collection
Browse files- .github/workflows/ci.yml +164 -0
- backend/fly.toml +52 -0
- deploy/deploy.sh +94 -0
- docs/postman_collection.json +207 -0
- frontend/e2e/pytest.ini +5 -0
- frontend/e2e/test_flows.py +184 -0
- frontend/src/app/(dashboard)/admin/page.tsx +364 -0
- frontend/src/app/(dashboard)/layout.tsx +17 -2
- frontend/src/components/layout/notifications-dropdown.tsx +165 -0
- frontend/vercel.json +32 -0
.github/workflows/ci.yml
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: CI
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches: [main, develop]
|
| 6 |
+
pull_request:
|
| 7 |
+
branches: [main]
|
| 8 |
+
|
| 9 |
+
env:
|
| 10 |
+
PYTHON_VERSION: "3.12"
|
| 11 |
+
NODE_VERSION: "20"
|
| 12 |
+
POSTGRES_USER: test
|
| 13 |
+
POSTGRES_PASSWORD: test
|
| 14 |
+
POSTGRES_DB: jobportal_test
|
| 15 |
+
|
| 16 |
+
jobs:
|
| 17 |
+
# ============ Backend ============
|
| 18 |
+
backend-lint:
|
| 19 |
+
name: Backend Lint
|
| 20 |
+
runs-on: ubuntu-latest
|
| 21 |
+
steps:
|
| 22 |
+
- uses: actions/checkout@v4
|
| 23 |
+
- uses: actions/setup-python@v5
|
| 24 |
+
with:
|
| 25 |
+
python-version: ${{ env.PYTHON_VERSION }}
|
| 26 |
+
- name: Install Ruff
|
| 27 |
+
run: pip install ruff
|
| 28 |
+
- name: Lint
|
| 29 |
+
run: cd backend && ruff check .
|
| 30 |
+
- name: Format check
|
| 31 |
+
run: cd backend && ruff format --check .
|
| 32 |
+
|
| 33 |
+
backend-test:
|
| 34 |
+
name: Backend Tests
|
| 35 |
+
runs-on: ubuntu-latest
|
| 36 |
+
services:
|
| 37 |
+
postgres:
|
| 38 |
+
image: postgres:17-alpine
|
| 39 |
+
env:
|
| 40 |
+
POSTGRES_USER: ${{ env.POSTGRES_USER }}
|
| 41 |
+
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
|
| 42 |
+
POSTGRES_DB: ${{ env.POSTGRES_DB }}
|
| 43 |
+
ports:
|
| 44 |
+
- 5432:5432
|
| 45 |
+
options: >-
|
| 46 |
+
--health-cmd pg_isready
|
| 47 |
+
--health-interval 10s
|
| 48 |
+
--health-timeout 5s
|
| 49 |
+
--health-retries 5
|
| 50 |
+
redis:
|
| 51 |
+
image: redis:7-alpine
|
| 52 |
+
ports:
|
| 53 |
+
- 6379:6379
|
| 54 |
+
options: >-
|
| 55 |
+
--health-cmd "redis-cli ping"
|
| 56 |
+
--health-interval 10s
|
| 57 |
+
--health-timeout 5s
|
| 58 |
+
--health-retries 5
|
| 59 |
+
env:
|
| 60 |
+
POSTGRES_SERVER: localhost
|
| 61 |
+
POSTGRES_PORT: 5432
|
| 62 |
+
POSTGRES_USER: test
|
| 63 |
+
POSTGRES_PASSWORD: test
|
| 64 |
+
POSTGRES_DB: jobportal_test
|
| 65 |
+
REDIS_URL: redis://localhost:6379/0
|
| 66 |
+
SECRET_KEY: test-secret-key-for-ci
|
| 67 |
+
APP_ENV: testing
|
| 68 |
+
steps:
|
| 69 |
+
- uses: actions/checkout@v4
|
| 70 |
+
- uses: actions/setup-python@v5
|
| 71 |
+
with:
|
| 72 |
+
python-version: ${{ env.PYTHON_VERSION }}
|
| 73 |
+
- name: Install uv
|
| 74 |
+
run: pip install uv
|
| 75 |
+
- name: Install dependencies
|
| 76 |
+
run: cd backend && uv pip install --system -e ".[dev]"
|
| 77 |
+
- name: Install pgvector extension
|
| 78 |
+
run: |
|
| 79 |
+
sudo apt-get update
|
| 80 |
+
sudo apt-get install -y postgresql-client
|
| 81 |
+
PGPASSWORD=test psql -h localhost -U test -d jobportal_test -c "CREATE EXTENSION IF NOT EXISTS vector;"
|
| 82 |
+
PGPASSWORD=test psql -h localhost -U test -d jobportal_test -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
|
| 83 |
+
PGPASSWORD=test psql -h localhost -U test -d jobportal_test -c 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp";'
|
| 84 |
+
- name: Run tests
|
| 85 |
+
run: cd backend && pytest -v --cov=app --cov-report=xml
|
| 86 |
+
- name: Upload coverage
|
| 87 |
+
uses: codecov/codecov-action@v4
|
| 88 |
+
with:
|
| 89 |
+
file: backend/coverage.xml
|
| 90 |
+
flags: backend
|
| 91 |
+
|
| 92 |
+
# ============ Frontend ============
|
| 93 |
+
frontend-lint:
|
| 94 |
+
name: Frontend Lint & Type Check
|
| 95 |
+
runs-on: ubuntu-latest
|
| 96 |
+
steps:
|
| 97 |
+
- uses: actions/checkout@v4
|
| 98 |
+
- uses: actions/setup-node@v4
|
| 99 |
+
with:
|
| 100 |
+
node-version: ${{ env.NODE_VERSION }}
|
| 101 |
+
- uses: pnpm/action-setup@v4
|
| 102 |
+
with:
|
| 103 |
+
version: 9
|
| 104 |
+
- name: Install dependencies
|
| 105 |
+
run: cd frontend && pnpm install --frozen-lockfile
|
| 106 |
+
- name: Type check
|
| 107 |
+
run: cd frontend && pnpm tsc --noEmit
|
| 108 |
+
- name: Lint
|
| 109 |
+
run: cd frontend && pnpm lint
|
| 110 |
+
|
| 111 |
+
frontend-build:
|
| 112 |
+
name: Frontend Build
|
| 113 |
+
runs-on: ubuntu-latest
|
| 114 |
+
needs: frontend-lint
|
| 115 |
+
steps:
|
| 116 |
+
- uses: actions/checkout@v4
|
| 117 |
+
- uses: actions/setup-node@v4
|
| 118 |
+
with:
|
| 119 |
+
node-version: ${{ env.NODE_VERSION }}
|
| 120 |
+
- uses: pnpm/action-setup@v4
|
| 121 |
+
with:
|
| 122 |
+
version: 9
|
| 123 |
+
- name: Install dependencies
|
| 124 |
+
run: cd frontend && pnpm install --frozen-lockfile
|
| 125 |
+
- name: Build
|
| 126 |
+
run: cd frontend && pnpm build
|
| 127 |
+
env:
|
| 128 |
+
NEXT_PUBLIC_API_URL: http://localhost:8000
|
| 129 |
+
|
| 130 |
+
# ============ Docker ============
|
| 131 |
+
docker-build:
|
| 132 |
+
name: Docker Build
|
| 133 |
+
runs-on: ubuntu-latest
|
| 134 |
+
needs: [backend-test, frontend-build]
|
| 135 |
+
if: github.ref == 'refs/heads/main'
|
| 136 |
+
steps:
|
| 137 |
+
- uses: actions/checkout@v4
|
| 138 |
+
- name: Set up Docker Buildx
|
| 139 |
+
uses: docker/setup-buildx-action@v3
|
| 140 |
+
- name: Build backend
|
| 141 |
+
run: docker build ./backend -t jobportal-backend:latest
|
| 142 |
+
- name: Build frontend
|
| 143 |
+
run: docker build ./frontend -t jobportal-frontend:latest
|
| 144 |
+
|
| 145 |
+
# ============ Deploy ============
|
| 146 |
+
deploy:
|
| 147 |
+
name: Deploy
|
| 148 |
+
runs-on: ubuntu-latest
|
| 149 |
+
needs: docker-build
|
| 150 |
+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
| 151 |
+
environment: production
|
| 152 |
+
steps:
|
| 153 |
+
- uses: actions/checkout@v4
|
| 154 |
+
- name: Deploy Backend to Fly.io
|
| 155 |
+
if: env.FLY_API_TOKEN != ''
|
| 156 |
+
uses: superfly/flyctl-actions/setup-flyctl@master
|
| 157 |
+
- run: |
|
| 158 |
+
if [ -n "$FLY_API_TOKEN" ]; then
|
| 159 |
+
cd backend && flyctl deploy --remote-only
|
| 160 |
+
else
|
| 161 |
+
echo "FLY_API_TOKEN not set, skipping deploy"
|
| 162 |
+
fi
|
| 163 |
+
env:
|
| 164 |
+
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
|
backend/fly.toml
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Fly.io deployment configuration for backend
|
| 2 |
+
# Deploy: cd backend && flyctl deploy
|
| 3 |
+
|
| 4 |
+
app = "jobportal-api"
|
| 5 |
+
primary_region = "sjc" # San Jose, CA
|
| 6 |
+
|
| 7 |
+
[build]
|
| 8 |
+
dockerfile = "Dockerfile"
|
| 9 |
+
|
| 10 |
+
[env]
|
| 11 |
+
APP_ENV = "production"
|
| 12 |
+
API_V1_STR = "/api/v1"
|
| 13 |
+
PORT = "8000"
|
| 14 |
+
|
| 15 |
+
[http_service]
|
| 16 |
+
internal_port = 8000
|
| 17 |
+
force_https = true
|
| 18 |
+
auto_stop_machines = true
|
| 19 |
+
auto_start_machines = true
|
| 20 |
+
min_machines_running = 1
|
| 21 |
+
|
| 22 |
+
[http_service.concurrency]
|
| 23 |
+
type = "requests"
|
| 24 |
+
hard_limit = 250
|
| 25 |
+
soft_limit = 200
|
| 26 |
+
|
| 27 |
+
[[services]]
|
| 28 |
+
protocol = "tcp"
|
| 29 |
+
internal_port = 8000
|
| 30 |
+
|
| 31 |
+
[[services.ports]]
|
| 32 |
+
port = 80
|
| 33 |
+
handlers = ["http"]
|
| 34 |
+
|
| 35 |
+
[[services.ports]]
|
| 36 |
+
port = 443
|
| 37 |
+
handlers = ["tls", "http"]
|
| 38 |
+
|
| 39 |
+
[[services.http_checks]]
|
| 40 |
+
interval = "15s"
|
| 41 |
+
timeout = "2s"
|
| 42 |
+
grace_period = "10s"
|
| 43 |
+
method = "get"
|
| 44 |
+
path = "/health"
|
| 45 |
+
|
| 46 |
+
[deploy]
|
| 47 |
+
release_command = "alembic upgrade head"
|
| 48 |
+
|
| 49 |
+
[[vm]]
|
| 50 |
+
cpu_kind = "shared"
|
| 51 |
+
cpus = 1
|
| 52 |
+
memory_mb = 512
|
deploy/deploy.sh
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Deploy script for JobPortal
|
| 3 |
+
# Usage: ./deploy/deploy.sh [backend|frontend|all]
|
| 4 |
+
|
| 5 |
+
set -e
|
| 6 |
+
|
| 7 |
+
COMPONENT=${1:-all}
|
| 8 |
+
|
| 9 |
+
echo "🚀 Deploying JobPortal ($COMPONENT)"
|
| 10 |
+
|
| 11 |
+
deploy_backend() {
|
| 12 |
+
echo "📦 Deploying backend to Fly.io..."
|
| 13 |
+
cd backend
|
| 14 |
+
|
| 15 |
+
# Set secrets if not already set
|
| 16 |
+
if [ -n "$DATABASE_URL" ]; then
|
| 17 |
+
flyctl secrets set DATABASE_URL="$DATABASE_URL" --stage
|
| 18 |
+
fi
|
| 19 |
+
if [ -n "$REDIS_URL" ]; then
|
| 20 |
+
flyctl secrets set REDIS_URL="$REDIS_URL" --stage
|
| 21 |
+
fi
|
| 22 |
+
if [ -n "$SECRET_KEY" ]; then
|
| 23 |
+
flyctl secrets set SECRET_KEY="$SECRET_KEY" --stage
|
| 24 |
+
fi
|
| 25 |
+
|
| 26 |
+
# Deploy
|
| 27 |
+
flyctl deploy --remote-only
|
| 28 |
+
|
| 29 |
+
echo "✅ Backend deployed!"
|
| 30 |
+
echo " URL: https://jobportal-api.fly.dev"
|
| 31 |
+
echo " Docs: https://jobportal-api.fly.dev/api/v1/docs"
|
| 32 |
+
cd ..
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
deploy_frontend() {
|
| 36 |
+
echo "📦 Deploying frontend to Vercel..."
|
| 37 |
+
cd frontend
|
| 38 |
+
|
| 39 |
+
# Deploy with Vercel CLI
|
| 40 |
+
if command -v vercel &> /dev/null; then
|
| 41 |
+
vercel --prod
|
| 42 |
+
else
|
| 43 |
+
echo "⚠️ Vercel CLI not installed. Run: npm i -g vercel"
|
| 44 |
+
echo " Then: cd frontend && vercel --prod"
|
| 45 |
+
fi
|
| 46 |
+
|
| 47 |
+
echo "✅ Frontend deployed!"
|
| 48 |
+
cd ..
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
deploy_worker() {
|
| 52 |
+
echo "📦 Deploying worker to Fly.io..."
|
| 53 |
+
cd backend
|
| 54 |
+
|
| 55 |
+
# Scale worker machine
|
| 56 |
+
flyctl machine run . \
|
| 57 |
+
--app jobportal-worker \
|
| 58 |
+
--region sjc \
|
| 59 |
+
--vm-size shared-cpu-1x \
|
| 60 |
+
--vm-memory 512 \
|
| 61 |
+
--entrypoint "celery -A app.worker.celery_config.celery_app worker --loglevel=warning --concurrency=2"
|
| 62 |
+
|
| 63 |
+
echo "✅ Worker deployed!"
|
| 64 |
+
cd ..
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
case $COMPONENT in
|
| 68 |
+
backend)
|
| 69 |
+
deploy_backend
|
| 70 |
+
;;
|
| 71 |
+
frontend)
|
| 72 |
+
deploy_frontend
|
| 73 |
+
;;
|
| 74 |
+
worker)
|
| 75 |
+
deploy_worker
|
| 76 |
+
;;
|
| 77 |
+
all)
|
| 78 |
+
deploy_backend
|
| 79 |
+
deploy_frontend
|
| 80 |
+
deploy_worker
|
| 81 |
+
;;
|
| 82 |
+
*)
|
| 83 |
+
echo "Usage: ./deploy.sh [backend|frontend|worker|all]"
|
| 84 |
+
exit 1
|
| 85 |
+
;;
|
| 86 |
+
esac
|
| 87 |
+
|
| 88 |
+
echo ""
|
| 89 |
+
echo "🎉 Deployment complete!"
|
| 90 |
+
echo ""
|
| 91 |
+
echo "Useful commands:"
|
| 92 |
+
echo " flyctl status -a jobportal-api # Backend status"
|
| 93 |
+
echo " flyctl logs -a jobportal-api # Backend logs"
|
| 94 |
+
echo " vercel ls # Frontend deployments"
|
docs/postman_collection.json
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"info": {
|
| 3 |
+
"name": "JobPortal API",
|
| 4 |
+
"description": "Complete API collection for the JobPortal backend",
|
| 5 |
+
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
| 6 |
+
},
|
| 7 |
+
"variable": [
|
| 8 |
+
{ "key": "base_url", "value": "http://localhost:8000/api/v1" },
|
| 9 |
+
{ "key": "access_token", "value": "" },
|
| 10 |
+
{ "key": "refresh_token", "value": "" }
|
| 11 |
+
],
|
| 12 |
+
"auth": {
|
| 13 |
+
"type": "bearer",
|
| 14 |
+
"bearer": [{ "key": "token", "value": "{{access_token}}" }]
|
| 15 |
+
},
|
| 16 |
+
"item": [
|
| 17 |
+
{
|
| 18 |
+
"name": "Auth",
|
| 19 |
+
"item": [
|
| 20 |
+
{
|
| 21 |
+
"name": "Register",
|
| 22 |
+
"request": {
|
| 23 |
+
"method": "POST",
|
| 24 |
+
"url": "{{base_url}}/auth/register",
|
| 25 |
+
"body": { "mode": "raw", "raw": "{\"email\": \"user@example.com\", \"password\": \"password123\", \"full_name\": \"Test User\"}", "options": { "raw": { "language": "json" } } }
|
| 26 |
+
}
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"name": "Login",
|
| 30 |
+
"request": {
|
| 31 |
+
"method": "POST",
|
| 32 |
+
"url": "{{base_url}}/auth/login",
|
| 33 |
+
"body": { "mode": "raw", "raw": "{\"email\": \"demo@jobportal.dev\", \"password\": \"demo123\"}", "options": { "raw": { "language": "json" } } }
|
| 34 |
+
},
|
| 35 |
+
"event": [{ "listen": "test", "script": { "exec": ["var json = pm.response.json();", "pm.collectionVariables.set('access_token', json.access_token);", "pm.collectionVariables.set('refresh_token', json.refresh_token);"] } }]
|
| 36 |
+
},
|
| 37 |
+
{
|
| 38 |
+
"name": "Get Me",
|
| 39 |
+
"request": { "method": "GET", "url": "{{base_url}}/auth/me" }
|
| 40 |
+
},
|
| 41 |
+
{
|
| 42 |
+
"name": "Refresh Token",
|
| 43 |
+
"request": {
|
| 44 |
+
"method": "POST",
|
| 45 |
+
"url": "{{base_url}}/auth/refresh",
|
| 46 |
+
"body": { "mode": "raw", "raw": "{\"refresh_token\": \"{{refresh_token}}\"}", "options": { "raw": { "language": "json" } } }
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
]
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"name": "Jobs",
|
| 53 |
+
"item": [
|
| 54 |
+
{
|
| 55 |
+
"name": "Search Jobs",
|
| 56 |
+
"request": { "method": "GET", "url": { "raw": "{{base_url}}/jobs?q=python&remote=remote&page=1&page_size=10", "host": ["{{base_url}}"], "path": ["jobs"], "query": [{"key": "q", "value": "python"}, {"key": "remote", "value": "remote"}, {"key": "page", "value": "1"}, {"key": "page_size", "value": "10"}] } }
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"name": "Get Job Detail",
|
| 60 |
+
"request": { "method": "GET", "url": "{{base_url}}/jobs/{{job_id}}" }
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"name": "Save Job",
|
| 64 |
+
"request": { "method": "POST", "url": "{{base_url}}/jobs/{{job_id}}/save", "body": { "mode": "raw", "raw": "{\"notes\": \"Looks interesting\"}", "options": { "raw": { "language": "json" } } } }
|
| 65 |
+
},
|
| 66 |
+
{
|
| 67 |
+
"name": "Unsave Job",
|
| 68 |
+
"request": { "method": "DELETE", "url": "{{base_url}}/jobs/{{job_id}}/save" }
|
| 69 |
+
}
|
| 70 |
+
]
|
| 71 |
+
},
|
| 72 |
+
{
|
| 73 |
+
"name": "Applications",
|
| 74 |
+
"item": [
|
| 75 |
+
{
|
| 76 |
+
"name": "List (Kanban)",
|
| 77 |
+
"request": { "method": "GET", "url": "{{base_url}}/applications" }
|
| 78 |
+
},
|
| 79 |
+
{
|
| 80 |
+
"name": "Create",
|
| 81 |
+
"request": { "method": "POST", "url": "{{base_url}}/applications", "body": { "mode": "raw", "raw": "{\"custom_job_title\": \"Senior Engineer\", \"custom_company_name\": \"TechCorp\", \"status\": \"applied\"}", "options": { "raw": { "language": "json" } } } }
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"name": "Update Status",
|
| 85 |
+
"request": { "method": "PATCH", "url": "{{base_url}}/applications/{{app_id}}", "body": { "mode": "raw", "raw": "{\"status\": \"interviewing\"}", "options": { "raw": { "language": "json" } } } }
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"name": "Delete",
|
| 89 |
+
"request": { "method": "DELETE", "url": "{{base_url}}/applications/{{app_id}}" }
|
| 90 |
+
},
|
| 91 |
+
{
|
| 92 |
+
"name": "Add Interview",
|
| 93 |
+
"request": { "method": "POST", "url": "{{base_url}}/applications/{{app_id}}/interviews", "body": { "mode": "raw", "raw": "{\"interview_type\": \"technical\", \"scheduled_at\": \"2026-06-01T10:00:00Z\", \"duration_minutes\": 60}", "options": { "raw": { "language": "json" } } } }
|
| 94 |
+
}
|
| 95 |
+
]
|
| 96 |
+
},
|
| 97 |
+
{
|
| 98 |
+
"name": "AI",
|
| 99 |
+
"item": [
|
| 100 |
+
{
|
| 101 |
+
"name": "Resume Review",
|
| 102 |
+
"request": { "method": "POST", "url": "{{base_url}}/ai/resume-review", "body": { "mode": "raw", "raw": "{\"resume_text\": \"Senior Engineer with 5 years experience...\", \"target_role\": \"Staff Engineer\"}", "options": { "raw": { "language": "json" } } } }
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"name": "Job Match",
|
| 106 |
+
"request": { "method": "POST", "url": "{{base_url}}/ai/job-match", "body": { "mode": "raw", "raw": "{\"resume_text\": \"...\", \"job_description\": \"...\"}", "options": { "raw": { "language": "json" } } } }
|
| 107 |
+
},
|
| 108 |
+
{
|
| 109 |
+
"name": "Cover Letter",
|
| 110 |
+
"request": { "method": "POST", "url": "{{base_url}}/ai/cover-letter", "body": { "mode": "raw", "raw": "{\"resume_text\": \"...\", \"job_description\": \"...\", \"company_name\": \"Google\"}", "options": { "raw": { "language": "json" } } } }
|
| 111 |
+
},
|
| 112 |
+
{
|
| 113 |
+
"name": "List Providers",
|
| 114 |
+
"request": { "method": "GET", "url": "{{base_url}}/ai/providers" }
|
| 115 |
+
},
|
| 116 |
+
{
|
| 117 |
+
"name": "Interview Questions",
|
| 118 |
+
"request": { "method": "POST", "url": "{{base_url}}/ai/interview/questions", "body": { "mode": "raw", "raw": "{\"job_title\": \"Senior Engineer\", \"job_description\": \"Build distributed systems...\", \"interview_type\": \"behavioral\", \"num_questions\": 5}", "options": { "raw": { "language": "json" } } } }
|
| 119 |
+
},
|
| 120 |
+
{
|
| 121 |
+
"name": "Company Research",
|
| 122 |
+
"request": { "method": "POST", "url": "{{base_url}}/ai/interview/company-research", "body": { "mode": "raw", "raw": "{\"company_name\": \"Stripe\", \"job_title\": \"Backend Engineer\"}", "options": { "raw": { "language": "json" } } } }
|
| 123 |
+
}
|
| 124 |
+
]
|
| 125 |
+
},
|
| 126 |
+
{
|
| 127 |
+
"name": "Profile & Resume",
|
| 128 |
+
"item": [
|
| 129 |
+
{
|
| 130 |
+
"name": "Get Profile",
|
| 131 |
+
"request": { "method": "GET", "url": "{{base_url}}/profile" }
|
| 132 |
+
},
|
| 133 |
+
{
|
| 134 |
+
"name": "Update Profile",
|
| 135 |
+
"request": { "method": "PATCH", "url": "{{base_url}}/profile", "body": { "mode": "raw", "raw": "{\"headline\": \"Full Stack Engineer\", \"location\": \"SF, CA\"}", "options": { "raw": { "language": "json" } } } }
|
| 136 |
+
},
|
| 137 |
+
{
|
| 138 |
+
"name": "List Resumes",
|
| 139 |
+
"request": { "method": "GET", "url": "{{base_url}}/resumes" }
|
| 140 |
+
},
|
| 141 |
+
{
|
| 142 |
+
"name": "Create Resume",
|
| 143 |
+
"request": { "method": "POST", "url": "{{base_url}}/resumes", "body": { "mode": "raw", "raw": "{\"name\": \"SWE Resume\", \"template_id\": \"simple\", \"target_role\": \"Senior SWE\"}", "options": { "raw": { "language": "json" } } } }
|
| 144 |
+
}
|
| 145 |
+
]
|
| 146 |
+
},
|
| 147 |
+
{
|
| 148 |
+
"name": "Alerts & Notifications",
|
| 149 |
+
"item": [
|
| 150 |
+
{
|
| 151 |
+
"name": "List Alerts",
|
| 152 |
+
"request": { "method": "GET", "url": "{{base_url}}/alerts" }
|
| 153 |
+
},
|
| 154 |
+
{
|
| 155 |
+
"name": "Create Alert",
|
| 156 |
+
"request": { "method": "POST", "url": "{{base_url}}/alerts", "body": { "mode": "raw", "raw": "{\"name\": \"Remote React Jobs\", \"query\": \"React\", \"filters\": {\"remote_type\": \"remote\"}, \"alert_frequency\": \"daily\"}", "options": { "raw": { "language": "json" } } } }
|
| 157 |
+
},
|
| 158 |
+
{
|
| 159 |
+
"name": "List Notifications",
|
| 160 |
+
"request": { "method": "GET", "url": "{{base_url}}/notifications" }
|
| 161 |
+
},
|
| 162 |
+
{
|
| 163 |
+
"name": "Mark All Read",
|
| 164 |
+
"request": { "method": "POST", "url": "{{base_url}}/notifications/read-all" }
|
| 165 |
+
}
|
| 166 |
+
]
|
| 167 |
+
},
|
| 168 |
+
{
|
| 169 |
+
"name": "Export",
|
| 170 |
+
"item": [
|
| 171 |
+
{
|
| 172 |
+
"name": "Export Applications CSV",
|
| 173 |
+
"request": { "method": "GET", "url": "{{base_url}}/export/applications/csv" }
|
| 174 |
+
},
|
| 175 |
+
{
|
| 176 |
+
"name": "Export Profile JSON (GDPR)",
|
| 177 |
+
"request": { "method": "GET", "url": "{{base_url}}/export/profile/json" }
|
| 178 |
+
},
|
| 179 |
+
{
|
| 180 |
+
"name": "Delete Account",
|
| 181 |
+
"request": { "method": "DELETE", "url": "{{base_url}}/export/account" }
|
| 182 |
+
}
|
| 183 |
+
]
|
| 184 |
+
},
|
| 185 |
+
{
|
| 186 |
+
"name": "Admin",
|
| 187 |
+
"item": [
|
| 188 |
+
{
|
| 189 |
+
"name": "System Health",
|
| 190 |
+
"request": { "method": "GET", "url": "{{base_url}}/admin/health" }
|
| 191 |
+
},
|
| 192 |
+
{
|
| 193 |
+
"name": "List Sources",
|
| 194 |
+
"request": { "method": "GET", "url": "{{base_url}}/admin/sources" }
|
| 195 |
+
},
|
| 196 |
+
{
|
| 197 |
+
"name": "Create Source",
|
| 198 |
+
"request": { "method": "POST", "url": "{{base_url}}/admin/sources", "body": { "mode": "raw", "raw": "{\"name\": \"Greenhouse - Stripe\", \"source_type\": \"ats_api\", \"domain\": \"stripe.com\", \"base_url\": \"https://boards-api.greenhouse.io/v1/boards/stripe/jobs\", \"ats_vendor\": \"greenhouse\", \"ats_config\": {\"board_token\": \"stripe\"}}", "options": { "raw": { "language": "json" } } } }
|
| 199 |
+
},
|
| 200 |
+
{
|
| 201 |
+
"name": "Trigger Scrape",
|
| 202 |
+
"request": { "method": "POST", "url": "{{base_url}}/admin/sources/{{source_id}}/scrape" }
|
| 203 |
+
}
|
| 204 |
+
]
|
| 205 |
+
}
|
| 206 |
+
]
|
| 207 |
+
}
|
frontend/e2e/pytest.ini
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[pytest]
|
| 2 |
+
base_url = http://localhost:3000
|
| 3 |
+
|
| 4 |
+
[tool.pytest.ini_options]
|
| 5 |
+
asyncio_mode = "auto"
|
frontend/e2e/test_flows.py
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
End-to-end tests with Playwright.
|
| 3 |
+
Tests critical user flows: register, login, search jobs, track application.
|
| 4 |
+
"""
|
| 5 |
+
import re
|
| 6 |
+
from playwright.sync_api import Page, expect
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
BASE_URL = "http://localhost:3000"
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class TestAuthFlow:
|
| 13 |
+
"""Test registration and login flows."""
|
| 14 |
+
|
| 15 |
+
def test_register_new_user(self, page: Page):
|
| 16 |
+
page.goto(f"{BASE_URL}/register")
|
| 17 |
+
|
| 18 |
+
# Fill form
|
| 19 |
+
page.fill('[id="name"]', "E2E Test User")
|
| 20 |
+
page.fill('[id="email"]', "e2e@example.com")
|
| 21 |
+
page.fill('[id="password"]', "testpass123")
|
| 22 |
+
page.fill('[id="confirm"]', "testpass123")
|
| 23 |
+
|
| 24 |
+
# Submit
|
| 25 |
+
page.click('button[type="submit"]')
|
| 26 |
+
|
| 27 |
+
# Should redirect to jobs page
|
| 28 |
+
page.wait_for_url("**/jobs")
|
| 29 |
+
expect(page).to_have_url(re.compile(r"/jobs"))
|
| 30 |
+
|
| 31 |
+
def test_login_existing_user(self, page: Page):
|
| 32 |
+
page.goto(f"{BASE_URL}/login")
|
| 33 |
+
|
| 34 |
+
page.fill('[id="email"]', "demo@jobportal.dev")
|
| 35 |
+
page.fill('[id="password"]', "demo123")
|
| 36 |
+
page.click('button[type="submit"]')
|
| 37 |
+
|
| 38 |
+
page.wait_for_url("**/jobs")
|
| 39 |
+
expect(page).to_have_url(re.compile(r"/jobs"))
|
| 40 |
+
|
| 41 |
+
def test_login_invalid_credentials(self, page: Page):
|
| 42 |
+
page.goto(f"{BASE_URL}/login")
|
| 43 |
+
|
| 44 |
+
page.fill('[id="email"]', "wrong@example.com")
|
| 45 |
+
page.fill('[id="password"]', "wrongpass")
|
| 46 |
+
page.click('button[type="submit"]')
|
| 47 |
+
|
| 48 |
+
# Should show error message
|
| 49 |
+
expect(page.locator("text=Invalid")).to_be_visible()
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
class TestJobSearch:
|
| 53 |
+
"""Test job search and filtering."""
|
| 54 |
+
|
| 55 |
+
def test_search_jobs(self, page: Page):
|
| 56 |
+
# Login first
|
| 57 |
+
self._login(page)
|
| 58 |
+
|
| 59 |
+
# Should be on jobs page
|
| 60 |
+
expect(page.locator("h1")).to_contain_text("Find Jobs")
|
| 61 |
+
|
| 62 |
+
# Search
|
| 63 |
+
page.fill('input[placeholder*="Search"]', "Python")
|
| 64 |
+
page.click('button:has-text("Search")')
|
| 65 |
+
|
| 66 |
+
# Should show results
|
| 67 |
+
page.wait_for_timeout(1000)
|
| 68 |
+
|
| 69 |
+
def test_filter_remote_jobs(self, page: Page):
|
| 70 |
+
self._login(page)
|
| 71 |
+
|
| 72 |
+
# Select remote filter
|
| 73 |
+
page.select_option('select[aria-label="Remote"]', "remote")
|
| 74 |
+
page.wait_for_timeout(500)
|
| 75 |
+
|
| 76 |
+
def test_view_job_detail(self, page: Page):
|
| 77 |
+
self._login(page)
|
| 78 |
+
|
| 79 |
+
# Click first job
|
| 80 |
+
first_job = page.locator("a[href*='/jobs/']").first
|
| 81 |
+
if first_job.is_visible():
|
| 82 |
+
first_job.click()
|
| 83 |
+
page.wait_for_url("**/jobs/**")
|
| 84 |
+
expect(page.locator("h1")).to_be_visible()
|
| 85 |
+
|
| 86 |
+
def _login(self, page: Page):
|
| 87 |
+
page.goto(f"{BASE_URL}/login")
|
| 88 |
+
page.fill('[id="email"]', "demo@jobportal.dev")
|
| 89 |
+
page.fill('[id="password"]', "demo123")
|
| 90 |
+
page.click('button[type="submit"]')
|
| 91 |
+
page.wait_for_url("**/jobs")
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
class TestApplicationTracker:
|
| 95 |
+
"""Test application tracking kanban."""
|
| 96 |
+
|
| 97 |
+
def test_create_application(self, page: Page):
|
| 98 |
+
self._login(page)
|
| 99 |
+
page.goto(f"{BASE_URL}/applications")
|
| 100 |
+
|
| 101 |
+
# Click add
|
| 102 |
+
page.click('button:has-text("Add Application")')
|
| 103 |
+
|
| 104 |
+
# Fill modal
|
| 105 |
+
page.fill('input[placeholder*="Job Title"]', "E2E Test Engineer")
|
| 106 |
+
page.fill('input[placeholder*="Company"]', "TestCorp")
|
| 107 |
+
page.click('button:has-text("Add")')
|
| 108 |
+
|
| 109 |
+
# Should appear in kanban
|
| 110 |
+
page.wait_for_timeout(1000)
|
| 111 |
+
expect(page.locator("text=E2E Test Engineer")).to_be_visible()
|
| 112 |
+
|
| 113 |
+
def test_kanban_columns_exist(self, page: Page):
|
| 114 |
+
self._login(page)
|
| 115 |
+
page.goto(f"{BASE_URL}/applications")
|
| 116 |
+
|
| 117 |
+
expect(page.locator("text=Wishlist")).to_be_visible()
|
| 118 |
+
expect(page.locator("text=Applied")).to_be_visible()
|
| 119 |
+
expect(page.locator("text=Interviewing")).to_be_visible()
|
| 120 |
+
|
| 121 |
+
def _login(self, page: Page):
|
| 122 |
+
page.goto(f"{BASE_URL}/login")
|
| 123 |
+
page.fill('[id="email"]', "demo@jobportal.dev")
|
| 124 |
+
page.fill('[id="password"]', "demo123")
|
| 125 |
+
page.click('button[type="submit"]')
|
| 126 |
+
page.wait_for_url("**/jobs")
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
class TestResumeBuilder:
|
| 130 |
+
"""Test resume management."""
|
| 131 |
+
|
| 132 |
+
def test_resume_page_loads(self, page: Page):
|
| 133 |
+
self._login(page)
|
| 134 |
+
page.goto(f"{BASE_URL}/resume")
|
| 135 |
+
|
| 136 |
+
expect(page.locator("h1")).to_contain_text("Resume Builder")
|
| 137 |
+
# Should show templates
|
| 138 |
+
expect(page.locator("text=Simple ATS")).to_be_visible()
|
| 139 |
+
|
| 140 |
+
def test_create_resume(self, page: Page):
|
| 141 |
+
self._login(page)
|
| 142 |
+
page.goto(f"{BASE_URL}/resume")
|
| 143 |
+
|
| 144 |
+
page.click('button:has-text("New Resume")')
|
| 145 |
+
page.fill('input[placeholder*="Software Engineer"]', "My Test Resume")
|
| 146 |
+
page.click('button:has-text("Create")')
|
| 147 |
+
|
| 148 |
+
page.wait_for_timeout(1000)
|
| 149 |
+
|
| 150 |
+
def _login(self, page: Page):
|
| 151 |
+
page.goto(f"{BASE_URL}/login")
|
| 152 |
+
page.fill('[id="email"]', "demo@jobportal.dev")
|
| 153 |
+
page.fill('[id="password"]', "demo123")
|
| 154 |
+
page.click('button[type="submit"]')
|
| 155 |
+
page.wait_for_url("**/jobs")
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
class TestProfile:
|
| 159 |
+
"""Test profile editing."""
|
| 160 |
+
|
| 161 |
+
def test_profile_page_loads(self, page: Page):
|
| 162 |
+
self._login(page)
|
| 163 |
+
page.goto(f"{BASE_URL}/profile")
|
| 164 |
+
|
| 165 |
+
expect(page.locator("h1")).to_contain_text("Profile")
|
| 166 |
+
expect(page.locator("text=Basics")).to_be_visible()
|
| 167 |
+
expect(page.locator("text=Experience")).to_be_visible()
|
| 168 |
+
|
| 169 |
+
def test_edit_profile_basics(self, page: Page):
|
| 170 |
+
self._login(page)
|
| 171 |
+
page.goto(f"{BASE_URL}/profile")
|
| 172 |
+
|
| 173 |
+
page.fill('input[placeholder*="Senior Software"]', "Full Stack Developer")
|
| 174 |
+
page.fill('input[placeholder*="San Francisco"]', "New York, NY")
|
| 175 |
+
page.click('button:has-text("Save")')
|
| 176 |
+
|
| 177 |
+
page.wait_for_timeout(1000)
|
| 178 |
+
|
| 179 |
+
def _login(self, page: Page):
|
| 180 |
+
page.goto(f"{BASE_URL}/login")
|
| 181 |
+
page.fill('[id="email"]', "demo@jobportal.dev")
|
| 182 |
+
page.fill('[id="password"]', "demo123")
|
| 183 |
+
page.click('button[type="submit"]')
|
| 184 |
+
page.wait_for_url("**/jobs")
|
frontend/src/app/(dashboard)/admin/page.tsx
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import { useState } from "react";
|
| 4 |
+
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
| 5 |
+
import {
|
| 6 |
+
Activity,
|
| 7 |
+
Database,
|
| 8 |
+
Globe,
|
| 9 |
+
Play,
|
| 10 |
+
Plus,
|
| 11 |
+
RefreshCw,
|
| 12 |
+
Server,
|
| 13 |
+
Users,
|
| 14 |
+
Zap,
|
| 15 |
+
AlertTriangle,
|
| 16 |
+
} from "lucide-react";
|
| 17 |
+
import { apiClient } from "@/lib/api/client";
|
| 18 |
+
|
| 19 |
+
interface SystemHealth {
|
| 20 |
+
total_jobs: number;
|
| 21 |
+
active_jobs: number;
|
| 22 |
+
expired_jobs: number;
|
| 23 |
+
total_sources: number;
|
| 24 |
+
active_sources: number;
|
| 25 |
+
total_users: number;
|
| 26 |
+
total_scrape_runs: number;
|
| 27 |
+
recent_failures: number;
|
| 28 |
+
last_scrape_at: string | null;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
interface Source {
|
| 32 |
+
id: string;
|
| 33 |
+
name: string;
|
| 34 |
+
source_type: string;
|
| 35 |
+
domain: string;
|
| 36 |
+
base_url: string;
|
| 37 |
+
ats_vendor: string | null;
|
| 38 |
+
status: string;
|
| 39 |
+
crawl_frequency_hours: number;
|
| 40 |
+
last_crawled_at: string | null;
|
| 41 |
+
last_success_at: string | null;
|
| 42 |
+
consecutive_failures: number;
|
| 43 |
+
total_jobs_found: number;
|
| 44 |
+
created_at: string;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
export default function AdminPage() {
|
| 48 |
+
const [activeTab, setActiveTab] = useState<"overview" | "sources" | "runs">("overview");
|
| 49 |
+
|
| 50 |
+
return (
|
| 51 |
+
<div className="space-y-6">
|
| 52 |
+
<div>
|
| 53 |
+
<h1 className="text-2xl font-bold">Admin Dashboard</h1>
|
| 54 |
+
<p className="text-muted-foreground">System health, scraper management, and monitoring</p>
|
| 55 |
+
</div>
|
| 56 |
+
|
| 57 |
+
<div className="flex gap-1 rounded-lg border bg-muted p-1">
|
| 58 |
+
{[
|
| 59 |
+
{ id: "overview" as const, label: "Overview", icon: Activity },
|
| 60 |
+
{ id: "sources" as const, label: "Sources", icon: Globe },
|
| 61 |
+
{ id: "runs" as const, label: "Scrape Runs", icon: Zap },
|
| 62 |
+
].map((tab) => {
|
| 63 |
+
const Icon = tab.icon;
|
| 64 |
+
return (
|
| 65 |
+
<button
|
| 66 |
+
key={tab.id}
|
| 67 |
+
onClick={() => setActiveTab(tab.id)}
|
| 68 |
+
className={`flex items-center gap-2 rounded-md px-4 py-2 text-sm font-medium transition-colors ${
|
| 69 |
+
activeTab === tab.id ? "bg-background shadow-sm" : "text-muted-foreground"
|
| 70 |
+
}`}
|
| 71 |
+
>
|
| 72 |
+
<Icon className="h-4 w-4" />
|
| 73 |
+
{tab.label}
|
| 74 |
+
</button>
|
| 75 |
+
);
|
| 76 |
+
})}
|
| 77 |
+
</div>
|
| 78 |
+
|
| 79 |
+
{activeTab === "overview" && <OverviewTab />}
|
| 80 |
+
{activeTab === "sources" && <SourcesTab />}
|
| 81 |
+
{activeTab === "runs" && <RunsTab />}
|
| 82 |
+
</div>
|
| 83 |
+
);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
function OverviewTab() {
|
| 87 |
+
const { data: health, isLoading } = useQuery({
|
| 88 |
+
queryKey: ["admin-health"],
|
| 89 |
+
queryFn: async () => {
|
| 90 |
+
const res = await apiClient.get<SystemHealth>("/admin/health");
|
| 91 |
+
return res.data;
|
| 92 |
+
},
|
| 93 |
+
refetchInterval: 30000,
|
| 94 |
+
});
|
| 95 |
+
|
| 96 |
+
if (isLoading) return <div className="h-48 animate-pulse rounded-lg border bg-muted" />;
|
| 97 |
+
|
| 98 |
+
return (
|
| 99 |
+
<div className="space-y-6">
|
| 100 |
+
{/* Stats Grid */}
|
| 101 |
+
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
| 102 |
+
<StatCard icon={<Database className="h-5 w-5" />} label="Active Jobs" value={health?.active_jobs || 0} subtitle={`${health?.expired_jobs || 0} expired`} />
|
| 103 |
+
<StatCard icon={<Globe className="h-5 w-5" />} label="Active Sources" value={health?.active_sources || 0} subtitle={`${health?.total_sources || 0} total`} />
|
| 104 |
+
<StatCard icon={<Users className="h-5 w-5" />} label="Users" value={health?.total_users || 0} />
|
| 105 |
+
<StatCard
|
| 106 |
+
icon={<AlertTriangle className="h-5 w-5" />}
|
| 107 |
+
label="Recent Failures (24h)"
|
| 108 |
+
value={health?.recent_failures || 0}
|
| 109 |
+
variant={health?.recent_failures && health.recent_failures > 0 ? "destructive" : "default"}
|
| 110 |
+
/>
|
| 111 |
+
</div>
|
| 112 |
+
|
| 113 |
+
{/* Summary */}
|
| 114 |
+
<div className="rounded-lg border bg-card p-6">
|
| 115 |
+
<h3 className="mb-4 font-semibold">System Status</h3>
|
| 116 |
+
<div className="space-y-3">
|
| 117 |
+
<div className="flex items-center justify-between text-sm">
|
| 118 |
+
<span>Total scrape runs</span>
|
| 119 |
+
<span className="font-medium">{health?.total_scrape_runs || 0}</span>
|
| 120 |
+
</div>
|
| 121 |
+
<div className="flex items-center justify-between text-sm">
|
| 122 |
+
<span>Last scrape</span>
|
| 123 |
+
<span className="font-medium">
|
| 124 |
+
{health?.last_scrape_at ? new Date(health.last_scrape_at).toLocaleString() : "Never"}
|
| 125 |
+
</span>
|
| 126 |
+
</div>
|
| 127 |
+
<div className="flex items-center justify-between text-sm">
|
| 128 |
+
<span>Database</span>
|
| 129 |
+
<span className="rounded-full bg-green-100 px-2 py-0.5 text-xs text-green-700 dark:bg-green-900 dark:text-green-300">
|
| 130 |
+
Healthy
|
| 131 |
+
</span>
|
| 132 |
+
</div>
|
| 133 |
+
<div className="flex items-center justify-between text-sm">
|
| 134 |
+
<span>Redis</span>
|
| 135 |
+
<span className="rounded-full bg-green-100 px-2 py-0.5 text-xs text-green-700 dark:bg-green-900 dark:text-green-300">
|
| 136 |
+
Connected
|
| 137 |
+
</span>
|
| 138 |
+
</div>
|
| 139 |
+
</div>
|
| 140 |
+
</div>
|
| 141 |
+
</div>
|
| 142 |
+
);
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
function SourcesTab() {
|
| 146 |
+
const queryClient = useQueryClient();
|
| 147 |
+
const [showAdd, setShowAdd] = useState(false);
|
| 148 |
+
|
| 149 |
+
const { data: sources, isLoading } = useQuery({
|
| 150 |
+
queryKey: ["admin-sources"],
|
| 151 |
+
queryFn: async () => {
|
| 152 |
+
const res = await apiClient.get<Source[]>("/admin/sources");
|
| 153 |
+
return res.data;
|
| 154 |
+
},
|
| 155 |
+
});
|
| 156 |
+
|
| 157 |
+
const triggerScrape = useMutation({
|
| 158 |
+
mutationFn: async (sourceId: string) => {
|
| 159 |
+
await apiClient.post(`/admin/sources/${sourceId}/scrape`);
|
| 160 |
+
},
|
| 161 |
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["admin-sources"] }),
|
| 162 |
+
});
|
| 163 |
+
|
| 164 |
+
return (
|
| 165 |
+
<div className="space-y-4">
|
| 166 |
+
<div className="flex justify-end">
|
| 167 |
+
<button
|
| 168 |
+
onClick={() => setShowAdd(true)}
|
| 169 |
+
className="inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground"
|
| 170 |
+
>
|
| 171 |
+
<Plus className="h-4 w-4" /> Add Source
|
| 172 |
+
</button>
|
| 173 |
+
</div>
|
| 174 |
+
|
| 175 |
+
{isLoading ? (
|
| 176 |
+
<div className="space-y-3">
|
| 177 |
+
{[...Array(3)].map((_, i) => (
|
| 178 |
+
<div key={i} className="h-20 animate-pulse rounded-lg border bg-muted" />
|
| 179 |
+
))}
|
| 180 |
+
</div>
|
| 181 |
+
) : (
|
| 182 |
+
<div className="space-y-3">
|
| 183 |
+
{sources?.map((source) => (
|
| 184 |
+
<div key={source.id} className="rounded-lg border bg-card p-4">
|
| 185 |
+
<div className="flex items-center justify-between">
|
| 186 |
+
<div>
|
| 187 |
+
<div className="flex items-center gap-2">
|
| 188 |
+
<h3 className="font-medium">{source.name}</h3>
|
| 189 |
+
<span className={`rounded-full px-2 py-0.5 text-xs ${
|
| 190 |
+
source.status === "active" ? "bg-green-100 text-green-700 dark:bg-green-900 dark:text-green-300"
|
| 191 |
+
: "bg-yellow-100 text-yellow-700 dark:bg-yellow-900 dark:text-yellow-300"
|
| 192 |
+
}`}>
|
| 193 |
+
{source.status}
|
| 194 |
+
</span>
|
| 195 |
+
{source.ats_vendor && (
|
| 196 |
+
<span className="rounded-full bg-muted px-2 py-0.5 text-xs capitalize">
|
| 197 |
+
{source.ats_vendor}
|
| 198 |
+
</span>
|
| 199 |
+
)}
|
| 200 |
+
</div>
|
| 201 |
+
<div className="mt-1 flex items-center gap-4 text-xs text-muted-foreground">
|
| 202 |
+
<span>{source.domain}</span>
|
| 203 |
+
<span>Every {source.crawl_frequency_hours}h</span>
|
| 204 |
+
<span>{source.total_jobs_found} jobs found</span>
|
| 205 |
+
{source.consecutive_failures > 0 && (
|
| 206 |
+
<span className="text-destructive">{source.consecutive_failures} failures</span>
|
| 207 |
+
)}
|
| 208 |
+
{source.last_crawled_at && (
|
| 209 |
+
<span>Last: {new Date(source.last_crawled_at).toLocaleString()}</span>
|
| 210 |
+
)}
|
| 211 |
+
</div>
|
| 212 |
+
</div>
|
| 213 |
+
<button
|
| 214 |
+
onClick={() => triggerScrape.mutate(source.id)}
|
| 215 |
+
disabled={triggerScrape.isPending}
|
| 216 |
+
className="inline-flex items-center gap-1 rounded-md border px-3 py-1.5 text-xs hover:bg-accent"
|
| 217 |
+
>
|
| 218 |
+
<Play className="h-3 w-3" />
|
| 219 |
+
Scrape Now
|
| 220 |
+
</button>
|
| 221 |
+
</div>
|
| 222 |
+
</div>
|
| 223 |
+
))}
|
| 224 |
+
</div>
|
| 225 |
+
)}
|
| 226 |
+
|
| 227 |
+
{showAdd && <AddSourceModal onClose={() => setShowAdd(false)} />}
|
| 228 |
+
</div>
|
| 229 |
+
);
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
function RunsTab() {
|
| 233 |
+
// Placeholder - shows recent scrape runs across all sources
|
| 234 |
+
return (
|
| 235 |
+
<div className="rounded-lg border bg-card p-6 text-center text-sm text-muted-foreground">
|
| 236 |
+
<RefreshCw className="mx-auto h-8 w-8 mb-2" />
|
| 237 |
+
<p>Select a source to view its scrape run history.</p>
|
| 238 |
+
<p className="mt-1">Go to Sources tab → click a source to see runs.</p>
|
| 239 |
+
</div>
|
| 240 |
+
);
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
function StatCard({
|
| 244 |
+
icon,
|
| 245 |
+
label,
|
| 246 |
+
value,
|
| 247 |
+
subtitle,
|
| 248 |
+
variant = "default",
|
| 249 |
+
}: {
|
| 250 |
+
icon: React.ReactNode;
|
| 251 |
+
label: string;
|
| 252 |
+
value: number | string;
|
| 253 |
+
subtitle?: string;
|
| 254 |
+
variant?: "default" | "destructive";
|
| 255 |
+
}) {
|
| 256 |
+
return (
|
| 257 |
+
<div className="rounded-lg border bg-card p-4">
|
| 258 |
+
<div className="flex items-center gap-2 text-muted-foreground">
|
| 259 |
+
{icon}
|
| 260 |
+
<span className="text-sm">{label}</span>
|
| 261 |
+
</div>
|
| 262 |
+
<p className={`mt-2 text-2xl font-bold ${variant === "destructive" && value ? "text-destructive" : ""}`}>
|
| 263 |
+
{value}
|
| 264 |
+
</p>
|
| 265 |
+
{subtitle && <p className="text-xs text-muted-foreground">{subtitle}</p>}
|
| 266 |
+
</div>
|
| 267 |
+
);
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
function AddSourceModal({ onClose }: { onClose: () => void }) {
|
| 271 |
+
const queryClient = useQueryClient();
|
| 272 |
+
const [form, setForm] = useState({
|
| 273 |
+
name: "",
|
| 274 |
+
source_type: "ats_api",
|
| 275 |
+
domain: "",
|
| 276 |
+
base_url: "",
|
| 277 |
+
ats_vendor: "greenhouse",
|
| 278 |
+
ats_config: { board_token: "" },
|
| 279 |
+
});
|
| 280 |
+
|
| 281 |
+
const create = useMutation({
|
| 282 |
+
mutationFn: async () => {
|
| 283 |
+
await apiClient.post("/admin/sources", form);
|
| 284 |
+
},
|
| 285 |
+
onSuccess: () => {
|
| 286 |
+
queryClient.invalidateQueries({ queryKey: ["admin-sources"] });
|
| 287 |
+
onClose();
|
| 288 |
+
},
|
| 289 |
+
});
|
| 290 |
+
|
| 291 |
+
return (
|
| 292 |
+
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/50">
|
| 293 |
+
<div className="w-full max-w-md rounded-lg bg-card p-6 shadow-lg">
|
| 294 |
+
<h2 className="mb-4 text-lg font-semibold">Add Job Source</h2>
|
| 295 |
+
<form onSubmit={(e) => { e.preventDefault(); create.mutate(); }} className="space-y-3">
|
| 296 |
+
<div>
|
| 297 |
+
<label className="mb-1 block text-xs font-medium">Name</label>
|
| 298 |
+
<input
|
| 299 |
+
value={form.name}
|
| 300 |
+
onChange={(e) => setForm((p) => ({ ...p, name: e.target.value }))}
|
| 301 |
+
className="w-full rounded-md border bg-background px-3 py-2 text-sm"
|
| 302 |
+
placeholder="Greenhouse - Stripe"
|
| 303 |
+
required
|
| 304 |
+
/>
|
| 305 |
+
</div>
|
| 306 |
+
<div className="grid grid-cols-2 gap-3">
|
| 307 |
+
<div>
|
| 308 |
+
<label className="mb-1 block text-xs font-medium">Type</label>
|
| 309 |
+
<select
|
| 310 |
+
value={form.source_type}
|
| 311 |
+
onChange={(e) => setForm((p) => ({ ...p, source_type: e.target.value }))}
|
| 312 |
+
className="w-full rounded-md border bg-background px-3 py-2 text-sm"
|
| 313 |
+
>
|
| 314 |
+
<option value="ats_api">ATS API</option>
|
| 315 |
+
<option value="careers_page">Careers Page</option>
|
| 316 |
+
<option value="sitemap">Sitemap</option>
|
| 317 |
+
</select>
|
| 318 |
+
</div>
|
| 319 |
+
<div>
|
| 320 |
+
<label className="mb-1 block text-xs font-medium">ATS Vendor</label>
|
| 321 |
+
<select
|
| 322 |
+
value={form.ats_vendor}
|
| 323 |
+
onChange={(e) => setForm((p) => ({ ...p, ats_vendor: e.target.value }))}
|
| 324 |
+
className="w-full rounded-md border bg-background px-3 py-2 text-sm"
|
| 325 |
+
>
|
| 326 |
+
<option value="greenhouse">Greenhouse</option>
|
| 327 |
+
<option value="lever">Lever</option>
|
| 328 |
+
<option value="ashby">Ashby</option>
|
| 329 |
+
<option value="workday">Workday</option>
|
| 330 |
+
<option value="smartrecruiters">SmartRecruiters</option>
|
| 331 |
+
</select>
|
| 332 |
+
</div>
|
| 333 |
+
</div>
|
| 334 |
+
<div>
|
| 335 |
+
<label className="mb-1 block text-xs font-medium">Domain</label>
|
| 336 |
+
<input
|
| 337 |
+
value={form.domain}
|
| 338 |
+
onChange={(e) => setForm((p) => ({ ...p, domain: e.target.value }))}
|
| 339 |
+
className="w-full rounded-md border bg-background px-3 py-2 text-sm"
|
| 340 |
+
placeholder="stripe.com"
|
| 341 |
+
required
|
| 342 |
+
/>
|
| 343 |
+
</div>
|
| 344 |
+
<div>
|
| 345 |
+
<label className="mb-1 block text-xs font-medium">Board Token / Slug</label>
|
| 346 |
+
<input
|
| 347 |
+
value={form.ats_config.board_token}
|
| 348 |
+
onChange={(e) => setForm((p) => ({ ...p, ats_config: { board_token: e.target.value } }))}
|
| 349 |
+
className="w-full rounded-md border bg-background px-3 py-2 text-sm"
|
| 350 |
+
placeholder="stripe"
|
| 351 |
+
required
|
| 352 |
+
/>
|
| 353 |
+
</div>
|
| 354 |
+
<div className="flex justify-end gap-2 pt-2">
|
| 355 |
+
<button type="button" onClick={onClose} className="rounded-md border px-4 py-2 text-sm">Cancel</button>
|
| 356 |
+
<button type="submit" disabled={create.isPending} className="rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground">
|
| 357 |
+
{create.isPending ? "Creating..." : "Add Source"}
|
| 358 |
+
</button>
|
| 359 |
+
</div>
|
| 360 |
+
</form>
|
| 361 |
+
</div>
|
| 362 |
+
</div>
|
| 363 |
+
);
|
| 364 |
+
}
|
frontend/src/app/(dashboard)/layout.tsx
CHANGED
|
@@ -9,13 +9,14 @@ import {
|
|
| 9 |
Search,
|
| 10 |
Settings,
|
| 11 |
User,
|
| 12 |
-
Brain,
|
| 13 |
Bell,
|
| 14 |
LogOut,
|
| 15 |
MessageSquare,
|
|
|
|
| 16 |
} from "lucide-react";
|
| 17 |
import { cn } from "@/lib/utils";
|
| 18 |
import { useAuthStore } from "@/store/auth";
|
|
|
|
| 19 |
|
| 20 |
const navItems = [
|
| 21 |
{ href: "/jobs", label: "Jobs", icon: Search },
|
|
@@ -27,6 +28,10 @@ const navItems = [
|
|
| 27 |
{ href: "/settings", label: "Settings", icon: Settings },
|
| 28 |
];
|
| 29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
export default function DashboardLayout({
|
| 31 |
children,
|
| 32 |
}: {
|
|
@@ -35,6 +40,10 @@ export default function DashboardLayout({
|
|
| 35 |
const pathname = usePathname();
|
| 36 |
const { user, logout } = useAuthStore();
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
return (
|
| 39 |
<div className="flex min-h-screen">
|
| 40 |
{/* Sidebar */}
|
|
@@ -48,7 +57,7 @@ export default function DashboardLayout({
|
|
| 48 |
|
| 49 |
{/* Navigation */}
|
| 50 |
<nav className="flex-1 space-y-1 p-4">
|
| 51 |
-
{
|
| 52 |
const Icon = item.icon;
|
| 53 |
const isActive = pathname.startsWith(item.href);
|
| 54 |
return (
|
|
@@ -95,6 +104,12 @@ export default function DashboardLayout({
|
|
| 95 |
|
| 96 |
{/* Main content */}
|
| 97 |
<main className="ml-64 flex-1">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
<div className="container mx-auto p-6">{children}</div>
|
| 99 |
</main>
|
| 100 |
</div>
|
|
|
|
| 9 |
Search,
|
| 10 |
Settings,
|
| 11 |
User,
|
|
|
|
| 12 |
Bell,
|
| 13 |
LogOut,
|
| 14 |
MessageSquare,
|
| 15 |
+
Shield,
|
| 16 |
} from "lucide-react";
|
| 17 |
import { cn } from "@/lib/utils";
|
| 18 |
import { useAuthStore } from "@/store/auth";
|
| 19 |
+
import { NotificationsDropdown } from "@/components/layout/notifications-dropdown";
|
| 20 |
|
| 21 |
const navItems = [
|
| 22 |
{ href: "/jobs", label: "Jobs", icon: Search },
|
|
|
|
| 28 |
{ href: "/settings", label: "Settings", icon: Settings },
|
| 29 |
];
|
| 30 |
|
| 31 |
+
const adminItems = [
|
| 32 |
+
{ href: "/admin", label: "Admin", icon: Shield },
|
| 33 |
+
];
|
| 34 |
+
|
| 35 |
export default function DashboardLayout({
|
| 36 |
children,
|
| 37 |
}: {
|
|
|
|
| 40 |
const pathname = usePathname();
|
| 41 |
const { user, logout } = useAuthStore();
|
| 42 |
|
| 43 |
+
// Show admin nav only for admin/superuser roles
|
| 44 |
+
const isAdmin = user?.role === "admin";
|
| 45 |
+
const allNavItems = isAdmin ? [...navItems, ...adminItems] : navItems;
|
| 46 |
+
|
| 47 |
return (
|
| 48 |
<div className="flex min-h-screen">
|
| 49 |
{/* Sidebar */}
|
|
|
|
| 57 |
|
| 58 |
{/* Navigation */}
|
| 59 |
<nav className="flex-1 space-y-1 p-4">
|
| 60 |
+
{allNavItems.map((item) => {
|
| 61 |
const Icon = item.icon;
|
| 62 |
const isActive = pathname.startsWith(item.href);
|
| 63 |
return (
|
|
|
|
| 104 |
|
| 105 |
{/* Main content */}
|
| 106 |
<main className="ml-64 flex-1">
|
| 107 |
+
{/* Top bar with notifications */}
|
| 108 |
+
<header className="sticky top-0 z-40 border-b bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60">
|
| 109 |
+
<div className="container mx-auto flex h-14 items-center justify-end px-6">
|
| 110 |
+
<NotificationsDropdown />
|
| 111 |
+
</div>
|
| 112 |
+
</header>
|
| 113 |
<div className="container mx-auto p-6">{children}</div>
|
| 114 |
</main>
|
| 115 |
</div>
|
frontend/src/components/layout/notifications-dropdown.tsx
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"use client";
|
| 2 |
+
|
| 3 |
+
import { useState, useEffect, useRef } from "react";
|
| 4 |
+
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
| 5 |
+
import { Bell, Check, CheckCheck, ExternalLink } from "lucide-react";
|
| 6 |
+
import { apiClient } from "@/lib/api/client";
|
| 7 |
+
|
| 8 |
+
interface Notification {
|
| 9 |
+
id: string;
|
| 10 |
+
type: string;
|
| 11 |
+
title: string;
|
| 12 |
+
body: string | null;
|
| 13 |
+
action_url: string | null;
|
| 14 |
+
is_read: boolean;
|
| 15 |
+
created_at: string;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
export function NotificationsDropdown() {
|
| 19 |
+
const [isOpen, setIsOpen] = useState(false);
|
| 20 |
+
const dropdownRef = useRef<HTMLDivElement>(null);
|
| 21 |
+
const queryClient = useQueryClient();
|
| 22 |
+
|
| 23 |
+
const { data } = useQuery({
|
| 24 |
+
queryKey: ["notifications"],
|
| 25 |
+
queryFn: async () => {
|
| 26 |
+
const res = await apiClient.get("/notifications", { params: { page_size: 10 } });
|
| 27 |
+
return res.data;
|
| 28 |
+
},
|
| 29 |
+
refetchInterval: 30000, // Poll every 30 seconds
|
| 30 |
+
});
|
| 31 |
+
|
| 32 |
+
const markRead = useMutation({
|
| 33 |
+
mutationFn: async (id: string) => {
|
| 34 |
+
await apiClient.post(`/notifications/${id}/read`);
|
| 35 |
+
},
|
| 36 |
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["notifications"] }),
|
| 37 |
+
});
|
| 38 |
+
|
| 39 |
+
const markAllRead = useMutation({
|
| 40 |
+
mutationFn: async () => {
|
| 41 |
+
await apiClient.post("/notifications/read-all");
|
| 42 |
+
},
|
| 43 |
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["notifications"] }),
|
| 44 |
+
});
|
| 45 |
+
|
| 46 |
+
// Close on outside click
|
| 47 |
+
useEffect(() => {
|
| 48 |
+
function handleClickOutside(event: MouseEvent) {
|
| 49 |
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target as Node)) {
|
| 50 |
+
setIsOpen(false);
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
document.addEventListener("mousedown", handleClickOutside);
|
| 54 |
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
| 55 |
+
}, []);
|
| 56 |
+
|
| 57 |
+
const unreadCount = data?.unread_count || 0;
|
| 58 |
+
const notifications: Notification[] = data?.notifications || [];
|
| 59 |
+
|
| 60 |
+
return (
|
| 61 |
+
<div className="relative" ref={dropdownRef}>
|
| 62 |
+
{/* Bell button */}
|
| 63 |
+
<button
|
| 64 |
+
onClick={() => setIsOpen(!isOpen)}
|
| 65 |
+
className="relative rounded-md p-2 text-muted-foreground hover:bg-accent hover:text-foreground"
|
| 66 |
+
>
|
| 67 |
+
<Bell className="h-5 w-5" />
|
| 68 |
+
{unreadCount > 0 && (
|
| 69 |
+
<span className="absolute -right-0.5 -top-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-destructive text-[10px] font-bold text-white">
|
| 70 |
+
{unreadCount > 9 ? "9+" : unreadCount}
|
| 71 |
+
</span>
|
| 72 |
+
)}
|
| 73 |
+
</button>
|
| 74 |
+
|
| 75 |
+
{/* Dropdown */}
|
| 76 |
+
{isOpen && (
|
| 77 |
+
<div className="absolute right-0 top-full z-50 mt-2 w-80 rounded-lg border bg-card shadow-lg">
|
| 78 |
+
{/* Header */}
|
| 79 |
+
<div className="flex items-center justify-between border-b px-4 py-3">
|
| 80 |
+
<h3 className="text-sm font-semibold">Notifications</h3>
|
| 81 |
+
{unreadCount > 0 && (
|
| 82 |
+
<button
|
| 83 |
+
onClick={() => markAllRead.mutate()}
|
| 84 |
+
className="flex items-center gap-1 text-xs text-primary hover:underline"
|
| 85 |
+
>
|
| 86 |
+
<CheckCheck className="h-3 w-3" />
|
| 87 |
+
Mark all read
|
| 88 |
+
</button>
|
| 89 |
+
)}
|
| 90 |
+
</div>
|
| 91 |
+
|
| 92 |
+
{/* Notifications list */}
|
| 93 |
+
<div className="max-h-96 overflow-y-auto">
|
| 94 |
+
{notifications.length === 0 ? (
|
| 95 |
+
<div className="p-6 text-center text-sm text-muted-foreground">
|
| 96 |
+
No notifications yet
|
| 97 |
+
</div>
|
| 98 |
+
) : (
|
| 99 |
+
notifications.map((notif) => (
|
| 100 |
+
<div
|
| 101 |
+
key={notif.id}
|
| 102 |
+
className={`flex items-start gap-3 border-b px-4 py-3 last:border-0 ${
|
| 103 |
+
!notif.is_read ? "bg-primary/5" : ""
|
| 104 |
+
}`}
|
| 105 |
+
>
|
| 106 |
+
<div className="flex-1 min-w-0">
|
| 107 |
+
<p className={`text-sm ${!notif.is_read ? "font-medium" : ""}`}>
|
| 108 |
+
{notif.title}
|
| 109 |
+
</p>
|
| 110 |
+
{notif.body && (
|
| 111 |
+
<p className="mt-0.5 truncate text-xs text-muted-foreground">
|
| 112 |
+
{notif.body}
|
| 113 |
+
</p>
|
| 114 |
+
)}
|
| 115 |
+
<p className="mt-1 text-xs text-muted-foreground">
|
| 116 |
+
{formatTimeAgo(notif.created_at)}
|
| 117 |
+
</p>
|
| 118 |
+
</div>
|
| 119 |
+
<div className="flex items-center gap-1">
|
| 120 |
+
{notif.action_url && (
|
| 121 |
+
<a
|
| 122 |
+
href={notif.action_url}
|
| 123 |
+
className="rounded p-1 text-muted-foreground hover:text-foreground"
|
| 124 |
+
>
|
| 125 |
+
<ExternalLink className="h-3 w-3" />
|
| 126 |
+
</a>
|
| 127 |
+
)}
|
| 128 |
+
{!notif.is_read && (
|
| 129 |
+
<button
|
| 130 |
+
onClick={() => markRead.mutate(notif.id)}
|
| 131 |
+
className="rounded p-1 text-muted-foreground hover:text-primary"
|
| 132 |
+
title="Mark as read"
|
| 133 |
+
>
|
| 134 |
+
<Check className="h-3 w-3" />
|
| 135 |
+
</button>
|
| 136 |
+
)}
|
| 137 |
+
</div>
|
| 138 |
+
</div>
|
| 139 |
+
))
|
| 140 |
+
)}
|
| 141 |
+
</div>
|
| 142 |
+
|
| 143 |
+
{/* Footer */}
|
| 144 |
+
<div className="border-t px-4 py-2 text-center">
|
| 145 |
+
<a href="/alerts" className="text-xs text-primary hover:underline">
|
| 146 |
+
Manage alerts
|
| 147 |
+
</a>
|
| 148 |
+
</div>
|
| 149 |
+
</div>
|
| 150 |
+
)}
|
| 151 |
+
</div>
|
| 152 |
+
);
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
function formatTimeAgo(dateStr: string): string {
|
| 156 |
+
const now = new Date();
|
| 157 |
+
const date = new Date(dateStr);
|
| 158 |
+
const seconds = Math.floor((now.getTime() - date.getTime()) / 1000);
|
| 159 |
+
|
| 160 |
+
if (seconds < 60) return "just now";
|
| 161 |
+
if (seconds < 3600) return `${Math.floor(seconds / 60)}m ago`;
|
| 162 |
+
if (seconds < 86400) return `${Math.floor(seconds / 3600)}h ago`;
|
| 163 |
+
if (seconds < 604800) return `${Math.floor(seconds / 86400)}d ago`;
|
| 164 |
+
return date.toLocaleDateString();
|
| 165 |
+
}
|
frontend/vercel.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"$schema": "https://openapi.vercel.sh/vercel.json",
|
| 3 |
+
"framework": "nextjs",
|
| 4 |
+
"buildCommand": "pnpm build",
|
| 5 |
+
"installCommand": "pnpm install",
|
| 6 |
+
"outputDirectory": ".next",
|
| 7 |
+
"env": {
|
| 8 |
+
"NEXT_PUBLIC_API_URL": "@api-url"
|
| 9 |
+
},
|
| 10 |
+
"headers": [
|
| 11 |
+
{
|
| 12 |
+
"source": "/(.*)",
|
| 13 |
+
"headers": [
|
| 14 |
+
{ "key": "X-Frame-Options", "value": "SAMEORIGIN" },
|
| 15 |
+
{ "key": "X-Content-Type-Options", "value": "nosniff" },
|
| 16 |
+
{ "key": "Referrer-Policy", "value": "strict-origin-when-cross-origin" }
|
| 17 |
+
]
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"source": "/_next/static/(.*)",
|
| 21 |
+
"headers": [
|
| 22 |
+
{ "key": "Cache-Control", "value": "public, max-age=31536000, immutable" }
|
| 23 |
+
]
|
| 24 |
+
}
|
| 25 |
+
],
|
| 26 |
+
"rewrites": [
|
| 27 |
+
{
|
| 28 |
+
"source": "/api/v1/:path*",
|
| 29 |
+
"destination": "https://jobportal-api.fly.dev/api/v1/:path*"
|
| 30 |
+
}
|
| 31 |
+
]
|
| 32 |
+
}
|