//go:build browser package thintest import ( "strconv" "testing" ) // TestBrowserMachines: the Machines screens at 1280 and 390. Nothing is // wider than the screen; Other people's machines opens on a click; a // row opens for its details; Revoke asks once more before its form // shows. On Add a machine, the machine that never connected comes // online in place when its runner connects, with no reload (the // person's stream through nav-stream.js). Saves the after shots when // EQUIPO_BROWSER_ARTIFACTS names a directory. func TestBrowserMachines(t *testing.T) { settled := func(p *innerPage) { p.wait(`document.getAnimations().every(a=>a.playState!=='running'||a.effect&&a.effect.getTiming().iterations===Infinity)`, "the page settled") } r := newMachinesRig(t) for i, size := range settingsSizes { w := strconv.FormatInt(size.w, 10) p := openInner(t, r.inst.URL, r.inst.Cookie(), size.w, size.h, size.touch, "light", "no-preference") p.open("/conversation/settings/machines") p.fits("machines") p.check(`!document.querySelector('[data-other-machines]').open && !document.querySelector('[data-other-machines] [data-machine]').checkVisibility()`, "others not folded") p.check(`[...document.querySelectorAll('[data-my-machines] [equipo-mach]')].every(d=>!d.open)`, "a row open unasked") p.check(`getComputedStyle(document.querySelector('[data-state="never"] [data-never-hint]')).display!=='none'`, "the never-connected hint is hidden") settled(p) p.shot("after-machines-" + w) p.check(`(document.querySelector('[data-other-machines] > summary').click(),document.querySelector('[data-other-machines]').open)`, "others do not open") never := `document.querySelector('[data-machine="` + r.never + `"]')` p.check(`(`+never+`.querySelector('summary').click(),`+never+`.open)`, "a row does not open") p.check(`!`+never+`.querySelector('[data-revoke]').checkVisibility()`, "Revoke posts without asking") p.check(`(`+never+`.querySelector('[equipo-mach-confirm] > summary').click(),`+never+`.querySelector('[data-revoke]').checkVisibility())`, "Revoke does not ask") p.fits("machines open") settled(p) p.shot("after-machines-open-" + w) p.open("/conversation/settings/machines/add") p.fits("add a machine") settled(p) p.shot("after-machines-add-" + w) if i == 0 { // The machine comes online on the page, which stays. p.check(never+`.dataset.state==='never'`, "not never connected first") r.dialWorker(r.neverToken, "Paul's MacBook Air", 0) p.wait(never+`&&`+never+`.dataset.state==='online'`, "the new machine online in place") p.stayed("machine online") settled(p) p.shot("after-machines-add-online-" + w) } p.stop() } }