oficina / mapa Public

Review H1 and M5: browser gates for the column width, the scriptless desktop walk (L8) and the 650ms hold (L11)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Summary

Fable's Phase 1 review (6e3aa6b): the column keeps 576–672px and clears the Links panel at 1280 and 1440, scripts on and off; with scripts off at 1440 the sidebar folds to the rail and back by POST, the panel is drawn, the daily pill pages its month in the lead slot, the header renames, New team page and Make team page create; a POST (Pin) holds its spinner 650ms while the Links toggle switches at once.
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 41a79d881621e9eb70f24754e93e3cb84010ffab parent fec9c43
1 file changed, +194 −0
  • internal/mapatest/layout_browser_test.go +194 −0
diff --git a/internal/mapatest/layout_browser_test.go b/internal/mapatest/layout_browser_test.go
new file mode 100644
index 0000000..5729866
--- /dev/null
+++ b/internal/mapatest/layout_browser_test.go
@@ -0,0 +1,194 @@
+//go:build browser
+
+package mapatest
+
+import (
+ "strconv"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/rastrillo/rastrillo/harness"
+ "github.com/chromedp/chromedp"
+)
+
+// The level-up's layout and scriptless walk (spec §3, §4; Fable's Phase 1
+// review H1 and M5: gates L8 and L11), in real Chromium at desktop
+// widths.
+
+// firstTeamPage is a team page's path, read from All pages.
+func firstTeamPage(t *testing.T, rig *harness.Rig) string {
+ t.Helper()
+ drive(t, rig, chromedp.Navigate(rig.Origin+"/pages"),
+ chromedp.WaitVisible(`main a[href^="/p/"]`))
+ return read(t, rig, chromedp.AttributeValue(`main a[href^="/p/"]`,
+ "href")).Value
+}
+
+// columnGeometry is the page column's left, right and width, and the
+// Links panel's left (-1 when it is not drawn), in CSS pixels.
+const columnGeometry = `(function () {
+ var body = document.querySelector("article[mapa-body]");
+ var panel = document.querySelector("aside[mapa-links]");
+ var box = body.getBoundingClientRect();
+ var left = -1;
+ if (panel && getComputedStyle(panel).display !== "none") {
+ left = panel.getBoundingClientRect().left;
+ }
+ return [box.left, box.right, box.width, left].map(Math.round).join(",");
+})()`
+
+// H1: with the panel open, the column keeps its measure (36rem to 42rem
+// of text) and clears the panel, at 1280 and 1440, scripts on or off.
+func TestTheColumnClearsTheLinksPanel(t *testing.T) {
+ for _, live := range []bool{false, true} {
+ rig, _ := browserRig(t, 3)
+ path := firstTeamPage(t, rig)
+ for _, width := range []int64{1280, 1440} {
+ drive(t, rig, scripts(live), chromedp.EmulateViewport(width, 900),
+ chromedp.Navigate(rig.Origin+path),
+ chromedp.WaitVisible("article[mapa-body]"))
+ parts := strings.Split(read(t, rig,
+ chromedp.Evaluate[string](columnGeometry)), ",")
+ right, _ := strconv.Atoi(parts[1])
+ measure, _ := strconv.Atoi(parts[2])
+ panel, _ := strconv.Atoi(parts[3])
+ if measure < 576 || measure > 672 {
+ t.Errorf("%dpx: the column is %dpx wide", width, measure)
+ }
+ if panel < 0 || right > panel-16 {
+ t.Errorf("%dpx: column ends at %d, panel at %d", width,
+ right, panel)
+ }
+ }
+ }
+}
+
+// sideWidth is the sidebar's width in CSS pixels.
+const sideWidth = `Math.round(document.querySelector("[mapa-side]")` +
+ `.getBoundingClientRect().width)`
+
+// L8 at desktop width, scripts off: the sidebar folds to the rail and
+// back by its POST, the Links panel is drawn, a daily note's pill sits in
+// the lead slot and pages its months, the header renames, New team page
+// creates, and Make team page shares.
+func TestTheScriptlessDesktopWalk(t *testing.T) {
+ rig, _ := browserRig(t, 3)
+ path := firstTeamPage(t, rig)
+ drive(t, rig, scripts(false), chromedp.EmulateViewport(1440, 900),
+ chromedp.Navigate(rig.Origin+path),
+ chromedp.WaitVisible("aside[mapa-links]"))
+ if width := read(t, rig, chromedp.Evaluate[int](sideWidth)); width < 200 {
+ t.Fatalf("the open sidebar is %dpx", width)
+ }
+ drive(t, rig, press(`[mapa-fold-to="rail"]`),
+ chromedp.WaitVisible(`[mapa-app][data-side="rail"]`))
+ if width := read(t, rig, chromedp.Evaluate[int](sideWidth)); width > 60 {
+ t.Fatalf("the rail is %dpx", width)
+ }
+ drive(t, rig, press(`[mapa-fold-to="open"]`),
+ chromedp.WaitVisible(`[mapa-app][data-side="open"]`))
+ walkTheDay(t, rig)
+ walkRename(t, rig, path)
+ walkNewAndShare(t, rig)
+}
+
+// walkTheDay: the pill in the lead slot, and the month paged by link.
+func walkTheDay(t *testing.T, rig *harness.Rig) {
+ t.Helper()
+ drive(t, rig, chromedp.Navigate(rig.Origin+"/d/2026-11-12"),
+ chromedp.WaitVisible(`[estilo-bar-lead] nav[mapa-day]`),
+ chromedp.Click(`[estilo-bar-lead] [mapa-day-now]`),
+ chromedp.WaitVisible(`[estilo-bar-lead] [mapa-month]`),
+ chromedp.Click(`[estilo-bar-lead] a[aria-label="Next month"]`),
+ chromedp.WaitVisible(`[estilo-bar-lead] [mapa-month]`))
+ title := text(t, rig, `[estilo-bar-lead] [mapa-month-head] strong`)
+ if title != "December 2026" {
+ t.Fatalf("the paged month is %q", title)
+ }
+}
+
+// walkRename renames in the header: type, then Enter.
+func walkRename(t *testing.T, rig *harness.Rig, path string) {
+ t.Helper()
+ field := `[estilo-bar-title-input]`
+ drive(t, rig, chromedp.Navigate(rig.Origin+path),
+ chromedp.WaitVisible(field),
+ chromedp.SetValue(field, "Renamed in the header"),
+ chromedp.Submit(field))
+ // The rename answers with a redirect (to Update links, or back with
+ // done=renamed): wait for it to land before reading the page again.
+ for range 40 {
+ here := read(t, rig, chromedp.Location())
+ if strings.Contains(here, "/links") || strings.Contains(here, "done=") {
+ break
+ }
+ time.Sleep(50 * time.Millisecond)
+ }
+ drive(t, rig, chromedp.Navigate(rig.Origin+path),
+ chromedp.WaitVisible("h1[mapa-title]"))
+ if got := text(t, rig, "h1[mapa-title]"); got != "Renamed in the header" {
+ t.Fatalf("after the header rename the title is %q", got)
+ }
+}
+
+// walkNewAndShare creates a team page from the sidebar's popover, then
+// shares a scratch page's block as another (Make team page).
+func walkNewAndShare(t *testing.T, rig *harness.Rig) {
+ t.Helper()
+ drive(t, rig, chromedp.Navigate(rig.Origin+"/pages"),
+ chromedp.Click(`[mapa-new-page] > summary`),
+ chromedp.SendKeys(`#mapa-new-title`, "From the sidebar"),
+ chromedp.Submit(`#mapa-new-title`),
+ chromedp.WaitVisible("h1[mapa-title]"))
+ if got := text(t, rig, "h1[mapa-title]"); got != "From the sidebar" {
+ t.Fatalf("New team page made %q", got)
+ }
+ drive(t, rig, chromedp.Navigate(rig.Origin+"/scratch/new"),
+ chromedp.SendKeys(`main textarea[mapa-editor]`, "Share this."),
+ press(save), chromedp.WaitVisible("h1[mapa-title]"))
+ here := strings.TrimPrefix(read(t, rig, chromedp.Location()), rig.Origin)
+ drive(t, rig, chromedp.Navigate(rig.Origin+here+"/share"),
+ chromedp.SendKeys(`main input[name="title"]`, "Shared"),
+ chromedp.Click(`main input[name="block"]`),
+ chromedp.Submit(`main input[name="title"]`),
+ chromedp.WaitVisible("h1[mapa-title]"))
+ if got := text(t, rig, "h1[mapa-title]"); got != "Shared" {
+ t.Fatalf("Make team page made %q", got)
+ }
+}
+
+// heldFor is how long the last navigation took from the click that
+// started it (stamped in sessionStorage), in milliseconds.
+const heldFor = `Math.round(performance.timeOrigin - ` +
+ `Number(sessionStorage.getItem("mapa-clicked")))`
+
+// L11, the busy rule: a POST (Pin, here) holds its spinner for 650ms
+// before the page moves on; a view switch (Links) is immediate.
+func TestAPostHoldsAndAViewSwitchDoesNot(t *testing.T) {
+ rig, _ := browserRig(t, 3)
+ path := firstTeamPage(t, rig)
+ pin := `form[action$="/pin"] button`
+ drive(t, rig, scripts(true), chromedp.EmulateViewport(1440, 900),
+ chromedp.Navigate(rig.Origin+path),
+ chromedp.WaitVisible("aside[mapa-links]"),
+ chromedp.Click(`#mapa-menu-page > summary`))
+ read(t, rig, chromedp.Evaluate[any](
+ `sessionStorage.setItem("mapa-clicked",`+
+ ` String(performance.timeOrigin + performance.now()))`))
+ drive(t, rig, chromedp.Click(pin), chromedp.Sleep(100*time.Millisecond))
+ if busy := read(t, rig, chromedp.Evaluate[bool](
+ `!!document.querySelector('`+pin+`[aria-busy="true"]')`)); !busy {
+ t.Fatal("Pin shows no spinner")
+ }
+ drive(t, rig, chromedp.WaitVisible(`[mapa-side-page]`))
+ if held := read(t, rig, chromedp.Evaluate[int](heldFor)); held < 640 {
+ t.Fatalf("Pin's POST was held for %dms", held)
+ }
+ drive(t, rig, chromedp.Click(`[aria-controls="mapa-links"]`),
+ chromedp.Sleep(50*time.Millisecond))
+ if hidden := read(t, rig, chromedp.Evaluate[bool](
+ `document.getElementById("mapa-links").hidden`)); !hidden {
+ t.Fatal("the Links toggle did not switch at once")
+ }
+}