feat(findings): show consolidation across report task and asset views

This commit is contained in:
ji ruo committed 2026-10-09 12:41:46 +08:00
1 parent d68594e81a
commit d36812b7e1
10 files changed
+627 -462

No files matched your search

+31
View File
@@ -321,3 +321,34 @@ func TestFindingCaseGroupedTrafficExportAndInheritedAccess(t *testing.T) {
t.Fatal(w.Code, w.Body)
}
}
func TestFindingCaseListIncludesContextAndFilteredCounts(t *testing.T) {
s, task, ids := testCaseServer(t)
cid, err := s.m.pg.MergeFindingCase(t.Context(), task, ids[:3], "same defect", "verified root cause", "human")
if err != nil {
t.Fatal(err)
}
r := httptest.NewRequest("GET", fmt.Sprintf("/api/finding-cases?task_id=%d&severity=medium", task), nil)
w := httptest.NewRecorder()
s.listFindingCases(w, r)
if w.Code != 200 {
t.Fatalf("status %d %s", w.Code, w.Body.String())
}
var page struct {
Total int `json:"total"`
MatchingReports int `json:"matching_reports"`
Items []struct {
Case *db.FindingCase `json:"case"`
TaskDescription string `json:"task_description"`
Assets []FindingAssetDTO `json:"assets"`
AssetCount int `json:"asset_count"`
LastFoundAt string `json:"last_found_at"`
} `json:"items"`
}
if err := json.Unmarshal(w.Body.Bytes(), &page); err != nil {
t.Fatal(err)
}
if page.Total != 1 || page.MatchingReports != 1 || len(page.Items) != 1 || page.Items[0].Case.ID != cid || page.Items[0].Case.Count != 3 || page.Items[0].Case.Report != "" || page.Items[0].TaskDescription == "" || page.Items[0].LastFoundAt == "" || page.Items[0].Assets == nil {
t.Fatalf("list payload %s", w.Body.String())
}
}