#!/bin/bash

echo "=== Deployment Verification Script ==="
echo "Date: $(date)"
echo

# Test URLs
URLS=(
    "https://upskill-staging.measurequick.com/training-login/"
    "https://upskill-staging.measurequick.com/trainer/dashboard/"
    "https://upskill-staging.measurequick.com/trainer/event/manage/"
    "https://upskill-staging.measurequick.com/trainer/certificate-reports/"
    "https://upskill-staging.measurequick.com/master-trainer/dashboard/"
)

echo "🔍 Testing URL accessibility..."
echo

for url in "${URLS[@]}"; do
    echo -n "Testing: $url ... "
    
    response=$(curl -s -o /dev/null -w "%{http_code}" "$url")
    
    if [ "$response" -eq 200 ]; then
        echo "✅ OK ($response)"
    elif [ "$response" -eq 302 ] || [ "$response" -eq 301 ]; then
        echo "✅ Redirect ($response)"
    else
        echo "❌ Failed ($response)"
    fi
done

echo
echo "🔍 Testing login form accessibility..."
login_response=$(curl -s "https://upskill-staging.measurequick.com/training-login/")

if echo "$login_response" | grep -q "user_login" && echo "$login_response" | grep -q "user_pass"; then
    echo "✅ Login form elements found"
else
    echo "❌ Login form elements missing"
fi

echo
echo "🔍 Testing for plugin activation indicators..."
if echo "$login_response" | grep -q "hvac"; then
    echo "✅ HVAC plugin CSS/JS detected"
else
    echo "❌ HVAC plugin indicators not found"
fi

echo
echo "=== Basic deployment verification complete ==="