//go:build browser package mapatest import ( "strings" "testing" "github.com/chromedp/chromedp" ) // The week strip's key, order and empty texts in a real browser (level-up // build note 82), with scripts off and on, then axe. func TestTheWeekKeyShowsWithScriptsOffAndOn(t *testing.T) { rig, _ := browserRig(t, 0) for _, on := range []bool{false, true} { drive(t, rig, scripts(on), chromedp.EmulateViewport(1440, 900), chromedp.Navigate(rig.Origin+"/d/2026-11-20"), chromedp.WaitVisible(`aside[mapa-links] p[mapa-week-key]`)) key := text(t, rig, `aside[mapa-links] p[mapa-week-key]`) for _, want := range []string{"Day shown", "Today", "A note you wrote"} { if !strings.Contains(key, want) { t.Fatalf("scripts %v: the key reads %q", on, key) } } order := read(t, rig, chromedp.Evaluate[string]( `Array.prototype.map.call(document.querySelectorAll( "#mapa-links-body > section > h2"), function (heading) { return heading.firstChild.textContent.trim(); }).join(" | ")`)) if order != "This week | Linked from | Links out" { t.Fatalf("scripts %v: the panel reads %q", on, order) } said := text(t, rig, `#mapa-links-body`) if !strings.Contains(said, "Nothing links to this day yet.") || !strings.Contains(said, "No links out yet.") { t.Fatalf("scripts %v: the empty lists read %q", on, said) } } if found := axeSerious(t, rig); found != "" { t.Fatalf("axe, a day with the key:\n%s", found) } }