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 thintest
4
5import (
6 "testing"
7 "time"
8)
9
10// TestBrowserSettingsStayOnPage: Paul, 2026-11-08: "Choosing a different
11// option in settings causes the sliding nav to repeat." Every Settings
12// change (Thinking words, Prefer, Pause and Resume, quiet hours) saves in
13// the background and shows a quiet Saved tick: no navigation, no page
14// swap or reveal, the shell and its nav untouched, at 1280 with a
15// mouse and 390 on touch. The server has each change.
16func TestBrowserSettingsStayOnPage(t *testing.T) {
17 r := newToolRig(t)
18 for _, size := range []struct {
19 w, h int64
20 touch bool
21 }{{1280, 900, false}, {390, 844, true}} {
22 p := openInner(t, r.inst.URL, r.inst.Cookie(), size.w, size.h, size.touch, "light", "no-preference")
23 mark := func() {
24 t.Helper()
25 p.check(`(()=>{window.__page=1;window.__rail=document.querySelector('#rail');window.__swapped=0;addEventListener('pageswap',()=>window.__swapped++);addEventListener('pagereveal',()=>window.__swapped++);return true})()`, "mark")
26 }
27 same := func(what string) {
28 t.Helper()
29 p.check(`window.__page===1 && window.__swapped===0 && document.querySelector('#rail')===window.__rail`, what+": the page or its nav was replaced")
30 p.stayed(what)
31 }
32 tick := func(section string) string {
33 return `!!document.querySelector('#` + section + ` [equipo-saved-tick][data-shown]:not([data-gone])')`
34 }
35
36 // Thinking words: picking a set saves it.
37 p.open("/conversation/settings/thinking")
38 mark()
39 p.check(`(()=>{document.querySelector('#thinking [data-set="terminal"] label').click();return true})()`, "pick Terminal")
40 p.wait(tick("thinking"), "Thinking words saved")
41 same("Thinking words")
42 if got, _ := r.client.Thinking(r.ctx); got.Set != "terminal" {
43 t.Fatalf("%d: thinking %s", size.w, got.Set)
44 }
45 // A second pick goes too: the form's revision moved on in place.
46 p.check(`(()=>{document.querySelector('#thinking [data-set="professional"] label').click();return true})()`, "pick Professional")
47 p.wait(`document.querySelector('#thinking input[value="professional"]').checked`, "picked")
48 p.waitFor(func() bool { got, _ := r.client.Thinking(r.ctx); return got.Set == "professional" }, "the second pick saved")
49 same("Thinking words again")
50
51 // Prefer, on Connections: the pressed choice moves in place.
52 p.open("/conversation/settings/connections")
53 mark()
54 p.check(`(()=>{const b=[...document.querySelectorAll('[data-section="connections"] [data-prefer]')].find(b=>b.getAttribute('aria-pressed')!=='true');window.__want=b.dataset.prefer;b.click();return true})()`, "Prefer")
55 p.wait(`document.querySelector('[data-section="connections"] [data-prefer="'+window.__want+'"]').getAttribute('aria-pressed')==='true' && !!document.querySelector('[data-section="connections"] [equipo-saved-tick][data-shown]:not([data-gone])')`, "Prefer saved")
56 same("Prefer")
57
58 // Pause and Resume, then quiet hours.
59 p.open("/conversation/settings/housekeeping")
60 mark()
61 p.click(`[data-hk-pause]`)
62 p.wait(`!!document.querySelector('[data-hk-status][data-paused] [data-hk-resume]') && `+tick("housekeeping"), "paused")
63 same("Pause")
64 if h := r.housekeeping(); !h.Paused {
65 t.Fatalf("%d: Pause did not take", size.w)
66 }
67 p.click(`[data-hk-resume]`)
68 p.wait(`!!document.querySelector('[data-hk-status]:not([data-paused]) [data-hk-pause]')`, "resumed")
69 p.check(`(()=>{for(const [s,v] of [['[data-hk-quiet-from]','21'],['[data-hk-quiet-until]','6']]){const e=document.querySelector(s);e.value=v;e.dispatchEvent(new Event('change',{bubbles:true}))}return true})()`, "hours")
70 p.click(`[data-savebar-save]`)
71 p.waitFor(func() bool { return r.housekeeping().Quiet.From == 21 && !r.housekeeping().Paused }, "quiet hours saved")
72 p.wait(tick("housekeeping"), "quiet hours tick")
73 same("quiet hours")
74 p.stop()
75 }
76}
77
78// waitFor polls a server-side condition.
79func (p *innerPage) waitFor(cond func() bool, what string) {
80 p.t.Helper()
81 for i := 0; i < 100; i++ {
82 if cond() {
83 return
84 }
85 time.Sleep(50 * time.Millisecond)
86 }
87 p.t.Fatalf("timed out waiting for %s", what)
88}
89
90// TestBrowserSettingsMenu: Paul, 2026-11-09: "settings could probably get
91// a submenu on mobile and its own menu sidebar on desktop". At 1280 the
92// Settings menu is a second sidebar beside the section, the current one
93// marked, the app's rail still there, and a section is a link away; at
94// 390 /conversation/settings is the menu as full-row drill-ins with
95// chevrons (eight with Copy and Places), and a section is its own page with Settings in its bar and no
96// menu. Light and dark; EQUIPO_BROWSER_ARTIFACTS keeps the shots.
97func TestBrowserSettingsMenu(t *testing.T) {
98 r := newToolRig(t)
99 for _, scheme := range []string{"light", "dark"} {
100 // Desktop.
101 p := openInner(t, r.inst.URL, r.inst.Cookie(), 1280, 900, false, scheme, "no-preference")
102 p.open("/conversation/settings/thinking")
103 // Two columns (Paul, 2026-11-10): the rail is the Settings nav.
104 p.check(`(()=>{const n=document.querySelector('[equipo-settings-rail]').getBoundingClientRect(),b=document.querySelector('[equipo-settings-body]').getBoundingClientRect();return n.width>150&&n.right<=b.left&&!document.querySelector('#rail').checkVisibility()&&!document.querySelector('[equipo-settings-nav]').checkVisibility()})()`, scheme+" 1280: the rail is not the Settings nav beside the section")
105 p.check(`(()=>{const c=document.querySelector('[equipo-settings-rail] [aria-current="page"]'),o=document.querySelector('[equipo-settings-rail] [data-rail-settings]:not([aria-current])');return c.dataset.railSettings==='thinking'&&getComputedStyle(c).backgroundColor!==getComputedStyle(o).backgroundColor})()`, scheme+" 1280: the current section is not marked")
106 p.check(`document.querySelector('[data-settings-leave]').checkVisibility()`, scheme+" 1280: no way back to Equipo")
107 p.wait(`document.getAnimations().every(a=>a.playState!=='running'||a.effect&&a.effect.getTiming().iterations===Infinity)`, "the slide settled")
108 p.shot("settings-menu-1280-" + scheme)
109 p.click(`[data-rail-settings="housekeeping"]`)
110 p.wait(`location.pathname==='/conversation/settings/housekeeping' && document.querySelector('[equipo-settings-rail] [aria-current="page"]').dataset.railSettings==='housekeeping' && !!document.querySelector('[data-hk-settings]')`, "Housekeeping from the menu")
111 p.click(`[data-rail-settings="connections"]`)
112 p.wait(`location.pathname==='/conversation/settings/connections' && !!document.querySelector('[equipo-settings-layout] [data-connections]')`, "Connections from the menu")
113 p.wait(`document.getAnimations().every(a=>a.playState!=='running'||a.effect&&a.effect.getTiming().iterations===Infinity)`, "the slide settled")
114 p.shot("settings-connections-1280-" + scheme)
115 p.stop()
116
117 // Phone.
118 q := openInner(t, r.inst.URL, r.inst.Cookie(), 390, 844, true, scheme, "no-preference")
119 q.open("/conversation/settings")
120 q.check(`(()=>{const ls=[...document.querySelectorAll('[equipo-settings-link]')];const body=document.querySelector('[equipo-settings-body]');return ls.length===9&&ls.every(a=>{const r=a.getBoundingClientRect();return r.height>=44&&r.width>=340&&getComputedStyle(a.querySelector('.icon:last-child')).display!=='none'})&&getComputedStyle(body).display==='none'&&document.documentElement.scrollWidth<=390})()`, scheme+" 390: the menu is not full-row drill-ins")
121 q.wait(`document.getAnimations().every(a=>a.playState!=='running'||a.effect&&a.effect.getTiming().iterations===Infinity)`, "the slide settled")
122 q.shot("settings-list-390-" + scheme)
123 q.click(`[data-settings-link="thinking"]`)
124 q.wait(`location.pathname==='/conversation/settings/thinking'`, "a section from the menu")
125 q.check(`(()=>{const back=document.querySelector('[rst-shell-back] a');const nav=document.querySelector('[equipo-settings-nav]');const h=document.querySelector('[equipo-settings-body] h1');return back.getAttribute('href')==='/conversation/settings'&&back.textContent.trim()==='Settings'&&getComputedStyle(nav).display==='none'&&!!h&&h.getBoundingClientRect().top>back.getBoundingClientRect().bottom-1&&document.documentElement.scrollWidth<=390})()`, scheme+" 390: a section has no way back to Settings or still shows the menu")
126 q.wait(`document.getAnimations().every(a=>a.playState!=='running'||a.effect&&a.effect.getTiming().iterations===Infinity)`, "the slide settled")
127 q.shot("settings-thinking-390-" + scheme)
128 q.click(`[rst-shell-back] a`)
129 q.wait(`location.pathname==='/conversation/settings' && getComputedStyle(document.querySelector('[equipo-settings-nav]')).display!=='none'`, "back to the menu")
130 q.open("/conversation/settings/housekeeping")
131 q.wait(`document.getAnimations().every(a=>a.playState!=='running'||a.effect&&a.effect.getTiming().iterations===Infinity)`, "the slide settled")
132 q.shot("settings-housekeeping-390-" + scheme)
133 q.open("/conversation/settings/places")
134 q.check(`(()=>{const h=document.querySelector('[equipo-settings-body] h1');return !!h&&!!document.querySelector('[equipo-places-empty]')&&document.documentElement.scrollWidth<=390})()`, scheme+" 390: the Places page is not one column with its empty line")
135 q.shot("settings-places-390-" + scheme)
136 q.stop()
137 }
138}
139
140// TestBrowserSettingsRail: Paul, 2026-11-10: "The settings nav should
141// probably replace the main nav on this view, right?" At 1280 Settings
142// is two columns: the rail itself turns into the Settings nav ("‹
143// Equipo", the sections, Add a connection under Connections and Add a
144// machine under Machines) with a
145// short slide as the person crosses in, and none between sections; "‹
146// Equipo" goes back to where they were, the main nav sliding back. The
147// rail does not move or resize. Under reduced motion nothing slides. At
148// 390 the drill-in stays: no Settings nav in the rail, the way back to
149// Settings in the bar.
150func TestBrowserSettingsRail(t *testing.T) {
151 r := newToolRig(t)
152 const settled = `document.getAnimations().every(a=>a.playState!=='running'||a.effect&&a.effect.getTiming().iterations===Infinity)`
153 const sliding = `(n=>!!n && n.hasAttribute('data-arriving') && n.getAnimations().length>0)`
154 p := openInner(t, r.inst.URL, r.inst.Cookie(), 1280, 900, false, "light", "no-preference")
155 p.open("/tasks")
156 p.check(`(()=>{sessionStorage.setItem('rail',JSON.stringify(document.querySelector('[rst-shell-rail]').getBoundingClientRect()));return document.querySelector('#rail').checkVisibility() && !document.querySelector('[equipo-settings-rail]')})()`, "1280: the main nav is not the rail outside Settings")
157 p.click(`#rail a[href="/conversation/settings"]`)
158 p.wait(`location.pathname==='/conversation/settings' && `+sliding+`(document.querySelector('[equipo-settings-rail]'))`, "the Settings nav slides in")
159 p.check(`(()=>{const was=JSON.parse(sessionStorage.getItem('rail')),now=document.querySelector('[rst-shell-rail]').getBoundingClientRect();const n=document.querySelector('[equipo-settings-rail]');const links=[...n.querySelectorAll('a')].map(a=>a.dataset.railSettings||'leave');return Math.abs(was.left-now.left)<1&&Math.abs(was.width-now.width)<1&&!document.querySelector('#rail').checkVisibility()&&links.join()==='leave,autonomy,thinking,connections,connections-add,machines,machines-add,housekeeping,copy,places,notebook,teams'&&n.querySelector('[data-settings-leave]').textContent.trim()==='Equipo'&&n.querySelector('[data-settings-leave]').getAttribute('href')==='/tasks'})()`, "1280: the rail moved, or is not ‹ Equipo and the sections, or ‹ Equipo does not lead back to Tasks")
160 p.check(`(()=>{const n=document.querySelector('[equipo-settings-rail]').getBoundingClientRect(),b=document.querySelector('[equipo-settings-body]').getBoundingClientRect();return n.right<=b.left&&b.left-n.right<120&&!document.querySelector('[equipo-settings-nav]').checkVisibility()})()`, "1280: Settings is not two columns")
161 p.wait(settled, "the slide settled")
162 p.shot("settings-rail-1280")
163 // Between sections nothing slides.
164 p.click(`[data-rail-settings="connections-add"]`)
165 p.wait(`location.pathname==='/conversation/settings/connections/add'`, "Add a connection from the rail")
166 p.check(`!document.querySelector('[data-arriving]') && document.querySelector('[equipo-settings-rail] [aria-current="page"]').dataset.railSettings==='connections-add'`, "1280: moving between sections slid, or Add a connection is not current")
167 p.shot("settings-rail-add-1280")
168 // ‹ Equipo: back to Tasks, the main nav sliding back.
169 p.click(`[data-settings-leave]`)
170 p.wait(`location.pathname==='/tasks' && `+sliding+`(document.querySelector('#rail'))`, "the main nav slides back")
171 p.stop()
172
173 // Reduced motion: the same swap, nothing slides.
174 q := openInner(t, r.inst.URL, r.inst.Cookie(), 1280, 900, false, "light", "reduce")
175 q.open("/conversation")
176 q.click(`#rail a[href="/conversation/settings"]`)
177 q.wait(`location.pathname==='/conversation/settings' && document.querySelector('[equipo-settings-rail]').checkVisibility()`, "Settings")
178 q.check(`document.querySelector('[equipo-settings-rail]').getAnimations().length===0 && document.querySelector('[data-settings-leave]').getAttribute('href')==='/conversation'`, "1280 reduced motion: the rail slid, or ‹ Equipo does not lead back")
179 q.stop()
180
181 // The phone keeps its drill-in.
182 m := openInner(t, r.inst.URL, r.inst.Cookie(), 390, 844, true, "light", "no-preference")
183 for _, path := range []string{"/conversation/settings", "/conversation/settings/connections", "/conversation/settings/connections/add"} {
184 m.open(path)
185 m.check(`!document.querySelector('[equipo-settings-rail]').checkVisibility() && document.documentElement.scrollWidth<=390`, "390: the Settings nav shows in the rail at "+path)
186 }
187 m.open("/conversation/settings")
188 m.check(`document.querySelector('[equipo-settings-nav]').checkVisibility()`, "390: the Settings menu is not the page")
189 m.wait(settled, "the slide settled")
190 m.shot("settings-rail-390")
191 m.stop()
192}
193