test: 后端补测试 + CI 增加覆盖率检查 - #153
Merged
Merged
Conversation
- 重构 backend/server.js 导出 app 与检索函数,支持 supertest 驱动测试 - 新增 backend/server.test.js(22 项:tokenize/检索/API/chat mock LLM) - CI 增加 backend 测试 job - 前端测试增加 v8 覆盖率检查(statements≥70% 等阈值)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更内容
后端(新增测试)
backend/server.js:导出app与检索函数(tokenize/retrieveQA/retrieveBuildingInfo等),并改为条件监听端口——直接运行行为不变,但可被 supertest 导入测试。backend/server.test.js(22 项测试):覆盖分词、打分、QA 检索、建筑检索、Prompt 构建,以及/health、/api/freshman-questions、/api/chat(mock LLM)等 HTTP 接口。CI(.github/workflows/test.yml)
test:coverage,启用 v8 覆盖率检查(阈值 statements≥70% / branches≥60% / functions≥70% / lines≥70%)。前端
@vitest/coverage-v8,新增test:coverage脚本,vitest.config 配置覆盖率阈值。验证