fix: 改进成功消息等待策略,修复测试失败问题

- 添加waitForSuccessMessage()方法到UserManagementPage和RoleManagementPage
- 改进submitForm()方法,添加等待时间
- 更新测试用例使用新的等待方法
- 增加错误消息检测和日志输出
- 修复权限选择器问题(使用.el-tree替代固定value)
This commit is contained in:
张翔
2026-04-04 10:03:19 +08:00
parent 0e367a8873
commit f882599072
35 changed files with 874 additions and 95 deletions
+91 -18
View File
@@ -2,26 +2,74 @@
# TDD工作流规范 - 质量门禁配置
pipeline:
# 后端测试阶段
# 后端单元测试和集成测试
test-backend:
image: maven:3.9-openjdk-21
commands:
- echo "开始后端测试..."
- echo "🚀 开始后端测试..."
- cd novalon-manage-api
- mvn clean test jacoco:report
- echo "后端测试完成,生成覆盖率报告"
- echo "后端测试完成,生成覆盖率报告"
when:
event: [push, pull_request]
# 前端测试阶段
test-frontend:
# 构建后端JAR文件(用于E2E测试)
build-backend-jar:
image: maven:3.9-openjdk-21
commands:
- echo "📦 构建后端JAR文件..."
- cd novalon-manage-api/manage-app
- mvn clean package -DskipTests
- echo "✅ JAR文件构建完成: target/manage-app-1.0.0.jar"
when:
event: [push, pull_request]
# 前端单元测试
test-frontend-unit:
image: node:18
commands:
- echo "开始前端测试..."
- echo "🚀 开始前端单元测试..."
- cd novalon-manage-web
- npm install
- npm ci
- npm run test:unit
- npm run test:e2e
- echo "前端测试完成"
- echo "✅ 前端单元测试完成"
when:
event: [push, pull_request]
# 前端E2E测试
test-frontend-e2e:
image: mcr.microsoft.com/playwright:v1.40.0-jammy
environment:
- DISPLAY=:99
commands:
- echo "🚀 开始前端E2E测试..."
- cd novalon-manage-web
- npm ci
- npx playwright install --with-deps chromium
- echo "📦 启动后端服务..."
- cd ../novalon-manage-api/manage-app
- java -jar target/manage-app-1.0.0.jar --spring.profiles.active=test &
- BACKEND_PID=$!
- cd ../../novalon-manage-web
- echo "⏳ 等待后端服务就绪..."
- |
for i in {1..60}; do
if curl -f http://localhost:8084/actuator/health > /dev/null 2>&1; then
echo "✅ 后端服务就绪"
break
fi
sleep 1
done
- echo "🎭 运行Playwright测试..."
- npx playwright test --project=chromium
- echo "🛑 停止后端服务..."
- kill $BACKEND_PID || true
- echo "✅ E2E测试完成"
when:
event: [push, pull_request]
@@ -29,7 +77,8 @@ pipeline:
quality-gates:
image: maven:3.9-openjdk-21
commands:
- echo "开始质量门禁检查..."
- echo "🔍 开始质量门禁检查..."
- cd novalon-manage-api
- mvn jacoco:check
- echo "✅ 测试覆盖率检查通过"
- echo "✅ 所有测试用例通过"
@@ -41,7 +90,8 @@ pipeline:
build:
image: maven:3.9-openjdk-21
commands:
- echo "开始构建..."
- echo "📦 开始构建..."
- cd novalon-manage-api
- mvn clean package -DskipTests
- echo "✅ 构建成功"
when:
@@ -52,17 +102,30 @@ pipeline:
security-scan:
image: aquasec/trivy:latest
commands:
- echo "开始安全漏洞扫描..."
- echo "🔒 开始安全漏洞扫描..."
- trivy filesystem --severity HIGH,CRITICAL --exit-code 1 .
- echo "✅ 安全扫描通过"
when:
event: [pull_request]
# 发布测试报告
publish-test-reports:
image: alpine:latest
commands:
- echo "📊 发布测试报告..."
- mkdir -p reports
- cp -r novalon-manage-api/target/site/jacoco reports/backend-coverage || true
- cp -r novalon-manage-web/playwright-report reports/e2e-report || true
- echo "✅ 测试报告已发布到 reports/"
when:
event: [push, pull_request]
status: [success, failure]
# 部署到测试环境
deploy-staging:
image: alpine/k8s:1.29
commands:
- echo "部署到测试环境..."
- echo "🚀 部署到测试环境..."
- kubectl apply -f k8s/staging/
- echo "✅ 测试环境部署完成"
when:
@@ -73,7 +136,7 @@ pipeline:
deploy-production:
image: alpine/k8s:1.29
commands:
- echo "部署到生产环境..."
- echo "🚀 部署到生产环境..."
- kubectl apply -f k8s/production/
- echo "✅ 生产环境部署完成"
when:
@@ -89,7 +152,10 @@ workflows:
branch: [develop]
steps:
- test-backend
- test-frontend
- build-backend-jar
- test-frontend-unit
- test-frontend-e2e
- publish-test-reports
- build
- deploy-staging
@@ -100,7 +166,10 @@ workflows:
branch: [main]
steps:
- test-backend
- test-frontend
- build-backend-jar
- test-frontend-unit
- test-frontend-e2e
- publish-test-reports
- security-scan
- build
- deploy-production
@@ -111,7 +180,10 @@ workflows:
event: [pull_request]
steps:
- test-backend
- test-frontend
- build-backend-jar
- test-frontend-unit
- test-frontend-e2e
- publish-test-reports
- quality-gates
- security-scan
@@ -128,9 +200,10 @@ notifications:
environment:
- JAVA_HOME=/usr/lib/jvm/java-21-openjdk
- NODE_ENV=test
- SPRING_PROFILES_ACTIVE=test
# 缓存配置
cache:
paths:
- ~/.m2/repository
- novalon-manage-web/node_modules
- novalon-manage-web/node_modules