| 1 | //go:build browser |
| 2 | |
| 3 | package thintest |
| 4 | |
| 5 | import ( |
| 6 | "fmt" |
| 7 | "os" |
| 8 | "testing" |
| 9 | ) |
| 10 | |
| 11 | // TestBrowserRosterAlignment holds the Roster stream's geometry at 1280 |
| 12 | // and 390, light and dark: reports are flat on a neutral rail, a report |
| 13 | // beside its decision is one compact line, the stage track spans the |
| 14 | // content with its label under its dot, bylines sit a fixed gap above |
| 15 | // what they introduce, the card composer matches the main one, and the |
| 16 | // last item clears the composer. testdata/roster-geometry.js measures. |
| 17 | func TestBrowserRosterAlignment(t *testing.T) { |
| 18 | src, err := os.ReadFile("testdata/roster-geometry.js") |
| 19 | if err != nil { |
| 20 | t.Fatal(err) |
| 21 | } |
| 22 | r := newAlignRig(t) |
| 23 | for _, width := range []int64{1280, 390} { |
| 24 | for _, scheme := range []string{"light", "dark"} { |
| 25 | t.Run(fmt.Sprintf("%d-%s", width, scheme), func(t *testing.T) { |
| 26 | p := openInner(t, r.inst.URL, r.inst.Cookie(), width, 844, width == 390, scheme, "reduce") |
| 27 | defer p.stop() |
| 28 | p.open("/conversation") |
| 29 | p.wait(`document.querySelector('[equipo-offline]').hidden && document.querySelector('[data-roster-enhanced]')`, "connected") |
| 30 | measure := func(phase string) { |
| 31 | t.Helper() |
| 32 | if bad := eval[string](p, fmt.Sprintf(`(%s)(%q, %t)`, src, phase, width == 390)); bad != "" { |
| 33 | t.Errorf("%s: %s", phase, bad) |
| 34 | } |
| 35 | } |
| 36 | measure("compact") |
| 37 | p.shot(fmt.Sprintf("roster-align-compact-%d-%s", width, scheme)) |
| 38 | p.click(`[equipo-card="merge"] [data-set-aside]`) |
| 39 | p.wait(`document.querySelector('[equipo-card="merge"] [equipo-aside-stub]') && document.querySelector('[equipo-roster-report] [data-track]')`, "full report") |
| 40 | measure("full") |
| 41 | p.shot(fmt.Sprintf("roster-align-full-%d-%s", width, scheme)) |
| 42 | p.fits("Roster alignment") |
| 43 | p.click(`[equipo-card="merge"] [equipo-aside-stub] [data-aside-undo]`) |
| 44 | p.wait(`document.querySelector('[equipo-card="merge"] [data-set-aside]')`, "restored") |
| 45 | }) |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |