fix: improve conversation and report stability

This commit is contained in:
richjohnrambo
2026-08-26 14:12:58 +08:00
parent dc80aa5104
commit a0fc553c6f
6 changed files with 138 additions and 14 deletions
+40
View File
@@ -2442,6 +2442,46 @@ func TestServeIMMonthlyReportsCreate(t *testing.T) {
}
}
func TestServeIMMonthlyReportsListIncludesPreviews(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()
expectIMBearer(t, ctrl, "token-1", 7, 42)
oldMonthlyReports := store.MonthlyReports
now := time.Now().UTC().Round(time.Millisecond)
reports := &testMonthlyReportsStore{report: &types.MonthlyReport{
ReportID: "mr_test",
AuthorID: 42,
Month: "2026-08",
WorkSummary: strings.Repeat("工作", 80),
NextPlan: " 下月计划一 \n 下月计划二 ",
Status: types.DailyReportStatusDraft,
ReadState: "unread",
Version: 1,
CreatedAt: now,
UpdatedAt: now,
}}
store.MonthlyReports = reports
defer func() { store.MonthlyReports = oldMonthlyReports }()
req := httptest.NewRequest(http.MethodGet, "/v1/im/reports/monthly?scope=mine", nil)
req.Header.Set("Authorization", "Bearer token-1")
rec := httptest.NewRecorder()
serveIMMonthlyReports(rec, req)
if rec.Code != http.StatusOK {
t.Fatalf("status: got %d, want %d; body=%s", rec.Code, http.StatusOK, rec.Body.String())
}
data := decodeIMHTTPResponse(t, rec).Data.(map[string]any)
items := data["items"].([]any)
item := items[0].(map[string]any)
if item["work_summary_short"] != strings.Repeat("工作", 60)+"..." {
t.Fatalf("unexpected work summary preview: %#v", item["work_summary_short"])
}
if item["next_plan_short"] != "下月计划一 下月计划二" {
t.Fatalf("unexpected next plan preview: %#v", item["next_plan_short"])
}
}
func TestServeIMMonthlyReportDraftAndSubmit(t *testing.T) {
ctrl := gomock.NewController(t)
defer ctrl.Finish()