The bar's Search is the lens alone, with ⌘K in its tooltip
Paul, 2026-11-18: the header's Search can be a lens icon with ⌘K. It stays in the bar (a phone has no sidebar, and in rail mode the bar is where people look) and is now drawn by estilo's new Action.IconOnly: no visible word, "Search" its accessible name, aria-keyshortcuts "Meta+K Control+K", and "Search ⌘K" as its tooltip on hover and keyboard focus (rastrillo's rst-tip). It still opens ⌘K, and the search page with scripts off. On a touch screen it takes a tap anywhere in 44px. Below 800px the Menu sheet's row keeps the word and now shows ⌘K, as Fichas' does. History and Links are unchanged. Re-pin estilo 4d5b935 -> d004805: the icon-only action, plus desk (c1773e0), which Mapa does not use. Copy: Luna approved the name, the tooltip and the sheet row as drafted (copy-review/search-icon). Gates: search_icon_browser_test.go checks no visible text, the name, the shortcut, the tooltip on hover and on keyboard focus and whole on screen, ⌘K with scripts on and /search with them off, axe at 1440, 1000 and 800, L5 for the bar (scripts off against on, light and dark, no layout shift), and the 44px tap. Each was seen failing with IconOnly off and with estilo's hit area removed. TestAltBadgeShowsItsState's print check raced the field's own blur (2 runs in 8 failed on main 31289b3; this change made it lose every time): print hides the focused field, the blur closes it, and the check now takes gone as hidden. make ci and make browser green. Reviewed by Claude Fable across estilo, Mapa and Fichas: no High; the Mediums fixed; a delta review found no High or Medium. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Squashed from fix/search-icon into main.
7 files changed,
+295
−11
copy-review/search-icon/result.json+35 −0copy-review/search-icon/strings.json+26 −0go.mod+2 −2go.sum+2 −4internal/mapa/frame.go+10 −3internal/mapatest/images_alt_badge_browser_test.go+6 −2internal/mapatest/search_icon_browser_test.go+214 −0
CI passed — run details
CI log
=== editor ===
cd editor && npm ci --no-audit --no-fund --loglevel=error
added 16 packages in 320ms
cd editor && node build-bundles.mjs
wrote internal/mapa/static/editor.115ddee5d3f54787.js (354112 bytes, 111.2KB gzipped; L12 budget 120KB)
cd editor && node --test
✔ a badge is named for what it does, starting with its visible word (2.540431ms)
✔ first words stop at five words or forty characters (0.238301ms)
✔ the field keeps one trimmed line, without brackets (0.304112ms)
✔ the field holds at most MaxAlt bytes, cut at a character (0.512237ms)
✔ days and weeks move across months and years (1.270381ms)
✔ a month keeps the day, or takes the month's last (0.289586ms)
✔ the grid is six weeks from Monday, as the month calendar draws it (0.622371ms)
✔ the grid starts the week where the locale does (0.512258ms)
✔ the keys move a day, a week, a month and a year (0.250593ms)
✔ the picked day is the chip [[ makes for a date (14.894583ms)
✔ Insert → Today's date still puts today in at once (1.655683ms)
✔ / offers Date, the picker, and Today's date beside it (0.211612ms)
✔ after a ! the chip goes in after a space, never as an embed (2.072475ms)
✔ where the Markdown would read the chip differently, it is refused (1.98332ms)
✔ over a selection the chip goes after it and the words stay (2.744879ms)
✔ today is the day in the viewer's zone (13.885896ms)
✔ every offered locale has cases (1.715384ms)
✔ dates.mjs writes every date Go writes, byte for byte (5.442471ms)
✔ a chip, the month and the week, in three locales (0.58925ms)
✔ dates.json is what ICU gives, byte for byte (479.19022ms)
✔ L1: mounting then serialising gives cleanBody(body), byte for byte (88.58215ms)
ℹ 871 bodies
✔ L1: mounting a stored body adds nothing, and saving it writes nothing new (87.595306ms)
✔ L2: one edited block changes only that block's bytes; undo gives the body back (123.104624ms)
ℹ 858 single-block edits
✔ L2: inserting or deleting a block changes bytes only at the new seams, by Join (135.554464ms)
ℹ 866 inserts, 817 deletes
✔ L3: seeded edits keep the document and its Markdown saying the same thing (4625.177548ms)
ℹ 20904 edits over 871 bodies
✔ L3: Link to a page makes exactly one chip, and changes nothing else (1712.117647ms)
ℹ 4532 links over 871 bodies; refused: {"A page link can’t hold another link or a line break. Select plain words.":918,"A page link can’t show [ or ]]. Select words without them.":404,"Select some words to link them to a page.":174,"Linked here, the Markdown around these words would read differently: a ! before them makes an embed, and a stray ` or * pairs up. Select other words.":18}
✔ L3: a picked date is one more date chip, or refused where a letter would be too (1341.175509ms)
ℹ over 871 bodies: {"inserted":5158,"spaced":23,"refused":45,"unstable":9}
✔ linear: trailing spaces (34.043988ms)
✔ linear: trailing whitespace (24.251668ms)
✔ linear: unclosed web links (26.234416ms)
✔ linear: web links with no address (27.595094ms)
✔ linear: unclosed wiki links (21.951082ms)
✔ linear: unclosed embeds (24.074329ms)
✔ linear: closes only (4.0528ms)
✔ the selected words become the chip's shown text (11.751977ms)
✔ words that are the title make a plain [[Title]] (2.926446ms)
✔ spaces at the selection's edges stay outside the chip (1.056806ms)
✔ a date makes a date link, in a heading, an item and a quote (10.566944ms)
✔ bold words lose their bold: a chip carries no marks in Mapa's Markdown (1.040245ms)
✔ only the linked block's bytes change, and undo gives the body back (1.810861ms)
✔ a selection across blocks, over a chip or a break, or of brackets is refused (0.953865ms)
✔ a target the words cannot be linked to as typed is refused (0.203386ms)
✔ ⌘L: over a selection it opens Page link; with none it types [[; in code it does nothing (2.196385ms)
✔ web-linked words are refused: the address would be lost (review M4) (0.858529ms)
✔ words whose Markdown would read otherwise are refused (review M3) (1.401122ms)
✔ ⌘A then ⌘L says why, instead of doing nothing (review low 1) (0.339438ms)
✔ linkCheck says why it refuses (review low 2) (2.087102ms)
✔ golden file has bodies (1.026881ms)
✔ markup.mjs parses every body into Go's blocks, byte offsets and all (42.647068ms)
✔ markup.mjs strips and spans every block as Go does (56.677171ms)
✔ the schema's toDOM draws every body as Go renders it (58.561168ms)
✔ emphasis draws the four pinned outputs (18.833541ms)
✔ a body ends in the editor's empty paragraph (0.350278ms)
✔ the editor labels date chips as Go does, in every locale L4 holds (9.661769ms)
✔ a POST that never answers is aborted after the timeout (20.936042ms)
✔ a keepalive POST carries no signal, and an answer clears the timer (1.229686ms)
✔ autosave sends only what differs, and the tab owns the draft it wrote (10.524746ms)
✔ an offered draft never commits by itself; Save commits it (1.352283ms)
✔ reload, then close: sessionStorage says the draft is this tab's own (0.68094ms)
✔ closing carries text not yet sent, and the cap leaves it out (24.878077ms)
✔ clean rebase: applied, the caret survives, the base moves by the rebase POST (3.794612ms)
✔ the block under the caret is the teammate's too, and undo brings back yours (3.36111ms)
✔ typing mid-flight: the merge is not applied and the base does not move (0.969304ms)
✔ a merge the editor cannot represent stops after three tries (3.389703ms)
✔ a conflict is shown, locks the editor's own commits, and Resolve settles it (1.077674ms)
✔ leaving: a conflict stays with the choice; a failed flush offers Leave anyway; a stored draft leaves (1.581406ms)
✔ a stale tab shows the newer draft, offered, and never overwrites it (0.857397ms)
✔ the first scratch commit: empty creates nothing, then one page, then drafts on it (0.733918ms)
✔ noBase and gone lead to the existing choices (0.842359ms)
✔ a commit that merged is applied when nothing was typed since (0.99461ms)
✔ back from the cache: nothing unsaved reloads, unsaved text autosaves at once (6.83075ms)
✔ an own draft committed meanwhile goes on as a new draft (1.357412ms)
✔ a reload keeps a stored draft; unsent text still commits (0.575024ms)
✔ a page deleted mid-edit: what is typed is still stored as the draft, and nothing commits (H1) (1.179643ms)
✔ an offered draft committed in another tab: typing goes on as a new draft (H1) (11.336688ms)
✔ a commit reply without a revision is not a commit; an emptied day starts afresh (H2) (2.5024ms)
✔ Resolve stores what was typed first, and takes no typing until its answer is applied (M1) (2.033342ms)
✔ closing with a choice open, or commits held, still writes the text, never commits (M2) (0.966789ms)
✔ closing inside the settling window sends the loaded version with settling=1 (M3) (0.423865ms)
✔ a clean merge not applied because of typing still ends the choice on show (M4) (0.7565ms)
✔ settling finds the draft committed with a teammate's text: a close still writes (M-A) (0.423674ms)
✔ settling finds another tab's newer draft: the tab shows it before any typing (0.712338ms)
✔ a page deleted before the first autosave: the text is offered as a scratch page, and a close makes one (M-B) (0.526875ms)
✔ an autosave that never answered but landed: its 409 keeps the typing since (L3) (0.519691ms)
✔ marks: em outside strong, bold reopened around italics, edges outside (5.642071ms)
✔ marks close before code, links and atoms, and reopen after (0.485228ms)
✔ untouched blocks and atoms re-emit their source; edited atoms are written from attributes (7.855216ms)
✔ empty blocks are written as nothing (3.185795ms)
✔ an unclosed fence that is no longer last gets its closing fence (1.856375ms)
✔ the structure check puts Join's seam where a kept one would merge two blocks (2.373162ms)
✔ prepareSave adopts the parse when no seam or rewrite can save the document (13.300863ms)
✔ reparse: typed emphasis becomes a mark, "- " after a break becomes an item (3.43693ms)
✔ a trailing hard break stays on screen and is written as nothing (1.422342ms)
✔ the reparse waits while an IME is composing (1.623164ms)
✔ copied blocks paste with their bytes and seams; a cut and paste gives the body back (4.363885ms)
✔ a forged x-mapa slice is refused, and text from outside is read as Markdown (0.8001ms)
✔ rebuild changes origins only, outside undo history (2.50195ms)
✔ applyBody takes a teammate's block, keeps the caret, and ends untouched (2.411002ms)
✔ a block whose context changed is written again: a task toggled, a bullet, a quote (4.507631ms)
✔ a duplicate ^id typed above its holder never takes the id from it (1.684978ms)
✔ a copy-dragged block is reparsed, and says what its Markdown says (1.186746ms)
✔ a history command that throws is refused, never thrown (4.578302ms)
✔ an image re-emits its source, and an edited alt changes only its span (1.138918ms)
✔ a paste whose image copy is refused says why and pastes nothing (17.083012ms)
✔ a line of image openers reads in linear time (88.110607ms)
✔ a line of shared link address reads in linear time (14.426446ms)
✔ a line of shared web address reads in linear time (47.859766ms)
✔ one rename at a time, from either field (1.865192ms)
✔ an empty or unchanged title sends nothing (0.174713ms)
✔ a refusal keeps what was typed, and the title (0.217532ms)
✔ the pending state holds for the busy rule (9.687045ms)
✔ a failed POST says so and keeps the title (0.410229ms)
✔ Update links posts the confirm page's POST (0.274448ms)
✔ clean is CleanTitle's whitespace rule (0.109593ms)
✔ the saver's base follows a rename made over it, and only that (0.280408ms)
✔ closing sends the rename as one keepalive POST (2.265503ms)
✔ the port answers every shared case as typeddate.go does (6.747296ms)
✔ numbers follow the locale: 12/11 is November in en-IE, December in en-US (0.232811ms)
✔ M6: several files land in the order they were chosen (49.86679ms)
✔ M5: one Backspace before the box keeps the image where the box is (10.447032ms)
✔ M5: undoing text typed just before the box keeps the upload (12.85637ms)
✔ L12: a failed upload an undo takes away does not stall the next (14.810887ms)
✔ M4: Replace… keeps the old image until the new one is in, and its alt (13.937471ms)
✔ M3 and N1: text wins, except over a picture copied from a page (1.519682ms)
✔ N2: a JPEG over 10 MB is scaled before its size is checked (4.653512ms)
✔ a drag whose anchor the document no longer reaches selects to its end (5.086452ms)
ℹ tests 126
ℹ suites 0
ℹ pass 126
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 8262.860534
=== vet ===
go vet ./...
go vet -tags browser ./internal/mapatest/
=== fmt ===
=== code ===
go tool rastrillo budget code
The base has no .rastrillo/code.txt: skipping the check that records only go down.
budget code: within the limits.
=== test ===
CGO_ENABLED=0 go test ./...
? amadan.net/oficina/mapa/cmd/mapa [no test files]
ok amadan.net/oficina/mapa/internal/mapa 3.282s
? amadan.net/oficina/mapa/internal/mapa/icons [no test files]
ok amadan.net/oficina/mapa/internal/mapa/imagefile (cached)
ok amadan.net/oficina/mapa/internal/mapa/locale (cached)
ok amadan.net/oficina/mapa/internal/mapa/markup (cached)
ok amadan.net/oficina/mapa/internal/mapa/notionmd (cached)
ok amadan.net/oficina/mapa/internal/mapa/seal (cached)
ok amadan.net/oficina/mapa/internal/mapatest 13.148s
? amadan.net/oficina/mapa/scripts/mutate [no test files]
? amadan.net/oficina/mapa/scripts/preview [no test files]
=== migration-check ===
go tool rastrillo migration check
rastrillo migration check: models and migrations agree
=== credits-check ===
python3 scripts/credits.py --check
credits: checked
diff --git a/copy-review/search-icon/result.json b/copy-review/search-icon/result.json| new file mode 100644 |
| index 0000000..9753094 |
| --- /dev/null |
| +++ b/copy-review/search-icon/result.json |
| @@ -0,0 +1,35 @@ |
| +{ |
| + "action": "approve", |
| + "guidance": null, |
| + "note": "Reviewed 2026-11-18 by Luna (gpt-5.6-luna through Codex, ephemeral), the copy-review gate for Oficina copy since Paul's delegation of 2026-11-17, briefed with Paul's house rules from CARLOS platform's LUNA-COPY-BRIEF-stateless-replicas-4.md. Luna approved every string as drafted, with no edits and no flags.", |
| + "strings": [ |
| + { |
| + "id": "bar.search.name", |
| + "text": "Search", |
| + "original": "Search", |
| + "edited": false, |
| + "rerolled": false, |
| + "rerolls": [], |
| + "done": true |
| + }, |
| + { |
| + "id": "bar.search.tooltip", |
| + "text": "Search ⌘K", |
| + "original": "Search ⌘K", |
| + "edited": false, |
| + "rerolled": false, |
| + "rerolls": [], |
| + "done": true |
| + }, |
| + { |
| + "id": "sheet.search", |
| + "text": "Search ⌘K", |
| + "original": "Search ⌘K", |
| + "edited": false, |
| + "rerolled": false, |
| + "rerolls": [], |
| + "done": true |
| + } |
| + ], |
| + "flags": "none" |
| +} |
diff --git a/copy-review/search-icon/strings.json b/copy-review/search-icon/strings.json| new file mode 100644 |
| index 0000000..c20f5f9 |
| --- /dev/null |
| +++ b/copy-review/search-icon/strings.json |
| @@ -0,0 +1,26 @@ |
| +[ |
| + { |
| + "id": "bar.search.name", |
| + "section": "The bar", |
| + "label": "Search's accessible name", |
| + "text": "Search", |
| + "context": "The header's Search is now the lens icon alone; this is its aria-label. The shortcut is aria-keyshortcuts (Meta+K Control+K), not part of the name.", |
| + "notes": "Unchanged wording; it was the visible label." |
| + }, |
| + { |
| + "id": "bar.search.tooltip", |
| + "section": "The bar", |
| + "label": "Search's tooltip", |
| + "text": "Search ⌘K", |
| + "context": "Shown on hover and keyboard focus over the lens: the name, a space, and the shortcut as the app writes it elsewhere.", |
| + "notes": "New." |
| + }, |
| + { |
| + "id": "sheet.search", |
| + "section": "The bar", |
| + "label": "The Menu sheet's Search row", |
| + "text": "Search ⌘K", |
| + "context": "Below 800px the header's actions are rows in the Menu sheet; the row keeps the word and now shows the shortcut, as Fichas' does.", |
| + "notes": "The ⌘K is new in Mapa." |
| + } |
| +] |
diff --git a/go.mod b/go.mod| index 0456d08..897ff0c 100644 |
| --- a/go.mod |
| +++ b/go.mod |
| @@ -5,7 +5,8 @@ go 1.26.0 |
| toolchain go1.26.11 |
| require ( |
| - amadan.net/oficina/estilo.git v0.0.0-20261114124532-4d5b9357d49e |
| + amadan.net/oficina/estilo.git v0.0.0-20261118055615-d004805f40f2 |
| + amadan.net/oficina/notion.git v0.0.0-20261117112255-7eb9a9e888cb |
| amadan.net/rastrillo/rastrillo v0.35.1-0.20261116213651-96812beacacc |
| github.com/chromedp/cdproto v0.158.6 |
| github.com/chromedp/chromedp v0.21.0 |
| @@ -17,7 +18,6 @@ require ( |
| ) |
| require ( |
| - amadan.net/oficina/notion.git v0.0.0-20261117112255-7eb9a9e888cb // indirect |
| amadan.net/rastrillo/fiesta v1.3.0 // indirect |
| amadan.net/rastrillo/rastrillo/money v0.1.0 // indirect |
| github.com/BurntSushi/toml v1.6.0 // indirect |
diff --git a/go.sum b/go.sum| index c65c9bd..1947ca5 100644 |
| --- a/go.sum |
| +++ b/go.sum |
| @@ -1,7 +1,5 @@ |
| -amadan.net/oficina/estilo.git v0.0.0-20261114124532-4d5b9357d49e h1:GbRhuszEtwy3/iPHZ0gQ8avgduS/r/WNtw8gBsuRKkk= |
| -amadan.net/oficina/estilo.git v0.0.0-20261114124532-4d5b9357d49e/go.mod h1:2UFIFrbTrhew8EFM0C94WmTo2OASM2pHEgT4jzeE/s8= |
| -amadan.net/oficina/notion.git v0.0.0-20261117101339-994983fb0c8f h1:P733ZMOI5jvgodbnJxsqUkZfe6ydUQ0vpunEI2bwRpg= |
| -amadan.net/oficina/notion.git v0.0.0-20261117101339-994983fb0c8f/go.mod h1:2WuyjBTLHwurTGri00zfPxSKc9b3pomdT6wSs/UIvA4= |
| +amadan.net/oficina/estilo.git v0.0.0-20261118055615-d004805f40f2 h1:E2+IhBdGcjhX3IX8UgQj5t6Bu+4zkGG0J+W1CIeoTAo= |
| +amadan.net/oficina/estilo.git v0.0.0-20261118055615-d004805f40f2/go.mod h1:2UFIFrbTrhew8EFM0C94WmTo2OASM2pHEgT4jzeE/s8= |
| amadan.net/oficina/notion.git v0.0.0-20261117112255-7eb9a9e888cb h1:P1KhTWoKSfvm+v2rwcEqnfwsftrrpZRjEe1zoJvwceQ= |
| amadan.net/oficina/notion.git v0.0.0-20261117112255-7eb9a9e888cb/go.mod h1:2WuyjBTLHwurTGri00zfPxSKc9b3pomdT6wSs/UIvA4= |
| amadan.net/rastrillo/fiesta v1.3.0 h1:7SsHw4aeWPLStR3RHFEEtX4CwqKu+Ig3PgNX8FvD8WM= |
diff --git a/internal/mapa/frame.go b/internal/mapa/frame.go| index fe095a9..127d275 100644 |
| --- a/internal/mapa/frame.go |
| +++ b/internal/mapa/frame.go |
| @@ -119,6 +119,12 @@ func leadFor(page *pageChrome) leadView { |
| Status: page.Editor || page.Writable, Day: page.Day} |
| } |
| +// searchAction is the bar's Search: a link to the search page, which |
| +// mapa.js turns into ⌘K. |
| +var searchAction = chrome.Action{Item: menu.Item{Href: "/search", |
| + Label: "Search", Key: "⌘K"}, Icon: iconHTML("search"), IconOnly: true, |
| + KeyShortcuts: "Meta+K Control+K"} |
| + |
| // placesNav is the sidebar's places as the bar's nav. estilo shows them |
| // as rows in the Menu sheet below 800px, where there is no sidebar; |
| // mapa.css hides the bar's own copy from 800px, where the sidebar is. |
| @@ -132,10 +138,11 @@ func placesNav(items []NavItem) []chrome.Link { |
| } |
| // barActions are Search, History and Links (§3.1). History needs a page |
| -// with history; Links, a screen with the panel. |
| +// with history; Links, a screen with the panel. Search is the lens alone |
| +// in the bar (Paul, 2026-11-18): "Search" is its name, "Search ⌘K" its |
| +// tooltip, and the Menu sheet's row keeps the word. |
| func barActions(page *view) []chrome.Action { |
| - actions := []chrome.Action{{Item: menu.Item{Href: "/search", |
| - Label: "Search"}, Icon: iconHTML("search")}} |
| + actions := []chrome.Action{searchAction} |
| chromeOf := page.Chrome |
| if chromeOf != nil && chromeOf.Page != nil && chromeOf.Page.ID != 0 { |
| actions = append(actions, chrome.Action{Item: menu.Item{ |
diff --git a/internal/mapatest/images_alt_badge_browser_test.go b/internal/mapatest/images_alt_badge_browser_test.go| index 388d7fd..ff375d1 100644 |
| --- a/internal/mapatest/images_alt_badge_browser_test.go |
| +++ b/internal/mapatest/images_alt_badge_browser_test.go |
| @@ -97,8 +97,12 @@ func printed(t *testing.T, rig *harness.Rig) { |
| got, "shown") { |
| t.Fatalf("a badge shows in print:\n%s", got) |
| } |
| - if read(t, rig, chromedp.Evaluate[string](`getComputedStyle( |
| - document.querySelector('[mapa-alt]')).display`)) != "none" { |
| + // Print hides the field, and a focused field hidden loses focus, |
| + // which closes it: gone is as good as hidden. Reading it as though |
| + // it stayed raced that blur (2 runs in 8 failed on main 31289b3). |
| + if read(t, rig, chromedp.Evaluate[string](`(function (field) { |
| + return field ? getComputedStyle(field).display : "none"; |
| +})(document.querySelector('[mapa-alt]'))`)) != "none" { |
| t.Fatal("the open field shows in print") |
| } |
| } |
diff --git a/internal/mapatest/search_icon_browser_test.go b/internal/mapatest/search_icon_browser_test.go| new file mode 100644 |
| index 0000000..e895833 |
| --- /dev/null |
| +++ b/internal/mapatest/search_icon_browser_test.go |
| @@ -0,0 +1,214 @@ |
| +//go:build browser |
| + |
| +package mapatest |
| + |
| +import ( |
| + "encoding/json" |
| + "fmt" |
| + "testing" |
| + |
| + "amadan.net/rastrillo/rastrillo/harness" |
| + "github.com/chromedp/chromedp" |
| + "github.com/chromedp/chromedp/kb" |
| +) |
| + |
| +// The header's Search is the lens alone (Paul, 2026-11-18): no visible |
| +// word, "Search" its accessible name, its shortcut aria-keyshortcuts, |
| +// "Search ⌘K" its tooltip on hover and on focus, whole on screen. It |
| +// still opens ⌘K, and the search page with scripts off; it moves |
| +// nothing as the page loads (L5); axe finds nothing serious; and on a |
| +// touch screen a tap lands on it anywhere in 44px. |
| + |
| +// barSearch is the header's Search, on screen from 800px. |
| +const barSearch = `[estilo-bar-actions] a[href="/search"]` |
| + |
| +// searchFacts is what the header's Search shows and says. Tip is |
| +// whether its tooltip can be hit at each edge: the tooltip takes |
| +// pointer events for the moment it is asked, so a box laid out but cut |
| +// off fails. |
| +const searchFacts = `(function () { |
| + var a = document.querySelector(%q), box = a.getBoundingClientRect(); |
| + var tip = getComputedStyle(a, "::after"); |
| + var probe = document.createElement("style"); |
| + probe.textContent = "[estilo-bar-icon]::after { " + |
| + "pointer-events: auto !important; transition: none !important; }"; |
| + document.head.appendChild(probe); |
| + // The tooltip's border box: rst-tip hangs it 6px under the control, |
| + // its end on the control's end. The middle of each edge, 2px in (the |
| + // corners are rounded), must be the tooltip's. |
| + var pad = function (side) { return parseFloat(tip["padding" + side]); }; |
| + var content = tip.boxSizing !== "border-box"; |
| + var width = parseFloat(tip.width) + |
| + (content ? pad("Left") + pad("Right") : 0); |
| + var height = parseFloat(tip.height) + |
| + (content ? pad("Top") + pad("Bottom") : 0); |
| + var right = box.right, top = box.bottom + 6, left = right - width; |
| + var misses = isFinite(width) && isFinite(height) ? [] : |
| + ["no tooltip box"]; |
| + if (!misses.length) [[left + width / 2, top + 2], |
| + [left + width / 2, top + height - 2], [left + 2, top + height / 2], |
| + [right - 2, top + height / 2] |
| + ].forEach(function (p) { |
| + if (!a.contains(document.elementFromPoint(p[0], p[1]))) { |
| + misses.push(Math.round(p[0]) + "," + Math.round(p[1])); |
| + } |
| + }); |
| + probe.remove(); |
| + return JSON.stringify({Text: a.innerText.trim(), |
| + Name: a.getAttribute("aria-label"), |
| + Keys: a.getAttribute("aria-keyshortcuts"), |
| + Tip: tip.content, Shown: tip.opacity, Misses: misses.join(" "), |
| + Width: box.width, Height: box.height}); |
| +})()` |
| + |
| +type searchShows struct { |
| + Text, Name, Keys, Tip, Shown, Misses string |
| + Width, Height float64 |
| +} |
| + |
| +func showsOf(t *testing.T, rig *harness.Rig) searchShows { |
| + t.Helper() |
| + var got searchShows |
| + raw := read(t, rig, chromedp.Evaluate[string]( |
| + fmt.Sprintf(searchFacts, barSearch))) |
| + if err := json.Unmarshal([]byte(raw), &got); err != nil { |
| + t.Fatal(err) |
| + } |
| + return got |
| +} |
| + |
| +func TestTheBarsSearchIsTheLensAlone(t *testing.T) { |
| + rig, _ := browserRig(t, 1, harness.WithHover()) |
| + path := firstTeamPage(t, rig) |
| + for _, width := range []int64{1440, 1000, 800} { |
| + drive(t, rig, scripts(true), chromedp.EmulateViewport(width, 900), |
| + chromedp.Navigate(rig.Origin+path), |
| + chromedp.WaitVisible(barSearch)) |
| + got := showsOf(t, rig) |
| + if got.Text != "" || got.Name != "Search" || |
| + got.Keys != "Meta+K Control+K" || got.Tip != `"Search ⌘K"` { |
| + t.Errorf("%dpx: the bar's Search is %+v", width, got) |
| + } |
| + if got.Width != got.Height || got.Width < 24 { |
| + t.Errorf("%dpx: the lens is %vx%v, not a square of at least 24px", |
| + width, got.Width, got.Height) |
| + } |
| + if got.Shown != "0" { |
| + t.Errorf("%dpx: the tooltip shows at rest (opacity %s)", |
| + width, got.Shown) |
| + } |
| + drive(t, rig, rest(barSearch), chromedp.Sleep(200e6)) |
| + if got := showsOf(t, rig); got.Shown != "1" || got.Misses != "" { |
| + t.Errorf("%dpx: on hover the tooltip is at opacity %s, "+ |
| + "cut off at %q", width, got.Shown, got.Misses) |
| + } |
| + // Keyboard focus, reached by keys (Shift+Tab off the lens and |
| + // Tab back), so :focus-visible holds as it does for a person. |
| + drive(t, rig, rest("main"), chromedp.Focus(barSearch), |
| + chromedp.KeyEvent(kb.Tab, |
| + chromedp.KeyModifiers(chromedp.ModifierShift)), |
| + chromedp.KeyEvent(kb.Tab), chromedp.Sleep(200e6)) |
| + if !read(t, rig, chromedp.Evaluate[bool]( |
| + `document.querySelector('`+barSearch+ |
| + `').matches(":focus-visible")`)) { |
| + t.Fatalf("%dpx: the lens did not take keyboard focus", width) |
| + } |
| + if got := showsOf(t, rig); got.Shown != "1" { |
| + t.Errorf("%dpx: on focus the tooltip is at opacity %s", |
| + width, got.Shown) |
| + } |
| + if found := axeSerious(t, rig); found != "" { |
| + t.Errorf("%dpx: axe:\n%s", width, found) |
| + } |
| + } |
| + |
| + // The same action as before: ⌘K with scripts, the page without. |
| + drive(t, rig, rest("main"), scripts(true), |
| + chromedp.EmulateViewport(1280, 900), |
| + chromedp.Navigate(rig.Origin+path), chromedp.WaitVisible(barSearch), |
| + press(barSearch), chromedp.WaitVisible("dialog[mapa-palette] input")) |
| + drive(t, rig, scripts(false), chromedp.Navigate(rig.Origin+path), |
| + chromedp.WaitVisible(barSearch), press(barSearch), |
| + chromedp.WaitVisible(`main input[name="q"]`)) |
| + at := read(t, rig, chromedp.Evaluate[string](`location.pathname`)) |
| + if at != "/search" { |
| + t.Errorf("with scripts off the lens went to %s", at) |
| + } |
| + |
| + // Below 800px the actions are the Menu sheet's rows, which keep the |
| + // word, and show the shortcut. (The sheet's places, Mapa's nav, come |
| + // first and hold their own Search, as they did before.) |
| + drive(t, rig, scripts(true), chromedp.EmulateViewport(390, 844), |
| + chromedp.Navigate(rig.Origin+path), |
| + chromedp.WaitVisible("[estilo-bar-more] > summary")) |
| + row := read(t, rig, chromedp.Evaluate[string]( |
| + `Array.prototype.map.call(document.querySelectorAll( |
| + '[estilo-menu="sheet"] a[href="/search"]'), |
| + function (a) { return a.textContent; }).pop()`)) |
| + if row != "Search⌘K" { |
| + t.Errorf("the Menu sheet's Search row reads %q", row) |
| + } |
| +} |
| + |
| +// L5 for the header: the lens and every control beside it are where the |
| +// server drew them (scripts off) once the page has mounted, and no |
| +// layout shift is recorded from the start of the load, light and dark. |
| +func TestTheBarsSearchMovesNothing(t *testing.T) { |
| + rig, _ := browserRig(t, 1) |
| + path := firstTeamPage(t, rig) |
| + drive(t, rig, onNewDocument(shiftRecorder)) |
| + const bar = `JSON.stringify(Array.prototype.map.call( |
| + document.querySelectorAll("[estilo-bar-end] > *, " + |
| + "[estilo-bar-actions] a, [estilo-bar-actions] button"), |
| + function (el) { var b = el.getBoundingClientRect(); |
| + return [el.nodeName, b.left, b.top, b.width, b.height].join(" "); }))` |
| + for _, dark := range []bool{false, true} { |
| + for _, width := range []int64{1440, 1000} { |
| + load := func(live bool) string { |
| + drive(t, rig, scripts(live), |
| + chromedp.EmulateViewport(width, 900), colorScheme(dark), |
| + chromedp.Navigate(rig.Origin+path), |
| + chromedp.WaitVisible(barSearch), chromedp.Sleep(300e6)) |
| + return read(t, rig, chromedp.Evaluate[string](bar)) |
| + } |
| + off, on := load(false), load(true) |
| + if off != on { |
| + t.Errorf("%dpx dark=%v: the bar moved once scripts "+ |
| + "ran:\noff %s\non %s", width, dark, off, on) |
| + } |
| + if shifts := read(t, rig, chromedp.Evaluate[string]( |
| + `JSON.stringify(window.__shifts || [])`)); shifts != "[]" { |
| + t.Errorf("%dpx dark=%v: layout shifts %s", width, dark, shifts) |
| + } |
| + } |
| + } |
| +} |
| + |
| +// On a touch screen the lens is drawn as the other controls are and |
| +// takes a tap anywhere in 44px around its centre. |
| +func TestTheBarsSearchTakesATouchIn44px(t *testing.T) { |
| + rig, _ := browserRig(t, 1, harness.WithCoarsePointer()) |
| + path := firstTeamPage(t, rig) |
| + drive(t, rig, chromedp.EmulateViewport(1024, 768), |
| + chromedp.Navigate(rig.Origin+path), chromedp.WaitVisible(barSearch)) |
| + if !read(t, rig, chromedp.Evaluate[bool]( |
| + `matchMedia("(pointer: coarse)").matches`)) { |
| + t.Fatal("the page does not see a coarse pointer") |
| + } |
| + misses := read(t, rig, chromedp.Evaluate[string](`(function () { |
| + var a = document.querySelector('`+barSearch+`'); |
| + var b = a.getBoundingClientRect(), misses = []; |
| + var x = (b.left + b.right) / 2, y = (b.top + b.bottom) / 2, r = 21.5; |
| + [[-r, -r], [r, -r], [-r, r], [r, r], [0, -r], [0, r], [-r, 0], [r, 0]] |
| + .forEach(function (d) { |
| + if (!a.contains(document.elementFromPoint(x + d[0], y + d[1]))) { |
| + misses.push(d.join(",")); |
| + } |
| + }); |
| + return misses.join(" ") + (misses.length ? |
| + " (drawn " + b.width + "x" + b.height + ")" : ""); |
| +})()`)) |
| + if misses != "" { |
| + t.Errorf("a tap misses the lens at %s", misses) |
| + } |
| +} |