test/user-journey #3

Merged
zhangxiang merged 142 commits from test/user-journey into dev 2026-04-12 13:17:03 +08:00
2 changed files with 143 additions and 0 deletions
Showing only changes of commit 529bdd33c4 - Show all commits
@@ -0,0 +1,73 @@
# User Journey 覆盖矩阵
**最后更新:** 2026-04-09
## 覆盖率统计
- **总场景数:** 17
- **已覆盖:** 10
- **未覆盖:** 7
- **覆盖率:** 58.8%
---
## 访客旅程
| 场景 | 测试文件 | 状态 | 优先级 | 备注 |
|------|---------|------|-------|------|
| 首页浏览 | journeys/visitor-browse-journey.spec.ts | ✅ 已覆盖 | P0 | 完整覆盖 |
| 新闻浏览 | journeys/visitor-browse-journey.spec.ts | ✅ 已覆盖 | P1 | 完整覆盖 |
| 产品浏览 | journeys/visitor-browse-journey.spec.ts | ✅ 已覆盖 | P1 | 完整覆盖 |
| 联系表单填写 | journeys/visitor-browse-journey.spec.ts | ⚠️ 部分覆盖 | P0 | 仅填写,未验证提交 |
| 完整转化流程 | - | ❌ 未覆盖 | P0 | **需要新增** |
| 搜索引擎着陆 | - | ❌ 未覆盖 | P1 | **需要新增** |
## 移动端旅程
| 场景 | 测试文件 | 状态 | 优先级 | 备注 |
|------|---------|------|-------|------|
| 移动端导航 | - | ❌ 未覆盖 | P1 | **需要新增** |
| 移动端表单提交 | - | ❌ 未覆盖 | P1 | **需要新增** |
## 用户旅程
| 场景 | 测试文件 | 状态 | 优先级 | 备注 |
|------|---------|------|-------|------|
| 登录流程 | journeys/user-auth-journey.spec.ts | ✅ 已覆盖 | P0 | 完整覆盖 |
| 登出流程 | journeys/user-auth-journey.spec.ts | ✅ 已覆盖 | P1 | 完整覆盖 |
| 权限验证 | journeys/user-auth-journey.spec.ts | ✅ 已覆盖 | P1 | 完整覆盖 |
| 登录失败处理 | journeys/user-auth-journey.spec.ts | ✅ 已覆盖 | P1 | 完整覆盖 |
## 管理员旅程
| 场景 | 测试文件 | 状态 | 优先级 | 备注 |
|------|---------|------|-------|------|
| 内容创建 | journeys/admin-content-journey.spec.ts | ✅ 已覆盖 | P0 | 完整覆盖 |
| 内容编辑 | journeys/admin-content-journey.spec.ts | ✅ 已覆盖 | P1 | 完整覆盖 |
| 内容删除 | journeys/admin-content-journey.spec.ts | ✅ 已覆盖 | P1 | 完整覆盖 |
| 用户管理 | features/admin/user-management.spec.ts | ⚠️ Feature 测试 | P1 | 非 journey 测试 |
## SEO 验证
| 场景 | 测试文件 | 状态 | 优先级 | 备注 |
|------|---------|------|-------|------|
| Meta 标签验证 | - | ❌ 未覆盖 | P2 | **需要新增** |
| 结构化数据验证 | - | ❌ 未覆盖 | P2 | **需要新增** |
---
## 优先级说明
- **P0:** 核心业务场景,必须覆盖
- **P1:** 重要业务场景,应该覆盖
- **P2** 次要场景,建议覆盖
## 下一步行动
1. **P0 场景:** 新增访客转化旅程测试
2. **P1 场景:** 新增移动端旅程测试、搜索引擎着陆测试
3. **P2 场景:** 新增 SEO 验证测试
## 改进计划
详见:[User Journey 测试体系优化设计](../superpowers/specs/2026-04-09-user-journey-testing-optimization-design.md)
+70
View File
@@ -0,0 +1,70 @@
import * as fs from 'fs';
import * as path from 'path';
interface TestResult {
title: string;
status: 'passed' | 'failed' | 'skipped';
duration: number;
}
interface CoverageReport {
total: number;
passed: number;
failed: number;
skipped: number;
avgDuration: number;
passRate: number;
}
function analyzeTestCoverage(resultsPath: string): CoverageReport {
if (!fs.existsSync(resultsPath)) {
console.error(`错误: 找不到测试结果文件 ${resultsPath}`);
process.exit(1);
}
const content = fs.readFileSync(resultsPath, 'utf-8');
const results = JSON.parse(content);
const tests: TestResult[] = results.suites
.flatMap((suite: any) => suite.specs || [])
.map((spec: any) => ({
title: spec.title,
status: spec.ok ? 'passed' : 'failed',
duration: spec.duration || 0,
}));
const report: CoverageReport = {
total: tests.length,
passed: tests.filter(t => t.status === 'passed').length,
failed: tests.filter(t => t.status === 'failed').length,
skipped: tests.filter(t => t.status === 'skipped').length,
avgDuration: tests.length > 0 ? tests.reduce((sum, t) => sum + t.duration, 0) / tests.length : 0,
passRate: 0,
};
report.passRate = report.total > 0 ? (report.passed / report.total) * 100 : 0;
return report;
}
const resultsPath = process.argv[2] || 'reports/results.json';
const report = analyzeTestCoverage(resultsPath);
console.log('\n=== 测试覆盖率分析 ===');
console.log(`总测试数: ${report.total}`);
console.log(`通过: ${report.passed}`);
console.log(`失败: ${report.failed}`);
console.log(`跳过: ${report.skipped}`);
console.log(`通过率: ${report.passRate.toFixed(2)}%`);
console.log(`平均执行时间: ${(report.avgDuration / 1000).toFixed(2)}`);
if (!fs.existsSync('reports')) {
fs.mkdirSync('reports', { recursive: true });
}
fs.writeFileSync(
'reports/test-coverage-analysis.json',
JSON.stringify(report, null, 2)
);
console.log('\n✅ 分析结果已保存到 reports/test-coverage-analysis.json');