package operations import ( "encoding/json" "orchestra/internal/domain" "testing" "time" ) func TestBuildBrief(t *testing.T) { now := time.Now() p, _ := json.Marshal(map[string]any{"harness_id": "cc", "consumed": 12}) es := []domain.Event{{Type: "TaskCompleted", At: now}, {Type: "TaskFailed", At: now}, {Type: "ApprovalRequested", At: now}, {Type: "QuotaReported", At: now, Payload: p}} b := BuildBrief(es, now.Add(-time.Minute), now.Add(time.Minute), GitSync{Status: "clean"}) if b.Completed != 1 || b.Failed != 1 || len(b.NeedsAttention) != 2 || b.Quota["cc"] != 12 { t.Fatalf("unexpected brief: %+v", b) } }