#!/bin/bash
echo "=== COMPREHENSIVE API TEST ==="

# 1. Test Authentication
echo "1. Testing Authentication..."
TOKEN=$(curl -s -X POST https://api.rockvilletollandsda.church/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username": "admin", "password": "Alright8-Reapply-Shrewdly-Platter-Important-Keenness-Banking-Streak-Tactile"}' \
  | jq -r '.success')
echo "Auth: $TOKEN"

# 2. Test Public Endpoints
echo "2. Testing Public Endpoints..."
curl -s https://api.rockvilletollandsda.church/api/events | jq '.success'
curl -s https://api.rockvilletollandsda.church/api/bulletins | jq '.success' 
curl -s https://api.rockvilletollandsda.church/api/config | jq '.success'

# 3. Test Admin Endpoints
echo "3. Testing Admin Endpoints..."
TOKEN=$(curl -s -X POST https://api.rockvilletollandsda.church/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"username": "admin", "password": "Alright8-Reapply-Shrewdly-Platter-Important-Keenness-Banking-Streak-Tactile"}' \
  | jq -r '.data.token')

curl -s -H "Authorization: Bearer $TOKEN" https://api.rockvilletollandsda.church/api/admin/events/pending | jq '.success'
curl -s -H "Authorization: Bearer $TOKEN" https://api.rockvilletollandsda.church/api/admin/config | jq '.success'

# 4. Check for any remaining placeholder text
echo "4. Checking for placeholders..."
PLACEHOLDERS=$(grep -r "implement as needed\|TODO\|Working!\|n/a\|TBA" src/ 2>/dev/null | wc -l)
echo "Placeholder count: $PLACEHOLDERS"

echo "=== TEST COMPLETE ==="
