ui(test): enhance script output with visual formatting and colors
- Added color scheme (RED, GREEN, YELLOW, BLUE, PURPLE, CYAN, BOLD) - Added emojis throughout for visual clarity - Improved header formatting with decorative borders - Enhanced test results display with colored output - Added visual indicators for all status messages - Made summary section more user-friendly and visually rich - Script now outputs easy-to-understand visual summary
This commit is contained in:
parent
62e9f00663
commit
2bd38e152c
@ -4,6 +4,16 @@ set -e
|
|||||||
# Test runner script for E2E tests
|
# Test runner script for E2E tests
|
||||||
# Runs Playwright tests, builds reports, and checks health
|
# Runs Playwright tests, builds reports, and checks health
|
||||||
|
|
||||||
|
# Colors for visual output
|
||||||
|
RED='\033[0;31m'
|
||||||
|
GREEN='\033[0;32m'
|
||||||
|
YELLOW='\033[1;33m'
|
||||||
|
BLUE='\033[0;34m'
|
||||||
|
PURPLE='\033[0;35m'
|
||||||
|
CYAN='\033[0;36m'
|
||||||
|
BOLD='\033[1m'
|
||||||
|
NC='\033[0m' # No Color
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||||
WEB_DIR="$PROJECT_ROOT/web"
|
WEB_DIR="$PROJECT_ROOT/web"
|
||||||
@ -13,15 +23,17 @@ PORT=3050
|
|||||||
|
|
||||||
cd "$WEB_DIR"
|
cd "$WEB_DIR"
|
||||||
|
|
||||||
echo "========================================="
|
echo ""
|
||||||
echo "E2E Test Runner"
|
echo -e "${PURPLE}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||||
echo "========================================="
|
echo -e "${CYAN}${BOLD}🎭 E2E Test Runner${NC}"
|
||||||
echo "Project root: $PROJECT_ROOT"
|
echo -e "${PURPLE}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||||
echo "Web directory: $WEB_DIR"
|
echo -e "${BLUE}📁 Project root:${NC} ${BOLD}$PROJECT_ROOT${NC}"
|
||||||
echo "Reports directory: $REPORTS_DIR"
|
echo -e "${BLUE}🌐 Web directory:${NC} ${BOLD}$WEB_DIR${NC}"
|
||||||
echo "Timestamp: $TIMESTAMP"
|
echo -e "${BLUE}📊 Reports directory:${NC} ${BOLD}$REPORTS_DIR${NC}"
|
||||||
echo "Port: $PORT"
|
echo -e "${BLUE}⏰ Timestamp:${NC} ${BOLD}$TIMESTAMP${NC}"
|
||||||
echo "========================================="
|
echo -e "${BLUE}🔌 Port:${NC} ${BOLD}$PORT${NC}"
|
||||||
|
echo -e "${PURPLE}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||||
|
echo ""
|
||||||
|
|
||||||
# Create reports directory
|
# Create reports directory
|
||||||
mkdir -p "$REPORTS_DIR"
|
mkdir -p "$REPORTS_DIR"
|
||||||
@ -66,24 +78,25 @@ wait_for_server() {
|
|||||||
|
|
||||||
# Kill any existing server on port 3050
|
# Kill any existing server on port 3050
|
||||||
echo ""
|
echo ""
|
||||||
echo "Checking for existing server on port $PORT..."
|
echo -e "${YELLOW}🔍 Checking for existing server on port $PORT...${NC}"
|
||||||
kill_port $PORT
|
kill_port $PORT
|
||||||
|
echo -e "${GREEN}✓ Port $PORT is clear${NC}"
|
||||||
|
|
||||||
# Check if node_modules exists
|
# Check if node_modules exists
|
||||||
if [ ! -d "node_modules" ]; then
|
if [ ! -d "node_modules" ]; then
|
||||||
echo "Installing dependencies..."
|
echo -e "${YELLOW}📦 Installing dependencies...${NC}"
|
||||||
pnpm install
|
pnpm install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if Playwright is installed
|
# Check if Playwright is installed
|
||||||
if ! command -v npx playwright &> /dev/null; then
|
if ! command -v npx playwright &> /dev/null; then
|
||||||
echo "Playwright not found, installing browsers..."
|
echo -e "${YELLOW}🎭 Playwright not found, installing browsers...${NC}"
|
||||||
pnpm exec playwright install chromium
|
pnpm exec playwright install chromium
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Starting dev server..."
|
echo -e "${CYAN}${BOLD}🚀 Starting dev server...${NC}"
|
||||||
echo "========================================="
|
echo -e "${PURPLE}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||||
|
|
||||||
# Start dev server in background
|
# Start dev server in background
|
||||||
SERVER_PID=""
|
SERVER_PID=""
|
||||||
@ -93,19 +106,19 @@ SERVER_PID=$!
|
|||||||
# Save PID for cleanup
|
# Save PID for cleanup
|
||||||
echo $SERVER_PID > "$REPORTS_DIR/server-$TIMESTAMP.pid"
|
echo $SERVER_PID > "$REPORTS_DIR/server-$TIMESTAMP.pid"
|
||||||
|
|
||||||
echo "Server PID: $SERVER_PID"
|
echo -e "${BLUE}📌 Server PID:${NC} ${BOLD}$SERVER_PID${NC}"
|
||||||
echo "Server log: $REPORTS_DIR/server-$TIMESTAMP.log"
|
echo -e "${BLUE}📋 Server log:${NC} ${BOLD}$REPORTS_DIR/server-$TIMESTAMP.log${NC}"
|
||||||
|
|
||||||
# Wait for server to be ready
|
# Wait for server to be ready
|
||||||
if ! wait_for_server; then
|
if ! wait_for_server; then
|
||||||
echo "❌ Server failed to start. Check log: $REPORTS_DIR/server-$TIMESTAMP.log"
|
echo -e "${RED}❌ Server failed to start. Check log: $REPORTS_DIR/server-$TIMESTAMP.log${NC}"
|
||||||
kill_port $PORT
|
kill_port $PORT
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Running E2E tests..."
|
echo -e "${CYAN}${BOLD}🎭 Running E2E tests...${NC}"
|
||||||
echo "========================================="
|
echo -e "${PURPLE}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||||
|
|
||||||
# Run Playwright tests with JSON reporter for machine-readable output
|
# Run Playwright tests with JSON reporter for machine-readable output
|
||||||
START_TIME=$(date +%s)
|
START_TIME=$(date +%s)
|
||||||
@ -119,9 +132,9 @@ END_TIME=$(date +%s)
|
|||||||
DURATION=$((END_TIME - START_TIME))
|
DURATION=$((END_TIME - START_TIME))
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "========================================="
|
echo -e "${PURPLE}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||||
echo "Test Results"
|
echo -e "${CYAN}${BOLD}📊 Test Results${NC}"
|
||||||
echo "========================================="
|
echo -e "${PURPLE}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||||
|
|
||||||
# Parse JSON results if available
|
# Parse JSON results if available
|
||||||
if [ -f "$REPORTS_DIR/results-$TIMESTAMP.json" ]; then
|
if [ -f "$REPORTS_DIR/results-$TIMESTAMP.json" ]; then
|
||||||
@ -130,28 +143,30 @@ if [ -f "$REPORTS_DIR/results-$TIMESTAMP.json" ]; then
|
|||||||
PASSED_TESTS=$(cat "$REPORTS_DIR/results-$TIMESTAMP.json" | grep -o '"status":"passed"' | wc -l || echo "0")
|
PASSED_TESTS=$(cat "$REPORTS_DIR/results-$TIMESTAMP.json" | grep -o '"status":"passed"' | wc -l || echo "0")
|
||||||
FAILED_TESTS=$(cat "$REPORTS_DIR/results-$TIMESTAMP.json" | grep -o '"status":"failed"' | wc -l || echo "0")
|
FAILED_TESTS=$(cat "$REPORTS_DIR/results-$TIMESTAMP.json" | grep -o '"status":"failed"' | wc -l || echo "0")
|
||||||
|
|
||||||
echo "Total tests: $TOTAL_TESTS"
|
echo -e "${BLUE}📊 Total tests:${NC} ${BOLD}$TOTAL_TESTS${NC}"
|
||||||
echo "Passed: $PASSED_TESTS"
|
echo -e "${GREEN}✅ Passed:${NC} ${BOLD}$PASSED_TESTS${NC}"
|
||||||
echo "Failed: $FAILED_TESTS"
|
echo -e "${RED}❌ Failed:${NC} ${BOLD}$FAILED_TESTS${NC}"
|
||||||
echo "Duration: ${DURATION}s"
|
echo -e "${BLUE}⏱️ Duration:${NC} ${BOLD}${DURATION}s${NC}"
|
||||||
else
|
else
|
||||||
TOTAL_TESTS=0
|
TOTAL_TESTS=0
|
||||||
PASSED_TESTS=0
|
PASSED_TESTS=0
|
||||||
FAILED_TESTS=0
|
FAILED_TESTS=0
|
||||||
echo "Test count: 0 (tests did not run)"
|
echo -e "${YELLOW}⚠️ Test count: 0 (tests did not run)${NC}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $TEST_EXIT_CODE -eq 0 ]; then
|
if [ $TEST_EXIT_CODE -eq 0 ]; then
|
||||||
echo "✅ All tests passed"
|
echo ""
|
||||||
|
echo -e "${GREEN}${BOLD}✅ All tests passed${NC}"
|
||||||
STATUS="passed"
|
STATUS="passed"
|
||||||
else
|
else
|
||||||
echo "❌ Some tests failed"
|
echo ""
|
||||||
|
echo -e "${RED}${BOLD}❌ Some tests failed${NC}"
|
||||||
STATUS="failed"
|
STATUS="failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Report location: $REPORTS_DIR"
|
echo -e "${BLUE}📁 Report location:${NC} ${BOLD}$REPORTS_DIR${NC}"
|
||||||
echo "========================================="
|
echo -e "${PURPLE}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||||
|
|
||||||
# Update JSON report with results
|
# Update JSON report with results
|
||||||
cat > "$REPORT_JSON" << EOF
|
cat > "$REPORT_JSON" << EOF
|
||||||
@ -245,12 +260,12 @@ fi
|
|||||||
|
|
||||||
# Cleanup: Kill the server
|
# Cleanup: Kill the server
|
||||||
echo ""
|
echo ""
|
||||||
echo "Cleaning up..."
|
echo -e "${CYAN}${BOLD}🧹 Cleaning up...${NC}"
|
||||||
echo "========================================="
|
echo -e "${PURPLE}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||||
echo "Stopping server (PID: $SERVER_PID)..."
|
echo -e "${YELLOW}🛑 Stopping server (PID: $SERVER_PID)...${NC}"
|
||||||
kill $SERVER_PID 2>/dev/null || true
|
kill $SERVER_PID 2>/dev/null || true
|
||||||
kill_port $PORT
|
kill_port $PORT
|
||||||
echo "✅ Server stopped"
|
echo -e "${GREEN}✓ Server stopped${NC}"
|
||||||
|
|
||||||
# Update health check in JSON
|
# Update health check in JSON
|
||||||
cat > "$SUMMARY_JSON" << EOF
|
cat > "$SUMMARY_JSON" << EOF
|
||||||
@ -280,24 +295,24 @@ cat > "$SUMMARY_JSON" << EOF
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "========================================="
|
echo -e "${PURPLE}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||||
echo "Summary"
|
echo -e "${CYAN}${BOLD}📋 Summary${NC}"
|
||||||
echo "========================================="
|
echo -e "${PURPLE}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||||
echo "Tests run: Complete"
|
echo -e "${BLUE}✓ Tests run:${NC} ${BOLD}Complete${NC}"
|
||||||
echo "Status: $STATUS"
|
echo -e "${BLUE}📊 Status:${NC} ${BOLD}$STATUS${NC}"
|
||||||
echo "JSON Report: $REPORT_JSON"
|
echo -e "${BLUE}📄 JSON Report:${NC} ${BOLD}$REPORT_JSON${NC}"
|
||||||
echo "Markdown Report: $REPORT_MD"
|
echo -e "${BLUE}📝 Markdown Report:${NC} ${BOLD}$REPORT_MD${NC}"
|
||||||
echo "AI Summary: $SUMMARY_JSON"
|
echo -e "${BLUE}🤖 AI Summary:${NC} ${BOLD}$SUMMARY_JSON${NC}"
|
||||||
echo "HTML Report: $WEB_DIR/playwright-report/index.html"
|
echo -e "${BLUE}🌐 HTML Report:${NC} ${BOLD}$WEB_DIR/playwright-report/index.html${NC}"
|
||||||
echo "Health check: healthy"
|
echo -e "${BLUE}💚 Health check:${NC} ${BOLD}healthy${NC}"
|
||||||
echo "========================================="
|
echo -e "${PURPLE}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||||
|
echo -e "${GREEN}📁 Latest reports linked to:${NC} ${BOLD}$REPORTS_DIR/latest.{json,md,summary.json}${NC}"
|
||||||
|
echo -e "${PURPLE}${BOLD}═══════════════════════════════════════════════════════════════${NC}"
|
||||||
|
echo ""
|
||||||
|
|
||||||
# Create symlink to latest report
|
# Create symlink to latest report
|
||||||
ln -sf "$REPORT_JSON" "$REPORTS_DIR/latest.json"
|
ln -sf "$REPORT_JSON" "$REPORTS_DIR/latest.json"
|
||||||
ln -sf "$REPORT_MD" "$REPORTS_DIR/latest.md"
|
ln -sf "$REPORT_MD" "$REPORTS_DIR/latest.md"
|
||||||
ln -sf "$SUMMARY_JSON" "$REPORTS_DIR/latest-summary.json"
|
ln -sf "$SUMMARY_JSON" "$REPORTS_DIR/latest-summary.json"
|
||||||
|
|
||||||
echo "Latest reports linked to: $REPORTS_DIR/latest.{json,md,summary.json}"
|
|
||||||
echo "========================================="
|
|
||||||
|
|
||||||
exit $TEST_EXIT_CODE
|
exit $TEST_EXIT_CODE
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user