Spaces:
Sleeping
Sleeping
File size: 3,904 Bytes
c696d3f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | #!/bin/bash
# E2E 测试重构验证脚本
# 用于验证重构是否成功完成
set -e
echo "======================================"
echo "🔍 E2E 测试重构验证"
echo "======================================"
echo
# 颜色输出
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
check_pass() {
echo -e "${GREEN}✓${NC} $1"
}
check_fail() {
echo -e "${RED}✗${NC} $1"
exit 1
}
check_warn() {
echo -e "${YELLOW}⚠${NC} $1"
}
# 1. 检查前端 E2E 目录
echo "1. 检查前端 E2E 目录..."
if [ -d "frontend/e2e" ]; then
check_pass "frontend/e2e/ 目录存在"
else
check_fail "frontend/e2e/ 目录不存在"
fi
# 2. 检查前端 E2E 测试文件
echo "2. 检查前端 E2E 测试文件..."
if [ -f "frontend/e2e/ui-full-flow.spec.ts" ]; then
check_pass "ui-full-flow.spec.ts 已移动到 frontend/e2e/"
else
check_fail "ui-full-flow.spec.ts 不在 frontend/e2e/"
fi
if [ -f "frontend/e2e/visual-regression.spec.ts" ]; then
check_pass "visual-regression.spec.ts 已移动到 frontend/e2e/"
else
check_fail "visual-regression.spec.ts 不在 frontend/e2e/"
fi
# 3. 检查 Playwright 配置
echo "3. 检查 Playwright 配置..."
if [ -f "frontend/playwright.config.ts" ]; then
check_pass "playwright.config.ts 已移动到 frontend/"
else
check_fail "playwright.config.ts 不在 frontend/"
fi
# 4. 检查前端 package.json
echo "4. 检查前端 package.json..."
if grep -q "@playwright/test" frontend/package.json; then
check_pass "frontend/package.json 包含 Playwright 依赖"
else
check_fail "frontend/package.json 缺少 Playwright 依赖"
fi
if grep -q "test:e2e" frontend/package.json; then
check_pass "frontend/package.json 包含 E2E 测试脚本"
else
check_fail "frontend/package.json 缺少 E2E 测试脚本"
fi
# 5. 检查后端集成测试
echo "5. 检查后端集成测试..."
if [ -f "backend/tests/integration/test_api_full_flow.py" ]; then
check_pass "test_api_full_flow.py 已创建在 backend/tests/integration/"
else
check_fail "test_api_full_flow.py 不在 backend/tests/integration/"
fi
# 6. 检查根目录清理
echo "6. 检查根目录清理..."
if [ ! -d "e2e" ]; then
check_pass "根目录 e2e/ 已删除"
else
check_warn "根目录 e2e/ 仍然存在(应该已删除)"
fi
if [ ! -f "playwright.config.ts" ]; then
check_pass "根目录 playwright.config.ts 已删除"
else
check_warn "根目录 playwright.config.ts 仍然存在(应该已删除)"
fi
if [ ! -f "tsconfig.json" ]; then
check_pass "根目录 tsconfig.json 已删除"
else
check_warn "根目录 tsconfig.json 仍然存在(应该已删除)"
fi
if [ ! -d "node_modules" ]; then
check_pass "根目录 node_modules/ 已删除"
else
check_warn "根目录 node_modules/ 仍然存在(应该已删除)"
fi
# 7. 检查 CI 配置
echo "7. 检查 CI 配置..."
if grep -q "cd frontend" .github/workflows/ci-test.yml; then
check_pass "CI 配置已更新(包含 'cd frontend')"
else
check_warn "CI 配置可能未更新"
fi
if grep -q "test_api_full_flow.py" .github/workflows/ci-test.yml; then
check_pass "CI 配置包含后端 API 测试"
else
check_warn "CI 配置可能缺少后端 API 测试"
fi
# 8. 检查 .gitignore
echo "8. 检查 .gitignore..."
if grep -q "test-results/" frontend/.gitignore; then
check_pass "frontend/.gitignore 已更新"
else
check_warn "frontend/.gitignore 可能需要更新"
fi
echo
echo "======================================"
echo "✅ E2E 测试重构验证完成!"
echo "======================================"
echo
echo "下一步:"
echo "1. cd frontend && npm install # 安装前端依赖(包括 Playwright)"
echo "2. cd frontend && npm run test:e2e # 运行前端 E2E 测试"
echo "3. cd backend && uv run pytest tests/integration/ -v # 运行后端集成测试"
echo
|