#!/bin/bash # Smoke test for dashboard deployment # Usage: ./smoke-test-dashboard.sh [dev|prod] set -e ENV=${1:-dev} if [ "$ENV" = "dev" ]; then BASE_URL="http://nas.jimmygan.com:4001" CONTAINER="nas-dashboard-dev" else BASE_URL="http://nas.jimmygan.com:4000" CONTAINER="nas-dashboard" fi echo "=== Dashboard Smoke Test ($ENV) ===" echo "Base URL: $BASE_URL" echo "" # Test 1: Health check echo "1. Testing health endpoint..." HEALTH=$(curl -s "$BASE_URL/api/health" --max-time 5) if echo "$HEALTH" | grep -q '"status":"ok"'; then echo "✅ Health check passed" else echo "❌ Health check failed: $HEALTH" exit 1 fi # Test 2: Frontend loads echo "2. Testing frontend loads..." FRONTEND=$(curl -s "$BASE_URL/" --max-time 5 | grep -c "NAS Dashboard" || echo "0") if [ "$FRONTEND" -gt 0 ]; then echo "✅ Frontend loads" else echo "❌ Frontend failed to load" exit 1 fi # Test 3: API endpoints respond (should require auth) echo "3. Testing API endpoints require auth..." DATES=$(curl -s "$BASE_URL/api/conversations/dates" --max-time 5) if echo "$DATES" | grep -q "Not authenticated"; then echo "✅ Conversation tracker API requires auth" else echo "❌ Unexpected response: $DATES" exit 1 fi # Test 4: Check for double /api/ prefix bug echo "4. Testing for double /api/ prefix bug..." DOUBLE_API=$(curl -s -o /dev/null -w "%{http_code}" "$BASE_URL/api/api/conversations/dates" --max-time 5) if [ "$DOUBLE_API" = "404" ]; then echo "✅ No double /api/ prefix bug" else echo "⚠️ Warning: /api/api/ path returned $DOUBLE_API (should be 404)" fi # Test 5: Container health echo "5. Checking container health..." HEALTH_STATUS=$(docker inspect --format='{{.State.Health.Status}}' $CONTAINER 2>/dev/null || echo "unknown") if [ "$HEALTH_STATUS" = "healthy" ]; then echo "✅ Container is healthy" else echo "❌ Container health: $HEALTH_STATUS" exit 1 fi # Test 6: Check recent logs for errors echo "6. Checking for recent errors in logs..." ERROR_COUNT=$(docker logs $CONTAINER --tail 50 2>&1 | grep -c 'ERROR' || echo 0) if [ "$ERROR_COUNT" -lt 5 ]; then echo "✅ No critical errors in recent logs ($ERROR_COUNT errors)" else echo "⚠️ Warning: Found $ERROR_COUNT errors in recent logs" fi echo "" echo "=== All smoke tests passed! ==="