docs: update test strategy plan and README with Phase 5 completion status

- Document complete test suite implementation (Phase 1-5)
- Update test counts (992 tests) and coverage metrics (Branches 75.61%)
- Add k6 stress test verification results (91285 iterations, 0 errors)
- Add mutation score improvements (use-focus-trap 49.18%, use-swipe-gesture 33.06%)
- Update npm scripts documentation
This commit is contained in:
2026-07-31 20:25:51 +08:00
parent 41b73063cd
commit 553d7c0afb
2 changed files with 1335 additions and 8 deletions
+60 -8
View File
@@ -22,6 +22,7 @@
- 2026-07:完成安全加固(JWT、中间件、表单、CMS 接口)、可访问性修复
- 2026-07:完成全量测试基线建立(单元测试 705 条、E2E 618 条)与封版审查
- 2026-07:完成 CMS 数据模型扩展(locale、RBAC)、媒体管理、工作流引擎,并按页面类型全量迁移内容(基于 [docs/cms-evaluation.md](./docs/cms-evaluation.md)
- 2026-07:完成系统化测试套件实施(Phase 1-3 ✅,Phase 4 进行中)
## 项目进度
@@ -59,6 +60,12 @@
- [x] dogfood 剩余问题验证与视觉基线更新(2026-07-26):浏览器实测确认主导航「产品/解决方案」下拉菜单 click/hover 均可正常展开,问题已随 `(marketing)/loading.tsx` 移除解决;同步修正 `e2e/nav-dropdown.spec.ts` 中断言文本(`睿新ERP管理系统``ERP 管理系统``行业方案``行业解决方案`);更新 desktop/tablet/mobile/webkit/firefox 全量视觉回归基线(105 张快照);type-check / lint0 errors172 既有 warnings/ test:unit72 suites / 954 tests/ 下拉菜单 E2E 全部通过
- [x] 全量回归与 E2E 配置修复(2026-07-27):修复 `e2e/playwright.config.ts``storageState` 路径错误(由 `./e2e/storageState.json` 改为基于配置文件目录的绝对路径),该错误导致 firefox/webkit 全量 E2E 运行时无法读取 Cookie 偏好状态而全部失败;将 `e2e/p2-functional-e2e.spec.ts` 中「Footer 导航链接可点击」拆分为隐私政策、服务条款两个独立测试,并改用 `page.evaluate` 直接触发点击,避免 Firefox 中连续全页导航与 Playwright locator 评估的竞态超时;重新执行全量回归:type-check / lint0 errors172 既有 warnings/ test:unit72 suites / 954 tests/ E2E 全量(631 passed / 8 skipped / 0 failed,含视觉回归、CMS 工作流)全部通过
- [x] 联系表单 conversion 去重与首页 Hero 品牌标识补齐(2026-07-27):移除 `contact-content-v3.tsx` 中冗余的 `trackConversion('contact_form_submission')` 调用,改为 `trackContactForm(..., true)`,避免一次成功提交在 GA4 中被计为两次转化;同步更新 `contact-content-v3.test.tsx` 中断言;在 `home-content-v14.tsx` 首页 Hero 主标题上方增加 Logo + 公司中文名 + NOVALON 英文品牌标识,补齐截图中缺失的品牌信息;更新首页相关 desktop/tablet/mobile 视觉回归基线;type-check / lint0 errors172 既有 warnings/ 相关 unit 测试全部通过
- [x] 系统化测试套件实施(2026-07-31):Phase 1-5 全部完成 ✅
- [x] Phase 1E2E 分层测试框架(@smoke/@critical/@regression/@journey/@mobile/@analytics 标签体系)、Stryker 变异测试(utils.ts 91.18%)、Allure 报告集成
- [x] Phase 2:单元测试覆盖率达标(Branches 75.61%, Lines 50.82%, 72 suites / 992 tests),API Routes 集成测试(11 个文件)
- [x] Phase 3:用户旅程测试(UJ-01/UJ-02)、移动端专项 E2E 测试(16 个用例)、GA4 事件追踪测试(4 个用例)、k6 压力测试脚本修复与验证(91285 次迭代,0 错误)、安全扫描脚本(7 项安全响应头检查)
- [x] Phase 4Jenkinsfile 集成 E2E/视觉回归/安全扫描阶段、全量变异测试(整体 36.98%)、test:all 门禁脚本、安全头扫描脚本
- [x] Phase 5:k6 压力测试实际运行验证(14 分钟,300 并发峰值,91285 次迭代,0 错误率)、变异测试覆盖率提升(use-focus-trap 49.18%, use-swipe-gesture 33.06%, animations 16.59%)、全量测试通过(type-check ✅ / lint ✅ / 992 tests ✅)
## 技术栈
@@ -179,8 +186,19 @@ novalon-website/
| `npm run lint` | 运行 ESLint 检查 |
| `npm run type-check` | TypeScript 类型检查 |
| `npm run test` | 运行 E2E 测试 |
| `npm run test:unit` | 运行单元测试 |
| `npm run test:coverage` | 运行测试覆盖率 |
| `npm run test:unit` | 运行单元测试Jest72 suites / 992 tests |
| `npm run test:coverage` | 运行测试覆盖率(当前 Branches 75.61%, Lines 50.82% |
| `npm run test:e2e:fast` | 运行 E2E 快速测试(@smoke + @critical 标签) |
| `npm run test:e2e:standard` | 运行 E2E 标准回归测试(@regression 标签) |
| `npm run test:smoke` | 运行 E2E 冒烟测试(@smoke 标签) |
| `npm run test:critical` | 运行 E2E 关键路径测试(@critical 标签) |
| `npm run test:e2e:journey` | 运行用户旅程测试(@journey 标签,UJ-01/UJ-02 |
| `npm run test:e2e:mobile` | 运行移动端 E2E 测试(@mobile 标签) |
| `npm run test:mutation` | 运行变异测试(Stryker,评估测试质量,当前 36.98%) |
| `npm run test:mutation:quick` | 快速变异测试(仅 utils.ts91.18% |
| `npm run test:security` | 安全扫描(npm audit + 安全响应头检查) |
| `npm run test:security:headers` | 安全响应头检查(X-Content-Type-Options, CSP, HSTS 等) |
| `npm run test:all` | 全量门禁检查(type-check + lint + coverage + fast E2E + security headers |
| `npm run lighthouse` | 运行 Lighthouse 性能测试 |
## 代码质量门禁
@@ -211,19 +229,53 @@ novalon-website/
## 测试
项目使用 Playwright 进行 E2E 测试,Jest 进行单元测试
项目采用多层测试策略,涵盖单元测试、集成测试、E2E 测试、用户旅程测试、视觉回归测试、变异测试等
### 测试工具链
| 工具 | 用途 | 配置 |
|------|------|------|
| **Jest** | 单元测试(72 suites / 992 tests | `config/test/jest.config.js` |
| **Playwright** | E2E / 视觉回归 / 用户旅程测试 | `e2e/playwright.config.ts` |
| **Stryker** | 变异测试(评估测试质量) | `stryker.config.json` |
| **Allure** | 测试报告可视化 | Allure Playwright reporter |
| **k6** | 负载/压力/API 性能测试 | `tests/performance/` |
| **Lighthouse CI** | 性能/可访问性/SEO 审计 | `lighthouserc.js` |
### E2E 测试标签体系
| 标签 | 用途 | 执行命令 |
|------|------|----------|
| `@smoke` | 冒烟测试:核心功能 | `npm run test:smoke` |
| `@critical` | 关键路径:CMS 工作流等 | `npm run test:critical` |
| `@smoke` + `@critical` | 快速回归(<5min | `npm run test:e2e:fast` |
| `@regression` | 全量回归(<15min | `npm run test:e2e:standard` |
| `@journey` | 用户旅程(UJ-01/UJ-02 | `npm run test:e2e:journey` |
| `@mobile` | 移动端专项测试 | `npm run test:e2e:mobile` |
| `@visual` | 视觉回归(105 snapshots × 5 browsers | `npm run test:visual:all` |
### 运行测试
```bash
# E2E 测试
npm run test
# 单元测试
npm run test:unit
npm run test:unit # 954 tests
# 测试覆盖率
npm run test:coverage
npm run test:coverage # Branches 74.77%, Lines 50.78%
# E2E 测试
npm run test # 全量 E2E631 passed
npm run test:e2e:fast # 快速回归(@smoke + @critical
npm run test:e2e:standard # 标准回归(@regression
npm run test:e2e:journey # 用户旅程(@journey
npm run test:e2e:mobile # 移动端(@mobile
# 变异测试
npm run test:mutation # 全量变异测试
npm run test:mutation:quick # 快速变异(仅 utils.ts
# 全量门禁检查
npm run test:all # type-check + lint + coverage + fast E2E
```
## 部署