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 "fmt"
7 "testing"
8)
9
10// TestBrowserProjectsList: the Projects page at 1280 with a mouse and
11// 390 with touch. The key sits in the list's head at reading size, clear
12// of the list; the auto star's receipt and its filled star show; quiet
13// stars and Ask about this appear on hover with a mouse and always on
14// touch; a task row's status is text at line height, never a tall grey
15// box. With EQUIPO_BROWSER_ARTIFACTS set it saves projects-*.png.
16func TestBrowserProjectsList(t *testing.T) {
17 g := newGallery(t)
18 many, ids := newProjectsRig(t)
19 for _, size := range []struct {
20 w, h int64
21 touch bool
22 }{{1280, 900, false}, {390, 844, true}} {
23 p := openInner(t, g.a.inst.URL, g.a.inst.Cookie(), size.w, size.h, size.touch, "light", "reduce")
24 p.open("/projects")
25 p.fits("projects")
26 p.check(`!document.querySelector('[equipo-legend]')`, "the old legend is still under the list")
27 p.check(`[...document.querySelectorAll('[equipo-group]')].map(e=>e.dataset.group).join()==='starred,active'`, "groups")
28 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")
29 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")
30 if !size.touch {
31 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")
32 }
33 p.check(`!!document.querySelector('[data-star-receipt] [data-star-undo]')`, "no receipt")
34 on := `document.querySelector('[data-starred] [equipo-star] svg')`
35 p.check(`getComputedStyle(`+on+`).fill!=='none'`, "the star is not filled")
36 off := `document.querySelector('[equipo-prow]:not([data-starred]) [equipo-star]')`
37 if size.touch {
38 p.check(`getComputedStyle(`+off+`).opacity==='1'`, "quiet star hidden on touch")
39 } else {
40 p.check(`getComputedStyle(`+off+`).opacity==='0'`, "quiet star shown before hover")
41 p.check(`(()=>{`+off+`.focus();return true})()`, "focus star")
42 p.wait(`getComputedStyle(`+off+`).opacity==='1'`, "star shown on focus")
43 }
44 p.shot(fmt.Sprintf("projects-%d", size.w))
45
46 p.open("/tasks")
47 p.fits("tasks")
48 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")
49 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")
50 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")
51 p.shot(fmt.Sprintf("projects-tasks-%d", size.w))
52 p.open("/tasks?needs=you")
53 p.fits("needs")
54 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")
55 p.shot(fmt.Sprintf("projects-needs-%d", size.w))
56 p.stop()
57
58 // Ten projects: a filter, and the quiet ones folded until opened.
59 p = openInner(t, many.inst.URL, many.inst.Cookie(), size.w, size.h, size.touch, "light", "reduce")
60 p.open("/projects")
61 p.fits("many projects")
62 p.check(`!!document.querySelector('[equipo-p-filter] input[type="search"]') && !document.querySelector('[data-group="quiet"]').open`, "filter, or quiet open")
63 p.check(`!document.querySelector('[data-project="`+ids["P2"]+`"]').checkVisibility()`, "quiet rows showing while folded")
64 p.shot(fmt.Sprintf("projects-many-%d", size.w))
65 p.check(`(()=>{document.querySelector('[data-group="quiet"] > summary').click();return document.querySelector('[data-group="quiet"]').open})()`, "open quiet")
66 p.check(`document.querySelector('[data-project="`+ids["P2"]+`"]').checkVisibility()`, "quiet rows hidden when open")
67 p.fits("quiet open")
68 p.shot(fmt.Sprintf("projects-quiet-open-%d", size.w))
69 p.open("/projects?q=p3")
70 p.check(`document.querySelectorAll('[equipo-prow]').length===1`, "filter")
71 p.shot(fmt.Sprintf("projects-filtered-%d", size.w))
72 p.stop()
73 }
74}
75