#!/bin/bash echo "๐ŸŒ Testing Caddy-RS Web Interface" echo "==================================" # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' SERVER_PORT=8080 WEB_URL="http://localhost:$SERVER_PORT" echo -e "\n${YELLOW}๐Ÿ”จ Building project...${NC}" cargo build --release if [ $? -ne 0 ]; then echo -e "${RED}โŒ Build failed${NC}" exit 1 fi echo -e "\n${BLUE}๐Ÿš€ Starting server with web UI...${NC}" echo "Server URL: $WEB_URL" cargo run --bin caddy-rs --release -- -c example-sync-config.json & SERVER_PID=$! echo "Server PID: $SERVER_PID" # Wait for server to start echo "Waiting for server to start..." sleep 3 echo -e "\n${YELLOW}๐Ÿงช Testing web interface endpoints...${NC}" # Test 1: Web UI homepage echo "Test 1: GET / (Web UI)" HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" $WEB_URL/) if [ "$HTTP_STATUS" = "200" ]; then echo -e "${GREEN}โœ… Web UI homepage accessible${NC}" else echo -e "${RED}โŒ Web UI homepage failed (HTTP $HTTP_STATUS)${NC}" fi # Test 2: CSS file echo -e "\nTest 2: GET /styles.css" HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" $WEB_URL/styles.css) if [ "$HTTP_STATUS" = "200" ]; then echo -e "${GREEN}โœ… CSS file accessible${NC}" else echo -e "${RED}โŒ CSS file failed (HTTP $HTTP_STATUS)${NC}" fi # Test 3: JavaScript file echo -e "\nTest 3: GET /app.js" HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" $WEB_URL/app.js) if [ "$HTTP_STATUS" = "200" ]; then echo -e "${GREEN}โœ… JavaScript file accessible${NC}" else echo -e "${RED}โŒ JavaScript file failed (HTTP $HTTP_STATUS)${NC}" fi # Test 4: API endpoints still work echo -e "\nTest 4: GET /api/list (API)" HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" $WEB_URL/api/list) if [ "$HTTP_STATUS" = "200" ]; then echo -e "${GREEN}โœ… API endpoints still working${NC}" else echo -e "${RED}โŒ API endpoints broken (HTTP $HTTP_STATUS)${NC}" fi echo -e "\n${GREEN}๐ŸŽ‰ Web interface testing complete!${NC}" echo -e "\n${BLUE}๐ŸŒ Open in your browser:${NC}" echo "$WEB_URL" echo -e "\n${YELLOW}๐Ÿ“‹ Web Interface Features:${NC}" echo "โœ“ File listing with icons and metadata" echo "โœ“ Drag & drop file upload" echo "โœ“ File download functionality" echo "โœ“ Real-time WebSocket updates" echo "โœ“ Responsive mobile-friendly design" echo "โœ“ Dark mode support" echo "โœ“ Context menus for file operations" echo -e "\n${YELLOW}๐Ÿ”ง To test manually:${NC}" echo "1. Open $WEB_URL in your browser" echo "2. Try uploading files via drag & drop" echo "3. Enable real-time updates" echo "4. Right-click files for context menu" echo "5. Test on mobile/tablet for responsive design" echo -e "\n${YELLOW}โน๏ธ Press Ctrl+C to stop the server${NC}" echo "Server PID: $SERVER_PID" # Keep script running until user interrupts trap "echo -e '\n${YELLOW}๐Ÿงน Stopping server...${NC}'; kill $SERVER_PID 2>/dev/null; exit 0" INT while true; do sleep 1 done