oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package thintest
2
3import (
4 "strings"
5 "testing"
6
7 "amadan.net/oficina/equipo/internal/wire"
8)
9
10// TestContractHeadlines: a finding, Engineering's change and Review's
11// verdict each carry one plain sentence for the task page's timeline. The
12// instance keeps it on the record and serves it to every member; a
13// headline naming a file path is dropped (the detail keeps the path), and
14// a long one is cut at a word.
15func TestContractHeadlines(t *testing.T) {
16 r := newToolRig(t)
17 base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40)
18 id := taskID(t, r.call("h1", wire.ToolRecordTask, map[string]string{"repo": "oficina/sample", "title": "Swipe back does nothing", "brief": "On iOS."}))
19 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})
20 r.call("h3", wire.ToolAddFinding, map[string]any{"task": id, "headline": "Edited panes/swipe.go.", "text": "A second look."})
21 r.call("h4", wire.ToolAddFinding, map[string]any{"task": id, "text": "No headline at all."})
22 k, err := r.client.Task(r.ctx, id)
23 if err != nil {
24 t.Fatal(err)
25 }
26 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." {
27 t.Fatalf("finding headlines: %+v", k.Findings)
28 }
29 r.call("h5", wire.ToolStartTask, map[string]string{"task": id, "brief": "Make it go back."})
30 _, body := r.expect(wire.FrameDispatch)
31 d := body.(*wire.DispatchCommand)
32 r.step("h-run", wire.StepReport{TaskID: id, StepID: d.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: base})
33 long := strings.Repeat("Fixed swipe-back on every pane ", 8)
34 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."})
35 r.expect(wire.FrameWatchMerge)
36 c := r.dispatched(wire.SpecialistChecks, base, cand, 0)
37 r.checks("h-c", c, wire.ChecksPassed, exit(0), "", "ok")
38 rv := r.dispatched(wire.SpecialistReview, base, cand, 0)
39 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."}}})
40 r.wait("review headline", func(c *Conversation) bool {
41 k := c.Tasks[id]
42 return len(k.Steps) >= 3 && k.Steps[2].Headline == "Approved."
43 })
44 k, err = r.client.Task(r.ctx, id)
45 if err != nil {
46 t.Fatal(err)
47 }
48 eng := k.Steps[0]
49 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") {
50 t.Fatalf("engineering headline %q, summary %q", eng.Headline, eng.Summary)
51 }
52 if k.Steps[1].Headline != "" {
53 t.Fatalf("checks headline %q", k.Steps[1].Headline)
54 }
55 rev := k.Steps[2]
56 if rev.Headline != "Approved." || len(rev.Findings) != 2 || rev.Findings[0].Headline != "One note: test a swipe from mid-screen." || rev.Findings[1].Headline != "" {
57 t.Fatalf("review headlines: %q %+v", rev.Headline, rev.Findings)
58 }
59}
60