feat(platform): add quality notification plan
This commit is contained in:
@@ -859,6 +859,35 @@ func TestHandlerQualityIssuesFiltersIssueType(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandlerQualityNotificationPlan(t *testing.T) {
|
||||
handler := NewHandler(NewService(NewMockStore()))
|
||||
rec := httptest.NewRecorder()
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/quality/notification-plan?limit=10", nil)
|
||||
handler.ServeHTTP(rec, req)
|
||||
if rec.Code != http.StatusOK {
|
||||
t.Fatalf("status = %d body=%s", rec.Code, rec.Body.String())
|
||||
}
|
||||
var body struct {
|
||||
Data QualityNotificationPlan `json:"data"`
|
||||
}
|
||||
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
|
||||
t.Fatalf("response JSON should decode: %v body=%s", err, rec.Body.String())
|
||||
}
|
||||
if body.Data.ActiveRuleCount == 0 || body.Data.P0RuleCount == 0 {
|
||||
t.Fatalf("notification plan should expose active P0 rules, got %+v", body.Data)
|
||||
}
|
||||
if len(body.Data.Rules) == 0 || len(body.Data.Policies) == 0 || len(body.Data.PriorityIssues) == 0 {
|
||||
t.Fatalf("notification plan should include rules, policies and priority issues: %+v", body.Data)
|
||||
}
|
||||
first := body.Data.PriorityIssues[0]
|
||||
if first.Priority != "P0" || first.ActionLabel == "" || first.SLA == "" || first.VehicleLabel == "" {
|
||||
t.Fatalf("priority issue should be enriched for notification: %+v", first)
|
||||
}
|
||||
if !strings.Contains(first.NotificationText, "实时定位") || !strings.Contains(first.NotificationText, "#/history") {
|
||||
t.Fatalf("priority issue should include evidence links, got %q", first.NotificationText)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHandlerOpsHealthIncludesVehicleServiceRuntime(t *testing.T) {
|
||||
handler := NewHandler(NewServiceWithRuntime(NewMockStore(), RuntimeInfo{RequestTimeoutMs: 1500}))
|
||||
rec := httptest.NewRecorder()
|
||||
|
||||
Reference in New Issue
Block a user