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// rowsFixture is a Tasks list with one row for each kind of decision the
11// redesigned rows answer (Retry, Retry push, Another round, What next?),
12// three merged tasks for Done's "Show N more", a title too long for two
13// lines, and enough noted tasks to fill the list past twenty rows.
14type rowsFixture struct {
15 r *toolRig
16 retry, push, rounds, explore, long string
17 done []string
18 noted []string
19}
20
21const rowsLongTitle = "Make the compose sheet keep its draft, attachments and scroll position when the app comes back from the background"
22
23func newRowsFixture(t *testing.T, noted int) *rowsFixture {
24 t.Helper()
25 r := newToolRigAt(t, wire.ProtocolCurrent)
26 f := &rowsFixture{r: r}
27 sha := func(c string) string { return strings.Repeat(c, 40) }
28
29 // Done: three tasks Equipo merged.
30 for i, c := range []string{"a", "b", "c"} {
31 key := "d" + itoa(i)
32 id, _ := r.pushed(key, "Fix README typo number "+itoa(i+1), sha("1"), sha(c))
33 r.expect(wire.FrameWatchMerge)
34 ch := r.dispatched(wire.SpecialistChecks, sha("1"), sha(c), 0)
35 r.checks(key+"-c", ch, wire.ChecksPassed, exit(0), "", "ok\n")
36 rv := r.dispatched(wire.SpecialistReview, sha("1"), sha(c), 0)
37 r.verdict(key+"-r", rv, wire.VerdictApprove)
38 m := r.dispatched(wire.SpecialistMerge, sha("1"), sha(c), 0)
39 r.mergedStep(key+"-m", m, sha("d"))
40 r.wait("merged", func(c *Conversation) bool { return c.Tasks[id].Stage == wire.StageDone })
41 f.done = append(f.done, id)
42 }
43
44 // Stopped: the model connection failed (Retry), the push failed
45 // (Retry push).
46 stopped := func(key, title, reason string) string {
47 id := taskID(t, r.call(key+"-rec", wire.ToolRecordTask, map[string]any{"repo": "oficina/sample", "title": title, "brief": "Fix it.", "separate": true}))
48 if res := r.call(key+"-start", wire.ToolStartTask, map[string]string{"task": id, "brief": "Fix it."}); res.IsError {
49 t.Fatalf("start: %+v", res)
50 }
51 r.stop(key, r.nextDispatch(), reason)
52 r.wait("stopped", func(c *Conversation) bool { return c.Tasks[id].NeedsYou == wire.NeedsRetry })
53 return id
54 }
55 f.retry = stopped("s1", "Show project and stream context on thinking indicators", "provider_failed")
56 f.push = stopped("s2", "Create two clickable barber app mockups", "push_failed")
57
58 // Still not approved after two fix rounds: Another round.
59 cands := []string{sha("2"), sha("3"), sha("4")}
60 f.rounds, _ = r.pushed("fr", "Add project rename control and ship the update", sha("1"), cands[0])
61 r.expect(wire.FrameWatchMerge)
62 c := r.dispatched(wire.SpecialistChecks, sha("1"), cands[0], 0)
63 r.checks("fr-c0", c, wire.ChecksFailed, exit(2), "", "--- FAIL: TestRename\nFAIL\n")
64 fix := r.dispatched(wire.SpecialistEngineering, cands[0], "", 1)
65 for round := 1; round <= 2; round++ {
66 key := "fr" + itoa(round)
67 r.step(key+"-done", wire.StepReport{TaskID: f.rounds, StepID: fix.StepID, Attempt: 1, State: wire.StepDone, BaseSHA: cands[round-1], CandidateSHA: cands[round], Pushed: true, Termination: true})
68 c = r.dispatched(wire.SpecialistChecks, sha("1"), cands[round], round)
69 r.checks(key+"-c", c, wire.ChecksNone, nil, "", "")
70 rv := r.dispatched(wire.SpecialistReview, sha("1"), cands[round], round)
71 r.verdict(key+"-r", rv, wire.VerdictChanges, wire.Finding{Text: "Still wrong.", Path: "README.md", Line: 5})
72 if round == 1 {
73 fix = r.dispatched(wire.SpecialistEngineering, cands[1], "", 2)
74 }
75 }
76 r.wait("fix rounds", func(c *Conversation) bool { return c.Tasks[f.rounds].NeedsYou == wire.NeedsFixRounds })
77
78 // An exploration waiting on its direction: What next?
79 f.explore, _ = r.toDirection("x", "Barber app mockups")
80
81 // A title too long for two lines, and the noted tasks.
82 f.long = taskID(t, r.call("long-rec", wire.ToolRecordTask, map[string]any{"repo": "oficina/sample", "title": rowsLongTitle, "brief": "Keep the draft.", "separate": true}))
83 subjects := []string{"invite emails", "the sign-in page", "runner logs", "the merge card", "project stars", "the notebook", "dark mode charts", "machine names",
84 "thread replies", "preview links", "budget alerts", "the composer", "file uploads", "team links", "housekeeping", "the stage track", "spend totals", "settings search"}
85 for i := 0; i < noted; i++ {
86 title := "Tidy up " + subjects[i%len(subjects)]
87 id := taskID(t, r.call("n"+itoa(i)+"-rec", wire.ToolRecordTask, map[string]any{"repo": "oficina/equipo", "title": title, "brief": "Look at " + subjects[i%len(subjects)] + " when there is time.", "separate": true}))
88 f.noted = append(f.noted, id)
89 }
90 want := 3 + 2 + 1 + 1 + 1 + noted
91 r.wait("all rows", func(c *Conversation) bool { return len(c.Tasks) >= want })
92 return f
93}
94