package thintest import ( "strings" "testing" "amadan.net/oficina/equipo/internal/wire" ) // TestContractHeadlines: a finding, Engineering's change and Review's // verdict each carry one plain sentence for the task page's timeline. The // instance keeps it on the record and serves it to every member; a // headline naming a file path is dropped (the detail keeps the path), and // a long one is cut at a word. func TestContractHeadlines(t *testing.T) { r := newToolRig(t) base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40) id := taskID(t, r.call("h1", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Swipe back does nothing", "brief": "On iOS."})) r.call("h2", wire.ToolAddFinding, map[string]any{"task": id, "headline": "Found it: hiding the bar turned off swipe-back.", "text": "The host hides its navigation bar, which turns off the edge swipe.", "repo": "oficina/sample", "path": "panes/swipe.go", "line": 4}) r.call("h3", wire.ToolAddFinding, map[string]any{"task": id, "headline": "Edited panes/swipe.go.", "text": "A second look."}) r.call("h4", wire.ToolAddFinding, map[string]any{"task": id, "text": "No headline at all."}) k, err := r.client.Task(r.ctx, id) if err != nil { t.Fatal(err) } if len(k.Findings) != 3 || k.Findings[0].Headline != "Found it: hiding the bar turned off swipe-back." || k.Findings[1].Headline != "" || k.Findings[2].Headline != "" || k.Findings[1].Text != "A second look." { t.Fatalf("finding headlines: %+v", k.Findings) } r.call("h5", wire.ToolStartTask, map[string]string{"task": id, "brief": "Make it go back."}) _, body := r.expect(wire.FrameDispatch) d := body.(*wire.DispatchCommand) r.step("h-run", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: base}) long := strings.Repeat("Fixed swipe-back on every pane ", 8) r.step("h-done", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepDone, BaseSHA: base, CandidateSHA: cand, Pushed: true, Termination: true, Headline: long, Summary: "The host now lets the stack's pop gesture run.\n\nNot run here: the Xcode tests need macOS."}) r.expect(wire.FrameWatchMerge) c := r.dispatched(wire.SpecialistChecks, base, cand, 0) r.checks("h-c", c, wire.ChecksPassed, exit(0), "", "ok") rv := r.dispatched(wire.SpecialistReview, base, cand, 0) r.step("h-r", wire.StepReport{TaskID: id, StepID: rv.StepID, Attempt: 1, State: wire.StepDone, BaseSHA: base, CandidateSHA: cand, Termination: true, Family: "claude", Account: "claude-b", Verdict: wire.VerdictApprove, ReviewLabel: wire.ReviewSameFamily, Headline: "Approved.", Summary: "Read the change.", Findings: []wire.Finding{{Headline: "One note: test a swipe from mid-screen.", Text: "Consider a test for a swipe that starts mid-screen.", Path: "panes/swipe.go", Line: 4}, {Headline: "See swipe_test.go:9.", Text: "Another."}}}) r.wait("review headline", func(c *Conversation) bool { k := c.Tasks[id] return len(k.Steps) >= 3 && k.Steps[2].Headline == "Approved." }) k, err = r.client.Task(r.ctx, id) if err != nil { t.Fatal(err) } eng := k.Steps[0] if !strings.HasPrefix(eng.Headline, "Fixed swipe-back on every pane") || len(eng.Headline) > wire.MaxHeadline+len("…") || !strings.HasSuffix(eng.Headline, "…") || !strings.Contains(eng.Summary, "Xcode") { t.Fatalf("engineering headline %q, summary %q", eng.Headline, eng.Summary) } if k.Steps[1].Headline != "" { t.Fatalf("checks headline %q", k.Steps[1].Headline) } rev := k.Steps[2] if rev.Headline != "Approved." || len(rev.Findings) != 2 || rev.Findings[0].Headline != "One note: test a swipe from mid-screen." || rev.Findings[1].Headline != "" { t.Fatalf("review headlines: %q %+v", rev.Headline, rev.Findings) } }