//go:build browser package thintest import ( "fmt" "testing" ) // TestBrowserProjectsList: the Projects page at 1280 with a mouse and // 390 with touch. The key sits in the list's head at reading size, clear // of the list; the auto star's receipt and its filled star show; quiet // stars and Ask about this appear on hover with a mouse and always on // touch; a task row's status is text at line height, never a tall grey // box. With EQUIPO_BROWSER_ARTIFACTS set it saves projects-*.png. func TestBrowserProjectsList(t *testing.T) { g := newGallery(t) many, ids := newProjectsRig(t) for _, size := range []struct { w, h int64 touch bool }{{1280, 900, false}, {390, 844, true}} { p := openInner(t, g.a.inst.URL, g.a.inst.Cookie(), size.w, size.h, size.touch, "light", "reduce") p.open("/projects") p.fits("projects") p.check(`!document.querySelector('[equipo-legend]')`, "the old legend is still under the list") p.check(`[...document.querySelectorAll('[equipo-group]')].map(e=>e.dataset.group).join()==='starred,active'`, "groups") p.check(`(()=>{const k=document.querySelector('[equipo-key]'),lede=document.querySelector('[equipo-page-head] p');return getComputedStyle(k).fontSize===getComputedStyle(lede).fontSize})()`, "the key is not at reading size") p.check(`(()=>{const k=document.querySelector('[equipo-list-head]').getBoundingClientRect(),h=document.querySelector('[equipo-group] > h2').getBoundingClientRect();return h.top-k.bottom>=12})()`, "the key is tight to the list") if !size.touch { p.check(`(()=>{const k=document.querySelector('[equipo-key]').getBoundingClientRect(),l=document.querySelector('[equipo-rows]').getBoundingClientRect();return Math.abs(k.right-l.right)<=1})()`, "the key is not on the list's right") } p.check(`!!document.querySelector('[data-star-receipt] [data-star-undo]')`, "no receipt") on := `document.querySelector('[data-starred] [equipo-star] svg')` p.check(`getComputedStyle(`+on+`).fill!=='none'`, "the star is not filled") off := `document.querySelector('[equipo-prow]:not([data-starred]) [equipo-star]')` if size.touch { p.check(`getComputedStyle(`+off+`).opacity==='1'`, "quiet star hidden on touch") } else { p.check(`getComputedStyle(`+off+`).opacity==='0'`, "quiet star shown before hover") p.check(`(()=>{`+off+`.focus();return true})()`, "focus star") p.wait(`getComputedStyle(`+off+`).opacity==='1'`, "star shown on focus") } p.shot(fmt.Sprintf("projects-%d", size.w)) p.open("/tasks") p.fits("tasks") p.check(`[...document.querySelectorAll('[equipo-row] [equipo-chip]')].every(c=>c.getBoundingClientRect().height<=parseFloat(getComputedStyle(c).fontSize)*1.8 && getComputedStyle(c).backgroundColor==='rgba(0, 0, 0, 0)')`, "a task status is a tall grey box") p.check(`![...document.querySelectorAll('[equipo-group][data-group="needs"] [equipo-chip]')].some(c=>c.textContent.includes('Waiting for you'))`, "a Needs you row repeats its heading") p.check(`document.querySelectorAll('[equipo-trow]').length>0 && [...document.querySelectorAll('[equipo-trow]')].every(r=>!!r.querySelector('[equipo-trow-act] [equipo-menu] [equipo-ask-about]'))`, "Ask about this is not in every row's menu") p.shot(fmt.Sprintf("projects-tasks-%d", size.w)) p.open("/tasks?needs=you") p.fits("needs") p.check(`!!document.querySelector('[data-decision="`+g.unchecked+`"] [data-set-up-mac]') && !!document.querySelector('[data-decision="`+g.unchecked+`"] [data-ask-about]')`, "the Mac card's quiet links") p.shot(fmt.Sprintf("projects-needs-%d", size.w)) p.stop() // Ten projects: a filter, and the quiet ones folded until opened. p = openInner(t, many.inst.URL, many.inst.Cookie(), size.w, size.h, size.touch, "light", "reduce") p.open("/projects") p.fits("many projects") p.check(`!!document.querySelector('[equipo-p-filter] input[type="search"]') && !document.querySelector('[data-group="quiet"]').open`, "filter, or quiet open") p.check(`!document.querySelector('[data-project="`+ids["P2"]+`"]').checkVisibility()`, "quiet rows showing while folded") p.shot(fmt.Sprintf("projects-many-%d", size.w)) p.check(`(()=>{document.querySelector('[data-group="quiet"] > summary').click();return document.querySelector('[data-group="quiet"]').open})()`, "open quiet") p.check(`document.querySelector('[data-project="`+ids["P2"]+`"]').checkVisibility()`, "quiet rows hidden when open") p.fits("quiet open") p.shot(fmt.Sprintf("projects-quiet-open-%d", size.w)) p.open("/projects?q=p3") p.check(`document.querySelectorAll('[equipo-prow]').length===1`, "filter") p.shot(fmt.Sprintf("projects-filtered-%d", size.w)) p.stop() } }