facc04aa65
本提交为 .git 对象库损坏后的重建提交,内容等价于原先三个本地提交 (5e2fd4c2 / 57a53c98 / 5d7e1873)的累积结果,未做任何额外改动。 一、docs 结构整改(整改 #14) 根因:重构时新结构为 untracked 文件,执行 git stash(未带 -u)未纳入, 随后 git reset 拉回 HEAD 旧 tracked 树,导致旧树复活、新旧两棵目录 树并存于 docs/,共 791 文件、双分类体系冲突。 修复动作: - b2 同名异主题文件改名迁移保全 9 个 - C 类 39 个孤立文件按主题正确归类 - A/B1 类 222 个重复文件删除(新结构已有内容副本) - 9 个旧独有空目录删除 - 270 处内部引用按 verified 映射改写 - 整改记录 #14 登记于 04-运维文档/部署运维 结果:docs 791 → 569 文件,顶层仅规范 8 类 + 治理文件,单树恢复。 残留:约 20 处指向从未存在文件的陈旧死链,归入独立文档卫生任务。 二、compose 双目录对齐(消除踩坑 A) - docker-compose.yml:nginx 前端挂载全部由根目录 frontend-*/dist 改为 src/frontend-*/dist(h5 / agent / admin / terminal) - docker-compose.dev.yml:dev 服务 build context 与卷同步改 src/ - 效果:本地 docker compose up 不再把根目录 stale dist 挂回, 与线上一致,分叉隐患消除(已 docker compose config 校验通过) 防复发铁律: - 重构须提交;仓库修复须 git stash -u 或先 commit - 新结构须 git add 并提交,避免再次 untracked 复活 - H5 改动只动 src/frontend-h5/,禁改根目录遗留 frontend-*/
217 lines
9.1 KiB
Markdown
217 lines
9.1 KiB
Markdown
# 自动化测试套件全景(src/backend/tests/)
|
||
|
||
> **版本**: v1.0 | **生效日期**: 2026-08-05 | **维护人**: Duckula
|
||
> 自动生成工具:`scripts/test_inventory.py`
|
||
> (手动重跑:`cd src/backend && python ../../scripts/test_inventory.py --baseline 1311/88/4`)
|
||
|
||
本索引按 pytest 测试文件列出后端测试套件全貌,**与 `docs/03-测试文档/04-版本测试报告/` 互补**:
|
||
- 文档报告(TC/TR/BUG):按需求/版本/缺陷分类
|
||
- 本文档(测试套件全景):按 pytest 文件 + 主题分类
|
||
|
||
---
|
||
|
||
## 📊 总览数据
|
||
|
||
- **测试文件总数**: 78(含子目录)
|
||
- **测试用例总数**: 1403
|
||
- **预存在 collection 错误**: 3 个文件(已忽略,不计入用例)
|
||
- **最近一次 baseline**: 1311 passed / 88 failed / 4 xfailed (≈ 93.4%)
|
||
- **关联规范**: [`测试方法论指南.md`](./测试方法论指南.md)(Tier 0 / Tier 1 / Tier 2 / E2E 四层)
|
||
|
||
---
|
||
|
||
## 📁 按主题分类(pytest 文件 → 主题)
|
||
|
||
### 🔐 鉴权 / 认证 / RBAC(13 文件 / 212 用例)
|
||
|
||
| 测试文件 | 用例数 | 说明 |
|
||
|----------|--------|------|
|
||
| `tests/test_h5_oauth.py` | 41 | H5 OAuth |
|
||
| `tests/test_high_risk_guard.py` | 28 | 高危操作 OTP 守卫 |
|
||
| `tests/test_admin_user.py` | 22 | 后台管理员账号 |
|
||
| `tests/test_mfa.py` | 21 | MFA 旧路径(已迁移到 auth-otp) |
|
||
| `tests/test_otp_bind_flow.py` | 21 | OTP 绑定流程 |
|
||
| `tests/test_sensitive_words_auth.py` | 15 | **本次新增**(BUG-通用-004 鉴权补漏回归) |
|
||
| `tests/test_auth_qrcode.py` | 13 | 扫码登录 |
|
||
| `tests/test_admin_ip_whitelist.py` | 11 | 后台 IP 白名单 |
|
||
| `tests/test_agents_auth.py` | 11 | 坐席鉴权 |
|
||
| `tests/test_otp_unified.py` | 9 | OTP 统一认证 |
|
||
| `tests/test_auth_unified.py` | 8 | 统一认证(AUTH-03) |
|
||
| `tests/test_token_anomaly.py` | 7 | Token 异常检测 |
|
||
| `tests/test_rbac_verification.py` | 5 | 角色权限矩阵 |
|
||
|
||
### 🤖 自动化 / 工作流(10 文件 / 163 用例)
|
||
|
||
| 测试文件 | 用例数 | 说明 |
|
||
|----------|--------|------|
|
||
| `tests/automation/test_information_item_service.py` | 28 | 信息项服务(子目录) |
|
||
| `tests/test_automation_services.py` | 28 | 自动化服务层 |
|
||
| `tests/automation/test_session_manager_pause_resume.py` | 23 | 会话暂停恢复(子目录) |
|
||
| `tests/automation/test_global_intent_router.py` | 22 | 全局意图路由(子目录) |
|
||
| `tests/test_automation_unit.py` | 19 | 单元测试 |
|
||
| `tests/test_automation_session_manager.py` | 12 | 会话管理器 |
|
||
| `tests/automation/test_timeout_cleaner.py` | 8 | 超时清理(子目录) |
|
||
| `tests/test_automation_executor.py` | 8 | 自动化执行器 |
|
||
| `tests/test_automation_intent_router.py` | 8 | 意图路由器 |
|
||
| `tests/test_automation_approval.py` | 7 | 自动化审批 |
|
||
|
||
### 📋 审批工作流(3 文件 / 49 用例)
|
||
|
||
| 测试文件 | 用例数 | 说明 |
|
||
|----------|--------|------|
|
||
| `tests/test_approval_state_machine.py` | 19 | 审批状态机 |
|
||
| `tests/test_asset_approval_urge.py` | 18 | 资产审批催办 |
|
||
| `tests/test_approval_webhook.py` | 12 | 审批 Webhook |
|
||
|
||
### 💬 消息 / 路由 / 会话(10 文件 / 297 用例)
|
||
|
||
| 测试文件 | 用例数 | 说明 |
|
||
|----------|--------|------|
|
||
| `tests/test_routing_service.py` | 81 | 路由服务(含 broken link) |
|
||
| `tests/test_ai_reply_gate.py` | 51 | AI 回复闸门 |
|
||
| `tests/test_nontext_message.py` | 49 | 非文本消息(图片/语音) |
|
||
| `tests/test_message_dedup.py` | 34 | 消息去重 |
|
||
| `tests/test_ai_reply_mode_api.py` | 18 | AI 回复模式 API |
|
||
| `tests/test_message_router.py` | 17 | 消息路由器 |
|
||
| `tests/test_voice_asr.py` | 16 | 语音转文字(百度 ASR) |
|
||
| `tests/test_message_experience.py` | 13 | 体验优化 |
|
||
| `tests/test_message_id_type_bug.py` | 10 | UUID 类型 bug 回归 |
|
||
| `tests/test_messages_uuid.py` | 8 | UUID 消息 |
|
||
|
||
### 👥 会话协作 / 邀请(8 文件 / 123 用例)
|
||
|
||
| 测试文件 | 用例数 | 说明 |
|
||
|----------|--------|------|
|
||
| `tests/test_collaboration.py` | 21 | 协作功能 |
|
||
| `tests/test_invite_participant.py` | 20 | 邀请参与者 |
|
||
| `tests/test_conversation_grab.py` | 17 | 会话抢占(摇人) |
|
||
| `tests/test_employee_history_messages.py` | 17 | 员工历史消息 |
|
||
| `tests/test_invite_status.py` | 15 | 邀请状态 |
|
||
| `tests/test_conversations.py` | 13 | 会话管理 |
|
||
| `tests/test_invite_link.py` | 12 | 邀请链接 |
|
||
| `tests/test_employee_profile_service.py` | 8 | 员工档案 |
|
||
|
||
### 🧠 知识 / RAG(4 文件 / 61 用例)
|
||
|
||
| 测试文件 | 用例数 | 说明 |
|
||
|----------|--------|------|
|
||
| `tests/test_topic_detector.py` | 27 | 主题检测 |
|
||
| `tests/test_bugfix_ki_suggestions.py` | 21 | KI 建议 bug 修复回归 |
|
||
| `tests/test_confidence_gate.py` | 7 | 置信度闸门 |
|
||
| `tests/test_knowledge_iteration.py` | 6 | 知识迭代 |
|
||
|
||
### 🛡️ 内容审核(1 文件 / 15 用例)
|
||
|
||
| 测试文件 | 用例数 | 说明 |
|
||
|----------|--------|------|
|
||
| `tests/test_content_moderation.py` | 15 | 敏感词命中(中台核心) |
|
||
|
||
### 🎯 诊断 / 推荐 / 评分 / Wingman(7 文件 / 120 用例)
|
||
|
||
| 测试文件 | 用例数 | 说明 |
|
||
|----------|--------|------|
|
||
| `tests/test_wingman_service.py` | 32 | Wingman 服务层 |
|
||
| `tests/test_scoring_service.py` | 27 | 评分服务 |
|
||
| `tests/test_evaluation.py` | 16 | 评估 |
|
||
| `tests/test_triage.py` | 15 | 分诊 |
|
||
| `tests/test_recommend_progress_service.py` | 12 | 推荐进度 |
|
||
| `tests/test_wingman.py` | 12 | Wingman 模块 |
|
||
| `tests/test_match_keywords_email.py` | 6 | 关键词匹配 |
|
||
|
||
### 🏢 企微 / H5 集成(4 文件 / 46 用例)
|
||
|
||
| 测试文件 | 用例数 | 说明 |
|
||
|----------|--------|------|
|
||
| `tests/test_wecom_crypto.py` | 23 | 企微加解密 |
|
||
| `tests/test_h5_shake.py` | 12 | H5 摇一摇 |
|
||
| `tests/test_h5_asset_pipeline.py` | 6 | H5 资产推送管道 |
|
||
| `tests/test_h5_mask_option_select.py` | 5 | H5 蒙层/选项/选择 |
|
||
|
||
### 🖥️ 资产 / 基础 / 工具(11 文件 / 268 用例)
|
||
|
||
| 测试文件 | 用例数 | 说明 |
|
||
|----------|--------|------|
|
||
| `tests/test_p2_p3.py` | 48 | P2/P3 优先级 |
|
||
| `tests/test_org_tree.py` | 47 | 组织架构树 |
|
||
| `tests/test_meetingroom.py` | 40 | 会议室预定 |
|
||
| `tests/test_todo_integration.py` | 40 | 待办集成 |
|
||
| `tests/test_exclusion.py` | 28 | 排除规则 |
|
||
| `tests/test_api_basic.py` | 13 | API 基础冒烟 |
|
||
| `tests/test_env_gating.py` | 13 | 环境隔离 |
|
||
| `tests/test_avatar_service.py` | 12 | 头像服务 |
|
||
| `tests/test_backend_observer.py` | 11 | 后端观察者 |
|
||
| `tests/test_neo4j_client.py` | 9 | Neo4j 客户端 |
|
||
| `tests/test_response_contract.py` | 7 | 响应契约 |
|
||
|
||
### 🔌 WS / 实时推送(2 文件 / 12 用例)
|
||
|
||
| 测试文件 | 用例数 | 说明 |
|
||
|----------|--------|------|
|
||
| `tests/test_ws_endpoints.py` | 8 | WebSocket 端点 |
|
||
| `tests/test_ws_push_to_employee.py` | 4 | WS 推送给员工 |
|
||
|
||
### 🧪 Tier 1 API / 通用(2 文件 / 37 用例)
|
||
|
||
| 测试文件 | 用例数 | 说明 |
|
||
|----------|--------|------|
|
||
| `tests/test_tier1_api.py` | 34 | Tier 1 API 通用 |
|
||
| `tests/test_agents.py` | 3 | 坐席基础 |
|
||
|
||
### ⚠️ 预存在 collection 错误(2 文件 / 0 用例 / 2 collection 错)
|
||
|
||
| 测试文件 | 用例数 | 说明 |
|
||
|----------|--------|------|
|
||
| `tests/test_approval_detect_intent.py` | ⚠️ 0 | ⚠️ collection 错(import 损坏,预存在) |
|
||
| `tests/test_byod.py` | ⚠️ 0 | ⚠️ collection 错(预存在) |
|
||
|
||
---
|
||
|
||
## ⚠️ 预存在 collection 错误(已知,跳过)
|
||
|
||
| 错误信息 |
|
||
|----------|
|
||
| `____________ ERROR collecting tests/test_approval_detect_intent.py ____________` |
|
||
| `ImportError while importing test module 'D:\资料\03-项目开发\wecom_it_smart_desk\src\backend\tests\test_approval_detect_intent` |
|
||
| `E ImportError: cannot import name '_keyword_prefilter' from 'app.api.approval' (D:\资料\03-项目开发\wecom_it_smart_desk\src\` |
|
||
| `_____________________ ERROR collecting tests/test_byod.py _____________________` |
|
||
| `ImportError while importing test module 'D:\资料\03-项目开发\wecom_it_smart_desk\src\backend\tests\test_byod.py'.` |
|
||
| `E ImportError: cannot import name '_byod_fallback_detect' from 'app.api.byod' (D:\资料\03-项目开发\wecom_it_smart_desk\src\b` |
|
||
|
||
---
|
||
|
||
## 🚀 常用命令
|
||
|
||
```bash
|
||
cd src/backend
|
||
|
||
# 跑全部有效套件(跳过 3 个预损坏)
|
||
python -m pytest tests/ -q \
|
||
--ignore=tests/test_approval_detect_intent.py \
|
||
--ignore=tests/test_byod.py \
|
||
--ignore=tests/test_quick_rules.py
|
||
|
||
# 跑指定主题(按文件名匹配)
|
||
python -m pytest tests/test_sensitive_words_auth.py tests/test_content_moderation.py -v
|
||
|
||
# 跑本次新增的鉴权回归(最关键)
|
||
python -m pytest tests/test_sensitive_words_auth.py -v
|
||
|
||
# 重新生成本文档
|
||
python ../../scripts/test_inventory.py --baseline 1311/88/4
|
||
```
|
||
|
||
---
|
||
|
||
## 🔗 关联文档
|
||
|
||
- 测试方法论指南: `./测试方法论指南.md`
|
||
- 测试分类索引: `../README.md`
|
||
- TC(功能测试用例): `../03-功能测试用例/`
|
||
- TR(版本测试报告): `../04-版本测试报告/`
|
||
- BUG 单: `../05-缺陷单/`
|
||
- 整改记录 #12: `../../04-运维文档/部署运维/00-文档规范化整改记录.md`
|
||
|
||
---
|
||
|
||
> 最后更新:2026-08-05 | 自动生成 baseline:1311/1403 通过
|