//go:build browser package headless import ( "testing" "time" "amadan.net/oficina/equipo/internal/browsertest" ) // Paul, staging 71ce51b: the task receipt follows the task live, with no // reload: In progress, then the pushed branch and its short SHA, In // review while checks and review run, then what they found. Since slice // 4c Equipo merges a task whose checks passed and whose review approved, // so the receipt ends at Done, merged into main, with the link to the // repository; there is no merge for the person to make. func TestBrowserReceiptFollowsReview(t *testing.T) { _, inst, r := localEnv(t) r.start(t) c := inst.Cookie() p := openPage(t, inst.URL, c.Name, c.Value, 390, 844, false) defer p.stop() p.check(`(()=>{window.__nav=performance.getEntriesByType('navigation').length;return true})()`, "mark") 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") card := taskCard("Fix the README typo") stage := card + `?.querySelector('[equipo-stage]')?.textContent` p.run(browsertest.Wait(stage + `==='In progress'`)) // The step and the review each sleep 2.5 s on purpose: these waits are // on that work, so they get the window the rail drive gives it. 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)) 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)) 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)) p.check(`performance.getEntriesByType('navigation').length===window.__nav`, "the page reloaded") 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") } // Paul, staging: the sidebar reads the thin core and follows the stream. // While a step runs, Engineering says it is working on the task (linked) // and Tasks counts it; at 1280 and at 390 (inside the menu), no reload. // Then checks pass and Review approves, and Equipo merges it on its own // (slice 4c): the specialists go idle, Tasks stops counting it and // Needs you never does. func TestBrowserRailFollowsWork(t *testing.T) { for _, size := range []struct { w, h int64 touch bool }{{1280, 800, false}, {390, 844, true}} { _, inst, r := localEnv(t) r.start(t) c := inst.Cookie() p := openPage(t, inst.URL, c.Name, c.Value, size.w, size.h, !size.touch) p.check(`(()=>{window.__nav=performance.getEntriesByType('navigation').length;return true})()`, "mark") eng := `document.querySelector('#rail [data-specialist="engineering"]')` p.check(eng+`.dataset.state==='idle' && !document.querySelector('#nav-tasks [data-count]') && !document.querySelector('#rail [data-specialist="product"]')`, "idle sidebar") p.send("tool:record_task:oficina/sample|Slow sidebar change|x\ntool:start_task:$task|stepsleep:2500 edit:README.md|teh panes|the panes") 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'`)) // The step sleeps 2.5 s on purpose; on a loaded machine the // runner's report and the sidebar's swap need more than the 2.5 s // a 5 s wait leaves after it. p.run(browsertest.WaitWithin(`document.querySelector('#rail [data-specialist="engineering"]')?.dataset.state==='idle'`, 20*time.Second)) p.run(browsertest.WaitWithin(`document.querySelector('#rail [data-specialist="review"]')?.dataset.state==='idle' && !document.querySelector('#nav-tasks [data-count]')`, 20*time.Second)) p.check(`!document.querySelector('#nav-needs-you [data-count]')`, "a task Equipo merged on its own counts as needing the person") p.check(`performance.getEntriesByType('navigation').length===window.__nav`, "the page reloaded") p.stop() } }