#!/bin/bash echo "🧪 测试 WorkTime 应用部署..." # 测试服务器健康状态 echo "1. 测试服务器健康状态..." HEALTH_RESPONSE=$(curl -s http://localhost:3001/api/health) if [[ $HEALTH_RESPONSE == *"ok"* ]]; then echo "✅ 服务器健康状态正常" else echo "❌ 服务器健康状态异常: $HEALTH_RESPONSE" exit 1 fi # 测试数据API echo "2. 测试数据API..." DATA_RESPONSE=$(curl -s http://localhost:3001/api/data) if [[ $DATA_RESPONSE == *"tasks"* ]] && [[ $DATA_RESPONSE == *"projects"* ]]; then echo "✅ 数据API正常" else echo "❌ 数据API异常: $DATA_RESPONSE" exit 1 fi # 测试前端页面 echo "3. 测试前端页面..." FRONTEND_RESPONSE=$(curl -s http://localhost:3001 | head -1) if [[ $FRONTEND_RESPONSE == *""* ]]; then echo "✅ 前端页面正常" else echo "❌ 前端页面异常" exit 1 fi # 测试静态资源 echo "4. 测试静态资源..." STATIC_RESPONSE=$(curl -s -I http://localhost:3001/assets/ | head -1) if [[ $STATIC_RESPONSE == *"200"* ]] || [[ $STATIC_RESPONSE == *"404"* ]]; then echo "✅ 静态资源服务正常" else echo "❌ 静态资源服务异常: $STATIC_RESPONSE" exit 1 fi echo "" echo "🎉 所有测试通过!应用部署成功!" echo "📱 应用地址: http://localhost:3001" echo "🔧 API文档: http://localhost:3001/api/health"