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 "regexp"
5 "strings"
6 "testing"
7
8 "amadan.net/oficina/equipo/internal/wire"
9)
10
11// teamGallery is the gallery with the team panel's two cases: Review at
12// work on a Woodstar task, its activity arriving as Codex sends it
13// (raw shell), and Engineering idle after finishing the Equipo task,
14// whose session the runner kept, so it can be asked.
15type teamGallery struct {
16 *gallery
17 review, reviewStep string
18}
19
20// teamRawLines are Review's activity as the runner reported it.
21var teamRawLines = []wire.StepActivityReport{
22 {Kind: wire.ActivityRun, Subject: `/bin/bash -lc "cat ios/Woodstar/NavigationStack.swift"`},
23 {Kind: wire.ActivityRun, Subject: `/bin/bash -c 'sed -n 1,80p ios/Woodstar/AccountNavigationHost.swift'`},
24 {Kind: wire.ActivityRun, Subject: `/bin/bash -lc "rg -n interactivePopGestureRecognizer ios"`},
25 {Kind: wire.ActivityRun, Subject: `/bin/bash -lc "git diff 1111111...a91c3d0"`},
26}
27
28func newTeamGallery(t *testing.T) *teamGallery {
29 t.Helper()
30 g := &teamGallery{gallery: newGallery(t)}
31 a := g.a
32 sha := func(c string) string { return strings.Repeat(c, 40) }
33 // Engineering finishes the Equipo task; its session is kept.
34 cand := "a7c41e2" + sha("c")[7:]
35 a.step("tp-eng-done", wire.StepReport{TaskID: g.running, StepID: g.runningStep.StepID, Attempt: 1, State: wire.StepDone, BaseSHA: sha("8"), CandidateSHA: cand, Pushed: true, Termination: true, Family: "claude", Account: "claude-a", Summary: "Keep the scroll position across a live swap.", Headline: "Kept the list's scroll position across a live swap.", Askable: true})
36 a.dispatched(wire.SpecialistChecks, sha("8"), cand, 0)
37 // Review reads a Woodstar change, the way Paul saw it.
38 wcand := "a91c3d0" + sha("d")[7:]
39 g.review, _ = a.galleryPushed("tp-w", "oficina/sample", "Swipe from the edge to go back on the Account pane", "Swiping in from the left edge on the Account pane should go back.", sha("1"), wcand, "Let the stack's pop gesture run beside the pane's.", true)
40 c := a.dispatched(wire.SpecialistChecks, sha("1"), wcand, 0)
41 a.checks("tp-w-c", c, wire.ChecksCannotRun, nil, "needs_macos", "")
42 rv := a.dispatched(wire.SpecialistReview, sha("1"), wcand, 0)
43 g.reviewStep = rv.StepID
44 a.step("tp-w-r-run", wire.StepReport{TaskID: g.review, StepID: rv.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: rv.BaseSHA, CandidateSHA: rv.CandidateSHA, Family: "claude", Account: "claude-a"})
45 for i, l := range teamRawLines {
46 l.TaskID, l.StepID, l.Attempt = g.review, rv.StepID, 1
47 a.activity("tp-act-"+itoa(i), l)
48 }
49 a.wait("review activity", func(c *Conversation) bool { return len(c.StepActivity[rv.StepID]) == len(teamRawLines) })
50 return g
51}
52
53// TestPagesTeamPanel: the compact rows and each specialist's page (the
54// drawer's content), from the thin core alone. Review at work: one row
55// of two lines (no inner card, no stage or attempt chip, no raw shell);
56// its page has the task linked, the activity in plain words with each
57// command behind a disclosure, the files touched, what it runs on, and
58// no Ask box (a running step's session cannot be asked). Engineering
59// idle: the one word on its row; its page lists its recent work and asks
60// about the task it finished.
61func TestPagesTeamPanel(t *testing.T) {
62 g := newTeamGallery(t)
63 a := g.a
64 owner := a.inst.Cookie()
65 rail := railOf(t, a.get(owner, "/tasks", 200))
66 row := regexp.MustCompile(`(?s)<a equipo-spec id="nav-review".*?</a>`).FindString(rail)
67 for _, want := range []string{`href="/team/review" data-team-open`, `data-state="working"`, "equipo-mark", "equipo-clock", `<span equipo-nav-task>Swipe from the edge to go back on the Account pane</span>`, `<span equipo-spec-doing>Looking over the changes</span>`} {
68 if !strings.Contains(row, want) {
69 t.Fatalf("Review row lacks %q: %s", want, row)
70 }
71 }
72 for _, not := range []string{"attempt", "In review", "Woodstar", "/bin/bash", "git diff", "<details", "equipo-spec-panel"} {
73 if strings.Contains(row, not) {
74 t.Fatalf("Review row shows %q: %s", not, row)
75 }
76 }
77 if n := strings.Count(row, "equipo-spec-now"); n != 1 {
78 t.Fatalf("Review row has %d second lines", n)
79 }
80 eng := regexp.MustCompile(`(?s)<a equipo-spec id="nav-engineering".*?</a>`).FindString(rail)
81 if !strings.Contains(eng, `data-state="idle"`) || !strings.Contains(eng, "<span equipo-spec-state>idle</span>") || strings.Contains(eng, "equipo-spec-now") || !strings.Contains(eng, `href="/team/engineering"`) {
82 t.Fatalf("idle Engineering row: %s", eng)
83 }
84
85 review := a.get(owner, "/team/review", 200)
86 for _, want := range []string{`<section equipo-team data-team="review" data-state="working"`, `<h1 id="team-title">Review</h1>`, `<a equipo-team-task href="/tasks/` + g.review + `">Swipe from the edge to go back on the Account pane</a>`,
87 "Looking over the changes", "Searching for interactivePopGestureRecognizer", "Reading AccountNavigationHost.swift", "Reading NavigationStack.swift",
88 `Command</summary><code>/bin/bash -lc &#34;cat ios/Woodstar/NavigationStack.swift&#34;</code></details>`,
89 `<li title="ios/Woodstar/NavigationStack.swift">`, "<span>AccountNavigationHost.swift</span>", "Runs on", `<dd><span equipo-conn-label data-conn-label="Claude (` + Owner + `)"><span equipo-pmark data-provider="claude" aria-hidden="true">Cl</span><span>Claude (` + Owner + `)</span></span></dd>`, "Shown when this step ends", "Recent work", `data-team-close hidden`} {
90 if !strings.Contains(review, want) {
91 t.Fatalf("Review's page lacks %q:\n%s", want, review)
92 }
93 }
94 // Newest first, and raw shell only inside the disclosures.
95 if strings.Index(review, "Looking over the changes") > strings.Index(review, "Reading NavigationStack.swift") {
96 t.Fatal("activity not newest first")
97 }
98 outside := regexp.MustCompile(`(?s)<details equipo-team-raw>.*?</details>`).ReplaceAllString(review, "")
99 for _, raw := range []string{"/bin/bash", "sed -n", "rg -n", "git diff"} {
100 if strings.Contains(outside, raw) {
101 t.Fatalf("raw shell %q outside the disclosure", raw)
102 }
103 }
104 if strings.Contains(review, "data-team-ask") {
105 t.Fatal("an Ask box on a running step, which cannot be asked")
106 }
107
108 engineering := a.get(owner, "/team/engineering", 200)
109 for _, want := range []string{`data-team="engineering" data-state="idle"`, "Recent work", `<a href="/tasks/` + g.running + `">Task list loses its scroll position after a refresh</a>`, "<p>Kept the list&#39;s scroll position across a live swap.</p>",
110 `<h2>Ask Engineering</h2>`, `About <a href="/tasks/` + g.running + `">`, `action="/tasks/` + g.running + `/ask"`, `name="specialist" value="engineering"`, "Ask Engineering about this work"} {
111 if !strings.Contains(engineering, want) {
112 t.Fatalf("Engineering's page lacks %q:\n%s", want, engineering)
113 }
114 }
115 if strings.Contains(engineering, "equipo-team-now") || strings.Contains(engineering, "answers once this step ends") {
116 t.Fatal("idle Engineering shown at work")
117 }
118 // Checks never answer questions.
119 if p := a.get(owner, "/team/checks", 200); strings.Contains(p, "data-team-ask") {
120 t.Fatal("an Ask box for Checks")
121 }
122 a.get(owner, "/team/product", 404)
123}
124
125// TestPagesTeamPanelAskWaits: a running specialist is asked only through
126// a session the runner kept, an earlier round's; the drawer says the
127// answer comes once this round ends.
128func TestPagesTeamPanelAskWaits(t *testing.T) {
129 r := newToolRig(t)
130 base, cand, cand2 := strings.Repeat("1", 40), strings.Repeat("2", 40), strings.Repeat("3", 40)
131 id, _ := r.pushed("w", "Fix the README typo", base, cand)
132 r.checks("w-c1", r.dispatched(wire.SpecialistChecks, base, cand, 0), wire.ChecksPassed, exit(0), "", "ok")
133 rv1 := r.dispatched(wire.SpecialistReview, base, cand, 0)
134 r.step("w-r1", wire.StepReport{TaskID: id, StepID: rv1.StepID, Attempt: 1, State: wire.StepDone, BaseSHA: base, CandidateSHA: cand, Termination: true, Family: "claude", Account: "claude-b", Verdict: wire.VerdictChanges, ReviewLabel: wire.ReviewSameFamily, Findings: []wire.Finding{{Text: "The second typo is still there.", Path: "README.md", Line: 7}}, Askable: true})
135 fix := r.dispatched(wire.SpecialistEngineering, cand, "", 1)
136 r.step("w-f-run", wire.StepReport{TaskID: id, StepID: fix.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: cand})
137 r.step("w-f-done", wire.StepReport{TaskID: id, StepID: fix.StepID, Attempt: 1, State: wire.StepDone, BaseSHA: cand, CandidateSHA: cand2, Pushed: true, Termination: true})
138 r.checks("w-c2", r.dispatched(wire.SpecialistChecks, base, cand2, 1), wire.ChecksPassed, exit(0), "", "ok")
139 rv2 := r.dispatched(wire.SpecialistReview, base, cand2, 1)
140 r.step("w-r2-run", wire.StepReport{TaskID: id, StepID: rv2.StepID, Attempt: 1, State: wire.StepRunning, BaseSHA: base, CandidateSHA: cand2})
141 page := r.get(r.inst.Cookie(), "/team/review", 200)
142 for _, want := range []string{`data-state="working"`, "<h2>Ask Review</h2>", `action="/tasks/` + id + `/ask"`, `name="specialist" value="review"`, "Review answers once this step ends, from its last finished round."} {
143 if !strings.Contains(page, want) {
144 t.Fatalf("Review's page lacks %q:\n%s", want, page)
145 }
146 }
147}
148