| 1 | //go:build browser |
| 2 | |
| 3 | package thintest |
| 4 | |
| 5 | import ( |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | // TestBrowserPhoneIndex: Paul, f2602d3, an iPhone in dark mode: "Vertical |
| 10 | // alignment of header and top borders are all over the place here." The |
| 11 | // phone's home screen (the sidebar as a page): no back strip above it; |
| 12 | // the team's name and the avatar on one centre line; every nav group |
| 13 | // drawn alike (a hairline on every side, one radius, one gap under its |
| 14 | // label); counts and the specialists' words in one column before the |
| 15 | // chevrons; the profile menu holds the person only, and Settings is in |
| 16 | // the nav. |
| 17 | func TestBrowserPhoneIndex(t *testing.T) { |
| 18 | g := newGallery(t) |
| 19 | p := openInner(t, g.a.inst.URL, g.a.inst.Cookie(), 390, 844, true, "dark", "reduce") |
| 20 | defer p.stop() |
| 21 | p.open("/work") |
| 22 | p.check(`(()=>{const b=document.querySelector('[equipo-team-index] > [rst-shell-back]');return !b || b.getBoundingClientRect().height===0})()`, "a back strip above the home screen") |
| 23 | mid := `(e=>{const r=e.getBoundingClientRect();return (r.top+r.bottom)/2})` |
| 24 | p.check(`(()=>{const m=`+mid+`;return Math.abs(m(document.querySelector('[equipo-team-heading] [rst-shell-brand]'))-m(document.querySelector('[rst-shell-profile] > summary')))<=1})()`, "the team's name and the avatar are not on one centre line") |
| 25 | // Counts and specialist words share one right edge. |
| 26 | p.check(`(()=>{const xs=[...document.querySelectorAll('#rail > a [equipo-count], #rail [equipo-spec-state]')].map(e=>Math.round(e.getBoundingClientRect().right));return xs.length>=4 && Math.max(...xs)-Math.min(...xs)<=1})()`, "counts and specialist words in different columns") |
| 27 | // Every group: its first row has a top hairline and the radius, its |
| 28 | // last row the radius, and every label sits the same gap above. |
| 29 | p.check(`(()=>{const nav=document.querySelector('#rail');const kids=[...nav.children].filter(e=>e.matches('a,[equipo-spec],[equipo-nav-group],[equipo-team-heading]'));const groups=[];let cur=null;for(const k of kids){if(k.matches('[equipo-nav-group],[equipo-team-heading]')){cur={label:k,rows:[]};groups.push(cur)}else if(cur){cur.rows.push(k)}} |
| 30 | const firsts=groups.filter(g=>g.rows.length).map(g=>getComputedStyle(g.rows[0]));const lasts=groups.filter(g=>g.rows.length).map(g=>getComputedStyle(g.rows[g.rows.length-1])); |
| 31 | const tops=firsts.every(s=>s.borderTopWidth==='1px' && s.borderTopLeftRadius===firsts[0].borderTopLeftRadius && parseFloat(s.borderTopLeftRadius)>0); |
| 32 | const bottoms=lasts.every(s=>s.borderBottomLeftRadius===firsts[0].borderTopLeftRadius); |
| 33 | const sides=[...nav.querySelectorAll(':scope > a, :scope > [equipo-spec]')].every(e=>{const s=getComputedStyle(e);return s.borderLeftWidth==='1px' && s.borderRightWidth==='1px'}); |
| 34 | const gaps=groups.slice(1).map(g=>Math.round(g.rows[0].getBoundingClientRect().top-g.label.getBoundingClientRect().bottom)); |
| 35 | return groups.length>=3 && tops && bottoms && sides && gaps.every(x=>x===gaps[0])})()`, "nav groups drawn differently") |
| 36 | p.check(`!!document.querySelector('#rail a[href="/conversation/settings"]')`, "no Settings in the nav") |
| 37 | p.check(`(()=>{const d=document.querySelector('[rst-shell-profile]');d.open=true;const links=[...d.querySelectorAll('a')].map(a=>a.getAttribute('href'));return !links.includes('/settings/thinking') && !!d.querySelector('form[action="/signout"]')})()`, "the profile menu holds more than the person") |
| 38 | p.shot("ux1-index-profile-390") |
| 39 | p.open("/conversation/settings") |
| 40 | p.check(`['thinking','connections','housekeeping','notebook','teams'].every(k=>!!document.querySelector('[equipo-settings-nav] [data-settings-link="'+k+'"]'))`, "Settings sections") |
| 41 | p.check(`(()=>{const nav=document.querySelector('[equipo-settings-nav] ul').getBoundingClientRect();return [...document.querySelectorAll('[equipo-settings-link]')].every(a=>a.tagName==='A'&&a.getBoundingClientRect().width>=nav.width-1)})()`, "Settings rows are not whole-row links") |
| 42 | p.shot("ux1-settings-390") |
| 43 | } |
| 44 | |