# HMS V1 测试版本端到端测试报告 > 日期: 2026-05-17 | 测试环境: Windows 11 本地开发 | 分支: feat/media-library-banner > 测试执行者: Claude Code (自动化 E2E 测试 + 5 专业代理并行) --- ## 1. 测试概况 | 指标 | 值 | |------|-----| | 测试执行时间 | ~15 分钟(5 代理并行) | | 测试覆盖范围 | 后端 API + Web 前端 + 微信小程序 + 安全 + 跨平台一致性 | | 后端 API 端点测试 | **48 个端点**,40 PASS / 8 FAIL(路径修正后全部可达) | | Web 前端路由测试 | **25 个活跃路由**,100% 通过 | | 小程序页面覆盖 | **66 页面**(12 主包 + 54 子包),全部代码审查通过 | | 小程序 API 验证 | **19 个核心端点**,全部通过 | | 安全测试项 | **18 项**,15 PASS / 3 FAIL | | 跨平台一致性 | **20+ 实体 × 3 端**对比,发现 3 CRITICAL + 3 HIGH | | 多角色测试 | **5 角色**(admin/doctor/nurse/operator/viewer) | --- ## 2. 后端 API 测试结果 ### 2.1 端点可用性(修正路径后) #### 健康模块(36/40 PASS) | 端点 | 状态码 | 结果 | |------|--------|------| | GET /health/patients | 200 | PASS | | POST /health/patients | 200 | PASS | | GET /health/patients/{id} | 200 | PASS | | PUT /health/patients/{id} | 200 | PASS | | DELETE /health/patients/{id} | 200 | PASS(需 version 字段) | | GET /health/doctors | 200 | PASS | | GET /health/appointments | 200 | PASS | | GET /health/doctor-schedules | 200 | PASS | | GET /health/consultation-sessions | 200 | PASS | | GET /health/media | 200 | PASS | | GET /health/banners | 200 | PASS | | GET /health/alerts | 200 | PASS | | GET /health/follow-up-tasks | 200 | PASS | | GET /health/follow-up-templates | 200 | PASS | | GET /health/articles | 200 | PASS | | GET /health/patient-tags | 200 | PASS | | GET /health/article-categories | 200 | PASS | | GET /health/article-tags | 200 | PASS | | GET /health/care-plans | 200 | PASS | | GET /health/devices | 200 | PASS | | GET /health/ble-gateways | 200 | PASS | | GET /health/vital-signs/today | 200 | PASS | | GET /health/alert-rules | 200 | PASS | | GET /health/action-inbox/stats | 200 | PASS | | GET /health/action-inbox/my-patients | 200 | PASS | | GET /health/shifts | 200 | PASS | | GET /health/admin/system-health | 200 | PASS | | GET /health/admin/statistics/dashboard | 200 | PASS | | GET /health/admin/statistics/patients | 200 | PASS | | GET /health/admin/modules | 200 | PASS | | GET /health/points/account | 200 | PASS | | GET /health/points/products | 200 | PASS | | GET /health/points/orders | 200 | PASS | | GET /health/points/transactions | 200 | PASS | | GET /health/offline-events | 200 | PASS | | GET /health/handoff-logs | 200 | PASS | | GET /health/critical-alerts | 200 | PASS | | GET /health/vital-signs/daily | 400 | FAIL(需 date 参数,但传了仍 400) | | GET /health/medications | 405 | FAIL(GET 不支持,仅 POST) | | GET /health/medication-reminders | 405 | FAIL(GET 不支持) | #### 其他模块(12/12 PASS) | 端点 | 状态码 | 结果 | |------|--------|------| | GET /workflow/definitions | 200 | PASS | | GET /workflow/tasks/pending | 200 | PASS | | GET /workflow/tasks/completed | 200 | PASS | | GET /ai/analysis/history | 200 | PASS | | GET /ai/prompts | 200 | PASS | | GET /ai/providers | 200 | PASS | | GET /ai/suggestions | 200 | PASS | | GET /config/menus | 200 | PASS | | GET /config/dictionaries | 200 | PASS | | GET /config/themes | 200 | PASS | | GET /messages | 200 | PASS | | GET /messages/unread-count | 200 | PASS | | GET /audit-logs | 200 | PASS | ### 2.2 CRUD 全链路测试 | 步骤 | 操作 | 结果 | |------|------|------| | CREATE | POST 创建患者 | PASS — 返回 id + version=1 | | READ | GET 单条查询 | PASS — name/version 正确 | | UPDATE | PUT 更新患者 | PASS — version 自增为 2 | | OPTLOCK | PUT version=1 冲突 | PASS — 返回"版本冲突"错误 | | DELETE | DELETE + version=1 | PASS — 软删除成功 | | LIST SEARCH | 搜索已删除记录 | PASS — 列表不显示 | | GET BY ID | 查询已删除记录 | PASS — 返回错误 | ### 2.3 性能基线 | 端点 | 平均响应时间 | 评价 | |------|-------------|------| | GET /health/patients (10次) | **280ms** | 良好 | | GET /health/doctors (10次) | **278ms** | 良好 | | GET /admin/statistics/dashboard (10次) | **291ms** | 良好 | --- ## 3. Web 前端测试结果 > 由 Chrome DevTools MCP 代理实际浏览器测试 | 指标 | 结果 | |------|------| | 活跃路由 | 25 个,全部可访问 | | 登录流程 | PASS — admin 登录成功跳转仪表盘 | | 页面加载 | PASS — 所有页面正常渲染 | | Console 错误 | 无 CRITICAL 错误 | | 发现问题 | 4 个 LOW 级别 UI/UX 问题 | ### 3.1 关键页面测试 | 页面 | 功能 | 状态 | |------|------|------| | 登录页 | 表单验证 + JWT 认证 | PASS | | 仪表盘 | 统计卡片 + 数据加载 | PASS | | 患者管理 | 列表 + 搜索 + 新建 | PASS | | 医生管理 | 列表 + 详情 | PASS | | 预约管理 | 列表 + 新建预约 | PASS | | 咨询管理 | 会话列表 + 消息 | PASS | | 媒体库 | 文件上传 + 预览 | PASS | | 轮播图管理 | CRUD 操作 | PASS | | 权限管理 | 角色列表 + 权限分配 | PASS | | 用户管理 | 列表 + 编辑 | PASS | --- ## 4. 小程序端测试结果 > 综合评分: **8.5/10 (A-)** ### 4.1 页面覆盖 | 包 | 页数 | 状态 | |----|------|------| | 主包(6 TabBar + 6 普通) | 12 | PASS | | pkg-health | 5 | PASS | | pkg-doctor-core | 8 | PASS | | pkg-doctor-clinical | 11 | PASS | | pkg-mall | 3 | PASS | | pkg-profile | 19 | PASS | | ai-report | 2 | PASS | | article | 2 | PASS | | pkg-consultation | 1 | PASS | | **合计** | **66** | **100%** | ### 4.2 API 契约一致性 19 个核心 API 端点全部验证通过: - 路径一致: 100% - 方法一致: 100% - 请求/响应字段: 一致(核心端点) - 认证方式: 一致(JWT Bearer token) ### 4.3 安全检查 | 检查项 | 结果 | |--------|------| | Token 不硬编码 | PASS | | 401 自动处理 | PASS | | 并发限制 (MAX=8) | PASS | | 登出清理 | PASS | | 输入验证 | PASS | | 多租户隔离 | PASS | ### 4.4 性能优化 | 策略 | 实现 | |------|------| | 响应缓存 | 60s TTL + 去重 + 最大 100 条 | | 请求去重 | 相同 GET 合并为一次 | | 加载节流 | usePageData 5-30s | | 图片懒加载 | Image lazyLoad | | 安全定时器 | useSafeTimeout 页面隐藏清理 | --- ## 5. 跨平台一致性测试结果 ### 5.1 CRITICAL 问题(3 个) | ID | 严重性 | 描述 | 位置 | |----|--------|------|------| | CP-1 | **CRITICAL** | 药物提醒字段名不匹配:Web 用 `time_slots`,后端期望 `reminder_times` | `apps/web/src/api/health/medicationReminders.ts` vs `crates/erp-health/src/dto/medication_reminder_dto.rs` | | CP-2 | **CRITICAL** | 化验报告字段名不匹配:前端用 `indicators`/`doctor_interpretation`,后端用 `items`/`doctor_notes` | `apps/web/src/api/health/healthData.ts` + `apps/miniprogram/src/services/report.ts` vs 后端 DTO | | CP-3 | **CRITICAL** | 健康记录字段名不匹配:Web 用 `content`/`attachment_urls`,后端用 `overall_assessment`/`report_file_url` | `apps/web/src/api/health/healthData.ts` vs 后端 DTO | **影响**: 这 3 个问题会导致运行时数据丢失或字段写入失败。 ### 5.2 HIGH 问题(3 个) | ID | 严重性 | 描述 | |----|--------|------| | CP-4 | HIGH | 小程序患者 DTO 缺少 9 个后端字段(allergy_history 等) | | CP-5 | HIGH | 小程序随访任务 DTO 缺少 assigned_to 等字段 | | CP-6 | HIGH | 小程序告警 DTO 缺少 patient_id/rule_id/version 等 | ### 5.3 正面发现 - 三端 API 路径命名 **100% 一致** - HTTP 方法 **100% 一致** - 分页参数 (page/page_size) **一致** - 认证方式(JWT Bearer token)**一致** --- ## 6. 安全测试结果 ### 6.1 认证与授权 | 测试 | 结果 | 说明 | |------|------|------| | 无 Token 访问 | PASS | 返回 401 | | 无效 Token | PASS | 返回 401 | | 错误密码 | PASS | 返回 401 + "未授权" | | 速率限制 | PASS | 5 次错误后触发 429 | | Token 刷新 | PASS | 401 自动 refresh | ### 6.2 注入攻击防护 | 测试 | 结果 | 说明 | |------|------|------| | SQL 注入(搜索字段) | PASS | `OR '1'='1` 返回 0 条,参数化查询生效 | | SQL 注入(排序字段) | PASS | 无效排序不报错 | | XSS(存储型) | PASS | `