chore(test): add test infrastructure, CI config, and security scanning
- Add Jenkinsfile with E2E/visual regression/security scan stages - Add Stryker mutation testing configuration - Add security header scanning script (check-security-headers.ts) - Remove old playwright.config.ts (migrated to e2e/playwright.config.ts) - Remove obsolete .claude/skills/impeccable - Update jest config for test path patterns - Update package.json with comprehensive test scripts - Update .gitignore for stryker-tmp/ and .pi/ temp files
This commit is contained in:
Vendored
+80
@@ -162,6 +162,86 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
// ====== L3: E2E + 用户旅程测试 ======
|
||||
stage('🌐 E2E 测试') {
|
||||
when {
|
||||
branch 'main'
|
||||
beforeAgent true
|
||||
}
|
||||
steps {
|
||||
nodejs(nodeJSInstallationName: "${NODE_VERSION}") {
|
||||
sh '''
|
||||
echo "🔨 构建用于 E2E 测试..."
|
||||
npm run build
|
||||
echo "🚀 启动预览服务器..."
|
||||
npx serve dist -l 3000 &
|
||||
sleep 5
|
||||
echo "🧪 运行 E2E 快速测试(@smoke + @critical)..."
|
||||
cd e2e && npx playwright test --grep "@smoke|@critical" || echo "⚠️ E2E 测试部分失败,继续执行"
|
||||
echo "🧪 运行用户旅程测试..."
|
||||
npx playwright test --grep @journey || echo "⚠️ 用户旅程测试部分失败,继续执行"
|
||||
'''
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
sh 'kill $(lsof -t -i:3000) 2>/dev/null || true'
|
||||
publishHTML(target: [
|
||||
allowMissing: true,
|
||||
reportDir: 'e2e/playwright-report',
|
||||
reportFiles: 'index.html',
|
||||
reportName: 'E2E Test Report'
|
||||
])
|
||||
}
|
||||
failure {
|
||||
archiveArtifacts artifacts: 'e2e/test-results/**/*.png', allowEmptyArchive: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ====== L4: 视觉回归测试 ======
|
||||
stage('👁️ 视觉回归测试') {
|
||||
when {
|
||||
branch 'main'
|
||||
beforeAgent true
|
||||
}
|
||||
steps {
|
||||
nodejs(nodeJSInstallationName: "${NODE_VERSION}") {
|
||||
sh '''
|
||||
echo "🚀 启动预览服务器..."
|
||||
npx serve dist -l 3000 &
|
||||
sleep 5
|
||||
echo "🧪 运行视觉回归测试..."
|
||||
cd e2e && npx playwright test visual-regression.spec.ts --project=visual-chromium-desktop || echo "⚠️ 视觉回归测试失败,请检查基线是否需要更新"
|
||||
'''
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
sh 'kill $(lsof -t -i:3000) 2>/dev/null || true'
|
||||
archiveArtifacts artifacts: 'e2e/test-results/**/*.png', allowEmptyArchive: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ====== L5: 安全扫描 ======
|
||||
stage('🔒 安全扫描') {
|
||||
when {
|
||||
branch 'main'
|
||||
beforeAgent true
|
||||
}
|
||||
steps {
|
||||
nodejs(nodeJSInstallationName: "${NODE_VERSION}") {
|
||||
sh '''
|
||||
echo "🔒 运行依赖安全审计..."
|
||||
npm audit --audit-level=high || echo "⚠️ 存在高危依赖漏洞,请检查"
|
||||
echo "🔒 检查安全响应头..."
|
||||
npm run test:security:headers -- --url https://novalon.cn || echo "⚠️ 安全头检查未通过,请检查 Nginx 配置"
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('🏗️ 构建 dist') {
|
||||
steps {
|
||||
nodejs(nodeJSInstallationName: "${NODE_VERSION}") {
|
||||
|
||||
Reference in New Issue
Block a user