test(diary): 添加 9 个集成测试 + 修复 mood_stats 表名
Some checks failed
Main Merge / backend (push) Has been cancelled
Main Merge / frontend (push) Has been cancelled

集成测试 (TestDb + Service 层直接调用):
- test_journal_crud_full_lifecycle: 创建/查询/更新/列表/软删除全流程
- test_journal_version_conflict_on_update: 乐观锁版本冲突检测
- test_journal_tenant_isolation: 多租户数据隔离验证
- test_class_create_and_join: 班级创建+学生加入+成员查询+班级码重置
- test_sync_batch_create_and_fetch: 批量创建 3 篇日记同步
- test_sync_version_conflict_detection: 同步版本冲突检测
- test_mood_stats_aggregation: 心情统计 GROUP BY 聚合
- test_parent_binding_two_step_verification: 家长绑定两步验证
- test_achievement_list: 成就查询

修复:
- mood_stats_service: journal_entry → journal_entries 表名修正

测试: 518/518 全仓库通过 (含 9 新增集成测试)
This commit is contained in:
iven
2026-06-03 18:04:58 +08:00
parent 4cd381295a
commit 271f0c4f29
4 changed files with 497 additions and 2 deletions

View File

@@ -53,7 +53,7 @@ impl MoodStatsService {
// SQL GROUP BY — 一次查询获取所有心情计数(替代全量加载)
let sql = r#"
SELECT mood, COUNT(*) AS count
FROM journal_entry
FROM journal_entries
WHERE tenant_id = $1
AND author_id = $2
AND date >= $3
@@ -124,7 +124,7 @@ impl MoodStatsService {
let sql = r#"
SELECT DISTINCT date
FROM journal_entry
FROM journal_entries
WHERE tenant_id = $1
AND author_id = $2
AND date >= $3