oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1//go:build browser
2
3package headless
4
5import (
6 "testing"
7 "time"
8
9 "amadan.net/oficina/equipo/internal/browsertest"
10)
11
12// Paul, staging 71ce51b: the task receipt follows the task live, with no
13// reload: In progress, then the pushed branch and its short SHA, In
14// review while checks and review run, then what they found. Since slice
15// 4c Equipo merges a task whose checks passed and whose review approved,
16// so the receipt ends at Done, merged into main, with the link to the
17// repository; there is no merge for the person to make.
18func TestBrowserReceiptFollowsReview(t *testing.T) {
19 _, inst, r := localEnv(t)
20 r.start(t)
21 c := inst.Cookie()
22 p := openPage(t, inst.URL, c.Name, c.Value, 390, 844, false)
23 defer p.stop()
24 p.check(`(()=>{window.__nav=performance.getEntriesByType('navigation').length;return true})()`, "mark")
25 p.send("tool:record_task:oficina/sample|Fix the README typo|teh\ntool:start_task:$task|stepsleep:2500 reviewsleep:2500 edit:README.md|teh panes|the panes")
26 card := taskCard("Fix the README typo")
27 stage := card + `?.querySelector('[equipo-stage]')?.textContent`
28 p.run(browsertest.Wait(stage + `==='In progress'`))
29 // The step and the review each sleep 2.5 s on purpose: these waits are
30 // on that work, so they get the window the rail drive gives it.
31 p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;return !!c && c.querySelector('[equipo-stage]').textContent==='In review' && /^equipo\/tk[a-z0-9]+-fix-the-readme-typo$/.test(c.querySelector('[equipo-roster-facts] code').textContent) && !!c.querySelector('[data-open-amadan]')})()`, 20*time.Second))
32 p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;return c.querySelector('[data-verdict]')?.textContent==='Reviewing' && c.querySelector('[data-checks]')?.textContent==='Passed' && c.querySelector('[data-checks]').nextElementSibling.textContent==='make ci'})()`, 20*time.Second))
33 p.run(browsertest.WaitWithin(`(()=>{const c=`+card+`;const m=c.querySelector('[data-merged]');const a=m?.querySelector('[data-open-amadan]');return c.querySelector('[equipo-stage]').textContent==='Done' && c.querySelector('[data-verdict]').textContent==='Approved' && c.querySelector('[data-verdict]').nextElementSibling.textContent==='same family, same account' && !!m && /^Merged into main at [0-9a-f]{7}$/.test(m.querySelector('span').textContent) && !c.querySelector('[data-pushed]') && !!a && a.textContent==='Open on Amadan' && a.target==='_blank' && a.href.startsWith('https://amadan.net/oficina/sample')})()`, 20*time.Second))
34 p.check(`performance.getEntriesByType('navigation').length===window.__nav`, "the page reloaded")
35 p.check(`(()=>{const b=`+card+`.querySelector('[data-merged] [data-open-amadan]').getBoundingClientRect();return b.width>0 && b.height>0})()`, "the link to the merge is hidden")
36}
37
38// Paul, staging: the sidebar reads the thin core and follows the stream.
39// While a step runs, Engineering says it is working on the task (linked)
40// and Tasks counts it; at 1280 and at 390 (inside the menu), no reload.
41// Then checks pass and Review approves, and Equipo merges it on its own
42// (slice 4c): the specialists go idle, Tasks stops counting it and
43// Needs you never does.
44func TestBrowserRailFollowsWork(t *testing.T) {
45 for _, size := range []struct {
46 w, h int64
47 touch bool
48 }{{1280, 800, false}, {390, 844, true}} {
49 _, inst, r := localEnv(t)
50 r.start(t)
51 c := inst.Cookie()
52 p := openPage(t, inst.URL, c.Name, c.Value, size.w, size.h, !size.touch)
53 p.check(`(()=>{window.__nav=performance.getEntriesByType('navigation').length;return true})()`, "mark")
54 eng := `document.querySelector('#rail [data-specialist="engineering"]')`
55 p.check(eng+`.dataset.state==='idle' && !document.querySelector('#nav-tasks [data-count]') && !document.querySelector('#rail [data-specialist="product"]')`, "idle sidebar")
56 p.send("tool:record_task:oficina/sample|Slow sidebar change|x\ntool:start_task:$task|stepsleep:2500 edit:README.md|teh panes|the panes")
57 p.run(browsertest.Wait(eng + `?.dataset.state==='working' && ` + eng + `.querySelector('[equipo-nav-task]')?.textContent==='Slow sidebar change' && document.querySelector('#nav-tasks [data-count]')?.textContent==='1'`))
58 // The step sleeps 2.5 s on purpose; on a loaded machine the
59 // runner's report and the sidebar's swap need more than the 2.5 s
60 // a 5 s wait leaves after it.
61 p.run(browsertest.WaitWithin(`document.querySelector('#rail [data-specialist="engineering"]')?.dataset.state==='idle'`, 20*time.Second))
62 p.run(browsertest.WaitWithin(`document.querySelector('#rail [data-specialist="review"]')?.dataset.state==='idle' && !document.querySelector('#nav-tasks [data-count]')`, 20*time.Second))
63 p.check(`!document.querySelector('#nav-needs-you [data-count]')`, "a task Equipo merged on its own counts as needing the person")
64 p.check(`performance.getEntriesByType('navigation').length===window.__nav`, "the page reloaded")
65 p.stop()
66 }
67}
68