Commit Graph

5 Commits

Author SHA1 Message Date
moyin
0192934c66 test:添加验证码冷却时间清除功能测试
为新增的验证码冷却时间清除功能添加全面的测试用例:

验证服务测试:
- 测试成功清除冷却时间
- 测试清除不存在的冷却时间
- 测试Redis操作错误处理
- 测试不同类型和标识符的冷却时间清除

登录核心服务测试:
- 测试注册成功后自动清除冷却时间
- 测试密码重置成功后自动清除冷却时间
- 测试验证码登录成功后自动清除冷却时间
- 测试冷却时间清除失败的优雅处理
2025-12-25 20:49:16 +08:00
moyin
d4a7b36129 Merge branch 'main' of https://gitea.xinghangee.icu/datawhale/whale-town-end into ANGJustinl-main 2025-12-18 14:12:45 +08:00
moyin
3cfebbc4c4 fix: 修复测试用例中的问题
- 修复邮件服务测试中未使用的变量警告
- 修复验证服务测试中的TTL和返回值期望问题
- 确保所有113个测试用例通过

详细修改:
- email.service.spec.ts: 移除4个未使用的testService变量
- verification.service.spec.ts:
  * 添加TTL mock值避免异常分支
  * 更新getCodeStats期望值包含code和createdAt字段
  * 修正TTL期望值从-1改为-2(Redis标准)

测试结果: 6个测试套件,113个测试用例全部通过
2025-12-18 13:33:40 +08:00
angjustinl
6dece752ef test(email, verification, login): 更新测试中的断言内容, 修复测试error.
- Replace boolean assertions with structured result object checks in email service tests
- Update email service tests to verify success flag and isTestMode property
- Add error message assertions for failed email sending scenarios
- Change logger spy from 'log' to 'warn' for test mode email output
- Update test message to clarify emails are not actually sent in test mode
- Add code and createdAt properties to verification code stats mock data
- Fix TTL mock value from -1 to -2 to correctly represent non-existent keys
- Replace Inject decorator with direct UsersService type injection in LoginCoreService
- Ensure verification service tests properly mock TTL values during code verification
- Improve test coverage by validating complete response structures instead of simple booleans
2025-12-18 13:29:55 +08:00
moyin
eb7a022f5b feat:添加验证码服务
- 实现验证码生成、验证和管理功能
- 支持多种验证码类型(邮箱验证、密码重置、短信验证)
- 集成Redis缓存存储验证码
- 实现防刷机制:发送频率限制和每小时限制
- 支持验证码过期管理和尝试次数限制
- 包含完整的单元测试
2025-12-17 20:21:30 +08:00