feat: 引入全面测试基础设施并优化后端性能 - #5
Merged
Merged
Conversation
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
Co-authored-by: traeagent <traeagent@users.noreply.github.com>
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.
🎯 Changes
1. 全面引入测试基础设施与用例
AgentOrchestrator新增全面单元测试,覆盖消息重要性评估、类型分类、安全过滤、意图路由、工具执行、记忆管理、RAG 检索、指标监控及各类边界异常场景。ArticleController新增全面单元测试,覆盖文章 CRUD、分页查询、权限校验、相关文章、点赞收藏等全部 HTTP 接口场景。AuthController新增全面单元测试,覆盖登录、MFA、验证码、Token 刷新、退出登录等认证相关接口场景。CommentController新增全面单元测试,覆盖评论 CRUD、嵌套回复、点赞/取消点赞、审核流程、权限校验等全部接口场景。AesUtil新增全面单元测试,覆盖加密解密、密钥管理、密钥检测、API Key 掩码、日志安全字符串等功能。RedisLockUtil新增全面单元测试,覆盖分布式锁获取/释放、重试机制、超时处理、并发竞争及异常安全场景。CommentInput组件新增单元测试,覆盖输入校验、表情插入、提交/取消等场景。CommentItem组件的单元测试,更新断言和 Mock 结构。CommentList组件新增单元测试,覆盖评论加载、点赞、删除、加载更多等场景。FormInput组件的单元测试,增强验证提示和边界条件的测试覆盖。LoginForm组件新增单元测试,覆盖登录成功/失败、验证码校验、MFA 跳转等场景。useArticleDetailcomposable 新增单元测试,覆盖文章加载、错误处理、TOC 生成等场景。useValidationcomposable 新增单元测试,覆盖各种校验规则、自定义规则和异步校验场景。format.ts工具函数新增单元测试,覆盖日期和数字格式化场景。transform.ts工具函数新增单元测试,覆盖数据转换函数场景。xss.js工具函数新增单元测试,覆盖 XSS 过滤规则和白名单场景。@playwright/test依赖版本至 1.60.0,清理不再需要的可选依赖,优化 Vitest 测试配置,新增覆盖率和测试覆盖率报告相关配置,扩展测试环境配置,新增 Mock Service Worker 和更多全局 Mock 定义。2. 后端性能与安全性优化
AgentOrchestrator中的CircuitBreakerRegistry依赖。AgentOrchestrator中消息重要性评估和类型判断的触发词集合提取为静态常量,提升性能。ContentGenerationAgent中冗余的Logger声明,统一使用@Slf4j。ArticleServiceImpl中修复标签查询的 N+1 问题,改为批量IN查询替代逐条selectOneById。ArticleContentMapper新增upsert方法,使用ON DUPLICATE KEY UPDATE实现文章内容的插入或更新,避免先查后插的两次操作。AuthController,MfaController,PasswordController,UserController,VerificationController添加@Validated注解以启用参数校验功能。UserServiceImpl新增密码长度校验常量,并在注册流程中引入密码强度校验,新增validatePassword私有方法进行上下界校验。3. 前端组件与页面优化
ArticleCard,CommentInput,CommentList,LoginForm,RegisterForm,FormInput,MDEditor,FeaturedArticles,MobileMenu,SearchBar,UserMenu,TechBadge,EmptyState,ErrorState,Pagination,SkeletonLoader等组件的样式、交互、校验逻辑或配置。format.ts(日期和数字格式化),transform.ts(数据转换),xss.js(XSS 防护) 工具函数。💡 Technical Highlights
upsert操作,有效提升了后端服务的性能。@Validated注解和密码强度校验,增强了后端 API 的安全性和数据完整性。