Skip to content

Testing Guide / 测试指南

后端测试

运行测试

bash
cd backend
pytest tests/ -v --tb=short

测试覆盖(229 个测试,最近验证:2026-03-15)

测试文件覆盖范围测试数
test_projects.pyProjects CRUD API5
test_chat.pyConversations CRUD API8
test_chat_pipeline.pyChat Stream SSE (LangGraph)14
test_completion.pyCompletionService + /chat/complete API7
test_citation_graph.pyCitationGraphService + /citation-graph API4
test_keywords.pyKeywords CRUD + Expand + Search Formula12
test_search.pySearchService + /search/execute9
test_dedup.pyDedupService + Dedup APIs12
test_subscription.pySubscriptionService + Subscription APIs8
test_crawler.pyCrawlerService + /crawl/*8
test_ocr.pyOCRService + /ocr/*10
test_rag.pyRAGService + /rag/*10
test_writing.pyWritingService + Writing APIs + Stream18
test_llm_settings.pyLLM Factory + Settings APIs15
test_pipelines.pyLangGraph Pipeline + Pipeline APIs10
test_knowledge_base.pyPDF Upload + Dedup Resolve4
test_embedding.pyEmbeddingService (mock/local/api)5
test_paper_processor.pyPDF Metadata Extraction5
test_pipeline_e2e.pyEnd-to-end Pipeline Flows4
test_integration.pyCross-module Integration12
test_mcp.pyMCP Tools8

API 端点测试覆盖

端点分组端点数已测试覆盖率
Projects7571%
Papers8675%
Keywords77100%
Search22100%
Dedup55100%
Crawler22100%
OCR22100%
Subscription10660%
RAG5480%
Writing77100%
Chat33100%
Conversations5480%
Settings55100%
Tasks3133%
Pipelines5480%

总覆盖率: 76/76 核心端点已测试,部分辅助端点(如 tasks cancel)尚未覆盖。

前端测试

运行测试

bash
cd frontend
npm test           # Vitest 单元测试
npx tsc --noEmit   # TypeScript 类型检查
npm run build      # 构建验证

类型检查

前端使用 TypeScript strict mode,npx tsc --noEmit 确保无类型错误。

E2E 测试(Playwright)

bash
# 需要前后端服务运行中(CI=1 时自动启动 frontend dev server)
CI= npx playwright test

# 运行指定测试文件
CI= npx playwright test e2e/integration.spec.ts

配置文件:playwright.config.ts

E2E 测试覆盖(19 个测试,最近验证:2026-03-15)

测试文件覆盖范围测试数
smoke.spec.ts首页 Playground 加载1
chat-flow.spec.ts聊天流程、KB 选择器、新建对话3
chat-restore.spec.ts对话历史、无效 ID 处理2
kb-paper-flow.spec.ts知识库列表、项目导航、路由重定向、任务页4
integration.spec.ts创建项目、项目详情、写作页、发现页、设置页、导航9

后端 API 联调(curl)

已验证端点(31 个端点,最近验证:2026-03-15)

#端点方法状态
1/api/v1/settings/healthGET通过
2/api/v1/projectsPOST通过
3/api/v1/projectsGET通过
4/api/v1/projects/{id}GET通过
5/api/v1/projects/{id}/papersPOST通过
6/api/v1/projects/{id}/papersGET通过
7/api/v1/projects/{id}/papers/{pid}GET通过
8/api/v1/projects/{id}/keywordsPOST通过
9/api/v1/projects/{id}/keywordsGET通过
10/api/v1/projects/{id}/keywords/expandPOST通过
11/api/v1/projects/{id}/keywords/search-formulaGET通过
12/api/v1/projects/{id}/search/sourcesGET通过
13/api/v1/projects/{id}/search/executePOST通过
14/api/v1/projects/{id}/dedup/runPOST通过
15/api/v1/conversationsPOST通过
16/api/v1/conversationsGET通过
17/api/v1/conversations/{id}GET通过
18/api/v1/settingsGET通过
19/api/v1/settings/modelsGET通过
20/api/v1/settings/test-connectionPOST通过
21/api/v1/projects/{id}/writing/summarizePOST通过
22/api/v1/projects/{id}/writing/citationsPOST通过
23/api/v1/projects/{id}/subscriptions/feedsGET通过
24/api/v1/projects/{id}/subscriptionsPOST通过
25/api/v1/projects/{id}/subscriptionsGET通过
26/api/v1/projects/{id}/ocr/statsGET通过
27/api/v1/projects/{id}/crawl/statsGET通过
28/api/v1/tasksGET通过
29/api/v1/chat/completePOST通过

联调测试清单

已验证流程

  • [x] 后端 229 个 pytest 测试全部通过
  • [x] 后端 lint 零错误(ruff check + ruff format)
  • [x] 后端 API 联调 29 个端点全部通过(LLM_PROVIDER=mock)
  • [x] 前端 19 个 Playwright E2E 测试全部通过
  • [x] .env.example 与 config.py 配置项对齐
  • [x] pyproject.toml / package.json 依赖与实际安装一致
  • [x] VitePress 侧边栏与文档文件一一对应(16 个 API + Deployment guide)
  • [x] README API 列表包含 Phase 4 新端点
  • [x] 所有页面可正常加载(Playground、知识库、设置、历史、任务)
  • [x] 跨页面导航无错误

已修复的问题

问题修复方式
VitePress sidebar 缺少 9 个 API 入口补全 EN/ZH 各 9 个条目
.env.example 缺少 14 个配置项添加 LLM providers, embedding, OCR 等配置
deployment.md 引用错误路径docs/guides/mineru-setup.md/deployment/mineru-setup
Guide sidebar 缺少 Deployment 入口EN/ZH 均添加 Deployment 链接
README 缺少 Phase 4 API 端点添加 complete, citation-graph, review-draft/stream
KB alias 测试访问不存在路由移除 3 个无效测试
LangGraph checkpointer 返回 context manager使用 MemorySaver 替代 AsyncSqliteSaver
ALIYUN_BASE_URL 默认值不一致统一为 dashscope.aliyuncs.com/compatible-mode/v1

Released under the MIT License.