feat: add comprehensive testing mechanism for dashboard features
Deploy Dashboard (Dev) / deploy-dev (push) Failing after 2m0s
Run Tests / Backend Tests (push) Failing after 4m26s
Run Tests / Frontend Tests (push) Failing after 49s
Run Tests / Test Summary (push) Failing after 15s
Run Tests / Backend Tests (pull_request) Failing after 6m9s
Run Tests / Frontend Tests (pull_request) Failing after 3m54s
Run Tests / Test Summary (pull_request) Failing after 15s

- Add smoke test script for post-deployment verification
- Add health monitoring script with Telegram alerts
- Add backend integration tests for conversation tracker API
- Add frontend tests to verify correct API paths
- Update CI/CD workflows to enforce test failures and run smoke tests
- Add comprehensive testing documentation

This testing mechanism will catch issues like the double /api/ prefix bug
before they reach users.
This commit is contained in:
Gan, Jimmy
2026-04-19 21:54:13 +08:00
parent 9b8d7cfb00
commit 01fcb53a3a
8 changed files with 801 additions and 0 deletions
+79
View File
@@ -0,0 +1,79 @@
#!/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=$(ssh nas "/volume1/@appstore/ContainerManager/usr/bin/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=$(ssh nas "/volume1/@appstore/ContainerManager/usr/bin/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! ==="