#!/bin/bash

echo "🎯 TEST COMPLET DES SERVICES VEZA"
echo "=================================="
echo ""

# Test Backend API
echo "1. Backend API (port 8080):"
if curl -s http://localhost:8080/api/health > /dev/null; then
    echo "   ✅ Fonctionnel - http://localhost:8080"
else
    echo "   ❌ Non accessible"
fi
echo ""

# Test Frontend React
echo "2. Frontend React (port 5175):"
if curl -s http://localhost:5175 > /dev/null; then
    echo "   ✅ Accessible - http://localhost:5175"
else
    echo "   ❌ Non accessible"
fi
echo ""

# Test Frontend Desktop
echo "3. Frontend Desktop (port 5174):"
if curl -s http://localhost:5174 > /dev/null; then
    echo "   ✅ Accessible - http://localhost:5174"
else
    echo "   ❌ Non accessible"
fi
echo ""

# Test Stream Server
echo "4. Stream Server (port 8082):"
if curl -s http://localhost:8082 > /dev/null; then
    echo "   ✅ Accessible - http://localhost:8082"
else
    echo "   ❌ Non accessible"
fi
echo ""

# Test Grafana
echo "5. Grafana (port 3000):"
if curl -s http://localhost:3000 > /dev/null; then
    echo "   ✅ Accessible - http://localhost:3000"
else
    echo "   ❌ Non accessible"
fi
echo ""

# Test PostgreSQL
echo "6. PostgreSQL (port 5432):"
if docker exec veza-postgres-local pg_isready -U veza_user > /dev/null 2>&1; then
    echo "   ✅ Fonctionnel - localhost:5432"
else
    echo "   ❌ Non accessible"
fi
echo ""

# Test Redis
echo "7. Redis (port 6379):"
if docker exec veza-redis-local redis-cli ping > /dev/null 2>&1; then
    echo "   ✅ Fonctionnel - localhost:6379"
else
    echo "   ❌ Non accessible"
fi
echo ""

# Vérification des processus
echo "8. Processus en cours:"
echo "   Backend API: $(ps aux | grep -c './server' | grep -v grep || echo '0')"
echo "   Frontend React: $(ps aux | grep -c 'vite' | grep -v grep || echo '0')"
echo "   Stream Server: $(ps aux | grep -c 'stream_server' | grep -v grep || echo '0')"
echo ""

echo "🎉 RÉSUMÉ:"
echo "   • Backend API: http://localhost:8080"
echo "   • Frontend Web: http://localhost:5175"
echo "   • Frontend Desktop: http://localhost:5174"
echo "   • Stream Server: http://localhost:8082"
echo "   • Grafana: http://localhost:3000"
echo "   • PostgreSQL: localhost:5432"
echo "   • Redis: localhost:6379"
echo ""
echo "💡 Pour tester l'application:"
echo "   1. Ouvrez http://localhost:5175 dans votre navigateur"
echo "   2. Testez les fonctionnalités de l'interface"
echo "   3. Vérifiez les appels API via http://localhost:8080/api/health" 