oficina / fichas Public

The header has no Search; Search is the rail's first row and ⌘K

Paul, 2026-11-18: "I think we can just lose the search icon in the
header". The bar's Search, the lens of 6a57585, is gone from
barActions, and with it the tooltip "Search ⌘K".

Fichas' rail never had a Search, and on a phone the lens's Menu sheet
row was the only way to search from a card or History (only the list
has a Find box). So Search moved where Mapa has it: the rail's first
row, "Search" with ⌘K beside it while open, the icon with "Search" its
tooltip (title) when folded; and below 800px the Menu sheet's first
row, as the first link of the bar's nav, which the sheet draws. Each
goes to the type's Find box (/t/<type>#find), focusing it in place on
the list, and is a plain link with scripts off. ⌘K, on a page with no
Find box, now follows the rail's row (data-fichas-search, in the page
below 800px too) instead of the lens; still never from inside a field.
estilo's Action.IconOnly is left in place; estilo is unchanged.

Copy: copy-review/search-icon keeps Luna's approval, with a note that
both its strings are gone and that the new rows use the word "Search"
it approved; their drafts are deleted.

browser_search_icon_test.go becomes browser_search_entries_test.go: no
Search in the bar (nor "Search ⌘K" anywhere) at 1440, 1000, 800 and
390, scripts on and off, on the list, a card, History and Fields; the
rail's row open and folded (by width and by cookie), from the list and
a card, scripts on and off; the sheet's single first row on the list,
a card and History, scripts on and off; ⌘K and Ctrl+K on the list and
from a card and History at three widths, and nothing from inside a
field; axe at four widths on the list and a card; no shift in the bar.
The bar and sheet tests were seen failing on main. TestTheKeyboardWalk
checks J is inert on the rail's Search instead of the bar's. Build
note 23 records it and amends §3.1 and §3.2.

make ci and make browser green.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 378bd75397b91312cff8113b8a24a79e3c01e337 parent 6a57585
10 files changed, +329 −312
  • copy-review/search-icon/result.json +1 −0
  • copy-review/search-icon/strings.json +0 −18
  • docs/superpowers/specs/2026-11-17-fichas-level-up.md +6 −1
  • internal/fichas/contract_release.go +4 −3
  • internal/fichas/frame.go +19 −9
  • internal/fichas/static/grid.js +6 −5
  • internal/fichas/templates/partials.html +3 −1
  • internal/fichastest/browser_edit_test.go +3 −3
  • internal/fichastest/browser_search_entries_test.go +287 −0
  • internal/fichastest/browser_search_icon_test.go +0 −272

CI passed — run details

CI log
=== vet ===
go vet ./...
go vet -tags browser ./internal/fichastest/
=== fmt ===
=== test ===
go test ./...
?   	amadan.net/oficina/fichas/cmd/fichas	[no test files]
ok  	amadan.net/oficina/fichas/internal/fichas	2.360s
?   	amadan.net/oficina/fichas/internal/fichas/icons	[no test files]
ok  	amadan.net/oficina/fichas/internal/fichas/locale	0.008s
ok  	amadan.net/oficina/fichas/internal/fichas/seal	0.009s
ok  	amadan.net/oficina/fichas/internal/fichastest	1.846s
?   	amadan.net/oficina/fichas/scripts/mockups	[no test files]
?   	amadan.net/oficina/fichas/scripts/preview	[no test files]
?   	amadan.net/oficina/fichas/scripts/writeestilo	[no test files]
=== migration-check ===
go tool rastrillo migration check
rastrillo migration check: models and migrations agree
diff --git a/copy-review/search-icon/result.json b/copy-review/search-icon/result.json
index e75d59a..3c7fd7a 100644
--- a/copy-review/search-icon/result.json
+++ b/copy-review/search-icon/result.json
@@ -2,6 +2,7 @@
"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.",
+ "removed": "2026-11-18, the same day: Paul, \"I think we can just lose the search icon in the header\". The bar's Search is gone, and with it both strings reviewed here: the lens's name (bar.search.name) and its tooltip \"Search ⌘K\" (bar.search.tooltip). Their drafts (strings.json) are deleted; this record of Luna's approval stays. Search moved to where Mapa has it, in the word already approved here: the rail's first row (\"Search\", ⌘K beside it while the rail is open, \"Search\" its tooltip when folded) and the Menu sheet's first row below 800px (\"Search\"), so a phone still has it on a card or History, which have no Find box.",
"strings": [
{
"id": "bar.search.name",
diff --git a/copy-review/search-icon/strings.json b/copy-review/search-icon/strings.json
deleted file mode 100644
index 408f51b..0000000
--- a/copy-review/search-icon/strings.json
+++ /dev/null
@@ -1,18 +0,0 @@
-[
- {
- "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."
- }
-]
diff --git a/docs/superpowers/specs/2026-11-17-fichas-level-up.md b/docs/superpowers/specs/2026-11-17-fichas-level-up.md
index f145680..b9499ae 100644
--- a/docs/superpowers/specs/2026-11-17-fichas-level-up.md
+++ b/docs/superpowers/specs/2026-11-17-fichas-level-up.md
@@ -61,7 +61,7 @@ The estilo bar stack, as Mapa uses it (Mapa level-up §3.1). Fichas' slots:
| Title | The type's plural on a list ("Customers"); the card's title on a card's full page; "New type" in the designer. Not renamed in place: a type is renamed in its settings, a card on its card |
| Menubar | **Card**: New, Open full page, Delete… · **Edit**: Undo, Redo · **View**: Show View panel, Table, Board, Calendar, Cards, Density, Fold rail · **Type**: Fields, Card layout, Type settings, New type, Folders · **Help** |
| Lead | The view switcher (§4.2) and the save state: "Saved", "Saving…", or "Couldn't save" with Retry |
-| Actions | Search (focuses the Find box, ⌘K), View (toggles the panel, `aria-pressed`), the primary "New <singular>" |
+| Actions | View (toggles the panel, `aria-pressed`), the primary "New <singular>". Search left the bar (build note 23): it is the rail's first row |
| Account | estilo's account menu, as today |
- **Search stays per type.** ⌘K focuses the type's Find box. A search across every type is out (§12).
@@ -73,6 +73,7 @@ The estilo bar stack, as Mapa uses it (Mapa level-up §3.1). Fichas' slots:
- **R2, folders:** each type is in at most one folder. A type with no folder sits above the folders. A folder heading is a `<details>`, so it collapses with no script. Which folders are closed is one per-person cookie (`fichas-rail`, the closed folders' opaque keys), as density is. The folder holding the current type is always open.
- **Cookies stay few:** one for the rail (fold and closed folders), one for the panel, one for density, and one (`fichas-views`) mapping each type's key to the view last used, capped at 30 types, oldest dropped. Every one holds opaque keys or this app's words only.
- **Each type has its icon** (§8.1) and its card count, as the mock-ups show.
+- **Search is the rail's first row** (build note 23): the type's Find box, ⌘K beside it.
- **New type** is a quieter row below a rule.
- **⌘\ folds the rail** to icons, and back. The fold is two submit buttons, one per state, and CSS shows the one that fits (Mapa build note 10). `POST /view/rail` sets a cookie, writes no row, logs no event, and returns only to a local path.
- **Below 800px** the rail is estilo's Menu sheet.
@@ -1101,6 +1102,10 @@ Choices made while building, where this spec was silent or the build chose diffe
21. **A `<time>` whose text is a date in the reader's locale carries that locale's `lang`** (WCAG 3.1.2); one whose text is the interface's English ("in 3 days") does not. Line endings are compared newline-blind in one place, `EditFields`, and the forms' handlers do not repeat it.
22. **The new user-facing strings** are in `copy-review/level-up-phase-1/strings.json` for Paul's copy review; none is reviewed yet.
+### After Phase 1
+
+23. **The header has no Search** (Paul, 2026-11-18: "I think we can just lose the search icon in the header"; amends §3.1 and §3.2). The bar's Search, made a lens with "Search ⌘K" as its tooltip that morning (main `6a57585`), is gone, and the rail never had one, so Search moved there, where Mapa has it: the rail's first row, "Search" with ⌘K beside it while the rail is open, the icon with "Search" as its tooltip when folded; and below 800px the Menu sheet's first row (the bar's `Nav`, which the sheet draws), the only Search a phone has on a card or History, which have no Find box. Each goes to the type's Find box (`/t/<type>#find`), focusing it in place on the list. ⌘K, from a page with no Find box, goes where the rail's row goes, never from inside a field; the row (`data-fichas-search`) is in the page below 800px too, where the rail is not drawn. estilo's `Action.IconOnly` stays for a later action. `browser_search_entries_test.go` holds it: no Search in the bar at 1440, 1000, 800 and 390, scripts on and off, nor "Search ⌘K" anywhere; the rail's row open and folded (by width and by choice), from the list and a card, scripts on and off; the sheet's one first row on the list, a card and History; ⌘K and Ctrl+K at three widths, and nothing from inside a field; axe at four widths; no shift in the bar.
+
---
## 18. Findings and what changed
diff --git a/internal/fichas/contract_release.go b/internal/fichas/contract_release.go
index 54938fc..d662b12 100644
--- a/internal/fichas/contract_release.go
+++ b/internal/fichas/contract_release.go
@@ -71,9 +71,9 @@ type contractReleasePage struct {
Nav []NavItem
Account *chrome.Account
// The frame every shell page draws (level-up §3).
- Bar chrome.Bar
- L *ui.Localizer
- Rail, Here string
+ Bar chrome.Bar
+ L *ui.Localizer
+ Rail, Here, Search string
Theme, Flow, Phase, Payload, Signature, Destination, Importer, Error string
Cards []CardView
@@ -96,6 +96,7 @@ func (a *app) contractPage(w http.ResponseWriter, r *http.Request, p contractRel
p.Bar, _ = frame["Bar"].(chrome.Bar)
p.Rail, _ = frame["Rail"].(string)
p.Here, _ = frame["Here"].(string)
+ p.Search, _ = frame["Search"].(string)
p.L = a.readerL(r)
p.Destination = a.cfg.ContractRelease.Destination
p.Importer = a.cfg.ContractRelease.Importer
diff --git a/internal/fichas/frame.go b/internal/fichas/frame.go
index ddfbd4e..ae4abd1 100644
--- a/internal/fichas/frame.go
+++ b/internal/fichas/frame.go
@@ -76,7 +76,11 @@ func (a *app) buildFrame(r *http.Request, name string, data map[string]any, nav
return err
}
}
- links := make([]chrome.Link, 0, len(nav))
+ // Search is the rail's first row and, below 800px, the Menu sheet's
+ // first row, before the types (the sheet draws the bar's nav).
+ search := searchHref(facts)
+ links := make([]chrome.Link, 0, len(nav)+1)
+ links = append(links, chrome.Link{Href: search, Label: "Search"})
for _, n := range nav {
links = append(links, chrome.Link{Href: n.Href, Label: n.Label, Current: n.Current})
}
@@ -91,6 +95,7 @@ func (a *app) buildFrame(r *http.Request, name string, data map[string]any, nav
Menubar: menus, Lead: lead,
}
data["Rail"] = railState(r)
+ data["Search"] = search
data["Here"] = orDefault(data["Here"], r.URL.RequestURI())
return nil
}
@@ -201,16 +206,21 @@ func orText(s, def string) string {
return s
}
-// barActions: Search, History on a card, and the primary New. 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(f frameFacts) []chrome.Action {
- search := "/"
+// searchHref is where Search goes: the list's Find box, the current
+// type's on a page that has one.
+func searchHref(f frameFacts) string {
if f.TypeKey != "" {
- search = typeHref(f.TypeKey) + "#find"
+ return typeHref(f.TypeKey) + "#find"
}
- actions := []chrome.Action{{Item: menu.Item{Href: search, Label: "Search", Key: "⌘K"}, Icon: icons.Icon("search"),
- IconOnly: true, KeyShortcuts: "Meta+K Control+K"}}
+ return "/"
+}
+
+// barActions: History on a card, and the primary New. The bar has no
+// Search (Paul, 2026-11-18: "I think we can just lose the search icon in
+// the header"): it is the rail's first row, the Menu sheet's below
+// 800px, and ⌘K (grid.js).
+func barActions(f frameFacts) []chrome.Action {
+ var actions []chrome.Action
if f.CardID != 0 {
actions = append(actions, chrome.Action{Item: menu.Item{Href: "/cards/" + strconv.FormatInt(f.CardID, 10) + "/history", Label: "History"}, Icon: icons.Icon("history")})
}
diff --git a/internal/fichas/static/grid.js b/internal/fichas/static/grid.js
index 6688927..7ecac3d 100644
--- a/internal/fichas/static/grid.js
+++ b/internal/fichas/static/grid.js
@@ -624,11 +624,12 @@
if (mod && (e.key === "k" || e.key === "K")) {
var q = document.querySelector('[data-live-search] input[name="q"]');
if (q) { e.preventDefault(); q.focus(); q.select(); return; }
- // No Find box here (a card, History): go where the bar's Search
- // goes, the list's Find box, so ⌘K does what its tooltip says.
- // Never from inside a field, where it would leave typing unsaved.
- var lens = document.querySelector("[estilo-bar] a[estilo-bar-icon]");
- if (lens && !inField(t) && lens.pathname !== location.pathname) { e.preventDefault(); location.assign(lens.href); }
+ // No Find box here (a card, History): go where the rail's Search
+ // goes, the list's Find box (the link is there below 800px too,
+ // where the rail is not drawn). Never from inside a field, where
+ // it would leave typing unsaved.
+ var search = document.querySelector("a[data-fichas-search]");
+ if (search && !inField(t) && search.pathname !== location.pathname) { e.preventDefault(); location.assign(search.href); }
return;
}
if (mod && e.key === "\\") {
diff --git a/internal/fichas/templates/partials.html b/internal/fichas/templates/partials.html
index 555ea6a..a140512 100644
--- a/internal/fichas/templates/partials.html
+++ b/internal/fichas/templates/partials.html
@@ -37,12 +37,14 @@
{{- end -}}
{{end}}
-{{/* fichas-rail: the rail (level-up §3.2, R1): each type with its icon
+{{/* fichas-rail: the rail (level-up §3.2, R1): Search (the list's Find
+ box, ⌘K; the bar has none, Paul 2026-11-18), each type with its icon
and count, New type below a rule, and the fold at its foot. The fold
is two submit buttons, one per state; CSS shows the one that fits
what is on screen, so it works with scripts off and with no cookie.
Below 800px the bar's Menu sheet carries the types instead. */}}
{{define "fichas-rail"}}<nav fichas-rail aria-label="Types">
+ <a fichas-rail-item data-fichas-search href="{{.Search}}" aria-keyshortcuts="Meta+K Control+K" title="Search">{{icon "search"}}<span fichas-rail-label>Search</span><kbd fichas-kbd aria-hidden="true">⌘K</kbd></a>
{{- range .Nav}}
<a fichas-rail-item href="{{.Href}}"{{if .Current}} aria-current="page"{{end}} title="{{.Label}}">{{icon "users"}}<span fichas-rail-label>{{.Label}}</span><span fichas-rail-count>{{number $.L .Count}}</span></a>
{{- end}}
diff --git a/internal/fichastest/browser_edit_test.go b/internal/fichastest/browser_edit_test.go
index 40311f3..3d40586 100644
--- a/internal/fichastest/browser_edit_test.go
+++ b/internal/fichastest/browser_edit_test.go
@@ -225,8 +225,8 @@ func TestTheKeyboardWalk(t *testing.T) {
chromedp.Click(`[fichas-title-link]`),
chromedp.WaitVisible(`[fichas-pane]`),
// With the card open, J is still inert outside the pane and the
- // narrowed list: here, on the bar's Search.
- chromedp.Focus(`[estilo-bar] a[href$="#find"]`),
+ // narrowed list: here, on the rail's Search.
+ chromedp.Focus(`[fichas-rail] a[data-fichas-search]`),
chromedp.KeyEvent("j"),
chromedp.Sleep(300*time.Millisecond),
harness.Into(&inBar, chromedp.Evaluate[string](`location.search`)),
@@ -239,7 +239,7 @@ func TestTheKeyboardWalk(t *testing.T) {
t.Errorf("J in the grid went to %q; it must be inert there", inGrid)
}
if inBar != "?card="+itoa(s.ids[0])+"&sort=f_name" {
- t.Errorf("J on the bar went to %q; it must be inert outside the pane", inBar)
+ t.Errorf("J on the rail went to %q; it must be inert outside the pane", inBar)
}
if !strings.Contains(inPane, "card="+itoa(s.ids[1])) {
t.Errorf("J in the pane went to %q, want the second card", inPane)
diff --git a/internal/fichastest/browser_search_entries_test.go b/internal/fichastest/browser_search_entries_test.go
new file mode 100644
index 0000000..e4784ce
--- /dev/null
+++ b/internal/fichastest/browser_search_entries_test.go
@@ -0,0 +1,287 @@
+//go:build browser
+
+package fichastest
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/rastrillo/rastrillo/harness"
+ "github.com/chromedp/cdproto/cdp"
+ "github.com/chromedp/cdproto/emulation"
+ "github.com/chromedp/cdproto/network"
+ "github.com/chromedp/cdproto/page"
+ "github.com/chromedp/chromedp"
+)
+
+// The header has no Search (Paul, 2026-11-18: "I think we can just lose
+// the search icon in the header"). Search is the rail's first row, with
+// ⌘K beside it while the rail is open and "Search" its tooltip when
+// folded; the Menu sheet's first row below 800px, once, so a phone has
+// it on a card and on History, which have no Find box; and ⌘K or Ctrl+K
+// anywhere but inside a field. Each goes to the list's Find box, and
+// with scripts off links to #find.
+
+// railSearch is the rail's Search.
+const railSearch = `[fichas-rail] a[data-fichas-search]`
+
+// barSearch counts what in the bar, outside the Menu sheet, is a Search
+// on screen: a link to the Find box, an icon-only action, or a control
+// with a shortcut.
+const barSearch = `Array.prototype.filter.call(
+ document.querySelectorAll('[estilo-bar] a[href$="#find"], [estilo-bar] [estilo-bar-icon], [estilo-bar] [aria-keyshortcuts]'),
+ function (el) { return !el.closest('[estilo-menu="sheet"]') && el.checkVisibility(); }).length`
+
+// whereAt is the page's path and fragment.
+const whereAt = `location.pathname + location.hash`
+
+// findFocused is whether the list's Find box has focus.
+const findFocused = `document.activeElement === document.querySelector('[data-live-search] input[name="q"]')`
+
+func scriptsOn(on bool) chromedp.Action[chromedp.Void] {
+ return send(emulation.SetScriptExecutionDisabled, emulation.SetScriptExecutionDisabledParams{Value: !on})
+}
+
+func viewport(width int64) chromedp.Action[chromedp.Void] {
+ return send(emulation.SetDeviceMetricsOverride, emulation.SetDeviceMetricsOverrideParams{Width: width, Height: 900, DeviceScaleFactor: 1})
+}
+
+// railCookie sets the rail's fold, "" for none (the width decides).
+func railCookie(rig *harness.Rig, state string) chromedp.Action[chromedp.Void] {
+ if state == "" {
+ return send(network.DeleteCookies, network.DeleteCookiesParams{Name: "fichas-rail", URL: rig.Origin + "/"})
+ }
+ return chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
+ _, err := cdp.Call(ctx, target, network.SetCookie, network.SetCookieParams{Name: "fichas-rail", Value: state, URL: rig.Origin + "/"})
+ return err
+ })
+}
+
+func TestTheBarHasNoSearch(t *testing.T) {
+ s := seedCards(t, 3)
+ card := cardPath(s.ids[0])
+ for _, live := range []bool{false, true} {
+ for _, width := range []int64{1440, 1000, 800, 390} {
+ for _, path := range []string{"/t/t_customer", card, card + "/history", "/t/t_customer/fields"} {
+ var shown int
+ var html string
+ s.rig.Run(scriptsOn(live), viewport(width),
+ chromedp.Navigate(s.rig.Origin+path), chromedp.WaitReady(`[estilo-bar]`),
+ harness.Into(&shown, chromedp.Evaluate[int](barSearch)),
+ harness.Into(&html, chromedp.Evaluate[string](`document.documentElement.outerHTML`)))
+ if shown != 0 {
+ t.Errorf("%s at %dpx, scripts %v: the bar shows %d Search controls", path, width, live, shown)
+ }
+ if strings.Contains(html, "Search ⌘K") {
+ t.Errorf("%s at %dpx, scripts %v: \"Search ⌘K\" is still drawn", path, width, live)
+ }
+ }
+ }
+ }
+ s.rig.Run(scriptsOn(true))
+ for _, path := range []string{"/t/t_customer", card} {
+ for _, width := range []int64{1440, 1000, 800, 390} {
+ axeCheck(t, s.rig, path, width, "")
+ }
+ }
+}
+
+// The rail's Search, open and folded (by width, and by choice), scripts
+// on and off, from the list and from a card.
+func TestTheRailsSearchGoesToFind(t *testing.T) {
+ s := seedCards(t, 3)
+ card := cardPath(s.ids[0])
+ cases := []struct {
+ width int64
+ cookie string
+ open bool
+ }{{1440, "", true}, {1000, "", false}, {1440, "rail", false}, {1000, "open", true}}
+ for _, c := range cases {
+ for _, live := range []bool{false, true} {
+ name := fmt.Sprintf("%dpx, cookie %q, scripts %v", c.width, c.cookie, live)
+ var facts struct {
+ Label, Title, Keys, Kbd string
+ LabelShown, KbdShown bool
+ }
+ var raw string
+ s.rig.Run(scriptsOn(live), railCookie(s.rig, c.cookie), viewport(c.width),
+ chromedp.Navigate(s.rig.Origin+"/t/t_customer"), chromedp.WaitVisible(railSearch),
+ harness.Into(&raw, chromedp.Evaluate[string](`(function () {
+ var a = document.querySelector('`+railSearch+`');
+ var label = a.querySelector('[fichas-rail-label]'), kbd = a.querySelector('kbd');
+ // Folded, the rail keeps the words for screen readers and clips them
+ // to nothing.
+ var seen = function (el) { var b = el.getBoundingClientRect(); return b.width > 1 && b.height > 1 && getComputedStyle(el).clipPath === 'none'; };
+ return JSON.stringify({Label: label.textContent, Title: a.title, Keys: a.getAttribute('aria-keyshortcuts'),
+ Kbd: kbd.textContent, LabelShown: seen(label), KbdShown: seen(kbd)});
+})()`)))
+ if err := json.Unmarshal([]byte(raw), &facts); err != nil {
+ t.Fatal(err)
+ }
+ if facts.Label != "Search" || facts.Title != "Search" || facts.Keys != "Meta+K Control+K" || facts.Kbd != "⌘K" {
+ t.Errorf("%s: the rail's Search is %+v", name, facts)
+ }
+ if facts.LabelShown != c.open || facts.KbdShown != c.open {
+ t.Errorf("%s: open %v, but the label shows %v and ⌘K %v", name, c.open, facts.LabelShown, facts.KbdShown)
+ }
+ // From the list: the Find box (with scripts, focus; without,
+ // the link to #find).
+ var at string
+ var focused bool
+ s.rig.Run(chromedp.Click(railSearch), chromedp.Sleep(300*time.Millisecond),
+ harness.Into(&at, chromedp.Evaluate[string](whereAt)),
+ harness.Into(&focused, chromedp.Evaluate[bool](findFocused)))
+ if live && !focused {
+ t.Errorf("%s: from the list the rail's Search did not focus the Find box (at %s)", name, at)
+ }
+ if !live && at != "/t/t_customer#find" {
+ t.Errorf("%s: from the list the rail's Search went to %s", name, at)
+ }
+ // From a card, which has no Find box: the list's.
+ s.rig.Run(chromedp.Navigate(s.rig.Origin+card), chromedp.WaitVisible(railSearch),
+ chromedp.Click(railSearch), chromedp.WaitReady(`[data-live-search] input[name="q"]`),
+ harness.Into(&at, chromedp.Evaluate[string](whereAt)))
+ if at != "/t/t_customer#find" {
+ t.Errorf("%s: from a card the rail's Search went to %s", name, at)
+ }
+ }
+ }
+ s.rig.Run(scriptsOn(true), railCookie(s.rig, ""))
+}
+
+// Below 800px Search is the Menu sheet's first row, once, on the list,
+// a card and History.
+func TestTheMenuSheetHasSearch(t *testing.T) {
+ s := seedCards(t, 3)
+ card := cardPath(s.ids[0])
+ const sheetSearch = `[estilo-menu="sheet"] a[href$="#find"]`
+ for _, live := range []bool{false, true} {
+ for _, path := range []string{"/t/t_customer", card, card + "/history"} {
+ name := fmt.Sprintf("%s, scripts %v", path, live)
+ var rows, at string
+ var focused bool
+ s.rig.Run(scriptsOn(live), viewport(390),
+ chromedp.Navigate(s.rig.Origin+path), chromedp.WaitVisible("[estilo-bar-more] > summary"),
+ chromedp.Click("[estilo-bar-more] > summary"), chromedp.WaitVisible(sheetSearch),
+ harness.Into(&rows, chromedp.Evaluate[string](`Array.prototype.map.call(document.querySelectorAll('[estilo-menu="sheet"] [estilo-menu-item]'), function (row) { return row.textContent.trim(); }).join("|")`)),
+ chromedp.Click(sheetSearch), chromedp.Sleep(300*time.Millisecond),
+ chromedp.WaitReady(`[data-live-search] input[name="q"]`),
+ harness.Into(&at, chromedp.Evaluate[string](whereAt)),
+ harness.Into(&focused, chromedp.Evaluate[bool](findFocused)))
+ if !strings.HasPrefix(rows, "Search|") || strings.Count("|"+rows+"|", "|Search|") != 1 {
+ t.Errorf("%s: the Menu sheet's rows are %q", name, rows)
+ }
+ if live && path == "/t/t_customer" {
+ if !focused {
+ t.Errorf("%s: the sheet's Search did not focus the Find box", name)
+ }
+ } else if at != "/t/t_customer#find" {
+ t.Errorf("%s: the sheet's Search went to %s", name, at)
+ }
+ }
+ }
+ s.rig.Run(scriptsOn(true))
+}
+
+// ⌘K and Ctrl+K: the Find box on the list; from a card or History, the
+// list's Find box, at any width (below 800px too, where no rail is
+// drawn); and nothing from inside a field.
+func TestTheShortcutGoesToFind(t *testing.T) {
+ s := seedCards(t, 3)
+ card := cardPath(s.ids[0])
+ for _, mod := range []chromedp.Modifier{chromedp.ModifierMeta, chromedp.ModifierCtrl} {
+ for _, width := range []int64{1440, 1000, 390} {
+ name := fmt.Sprintf("%dpx, modifier %v", width, mod)
+ var focused bool
+ s.rig.Run(viewport(width), chromedp.Navigate(s.rig.Origin+"/t/t_customer"),
+ chromedp.WaitVisible(`[data-live-search] input[name="q"]`),
+ chromedp.Evaluate[chromedp.Void](`document.activeElement && document.activeElement.blur()`),
+ chromedp.KeyEvent("k", chromedp.KeyModifiers(mod)), chromedp.Sleep(200*time.Millisecond),
+ harness.Into(&focused, chromedp.Evaluate[bool](findFocused)))
+ if !focused {
+ t.Errorf("%s: on the list the shortcut did not focus the Find box", name)
+ }
+ for _, path := range []string{card, card + "/history"} {
+ var at string
+ s.rig.Run(chromedp.Navigate(s.rig.Origin+path), chromedp.WaitReady(`[fichas-main]`),
+ chromedp.Evaluate[chromedp.Void](`document.activeElement && document.activeElement.blur()`),
+ chromedp.KeyEvent("k", chromedp.KeyModifiers(mod)),
+ chromedp.WaitVisible(`[data-live-search] input[name="q"]`),
+ harness.Into(&at, chromedp.Evaluate[string](whereAt)))
+ if at != "/t/t_customer#find" {
+ t.Errorf("%s: the shortcut on %s went to %s", name, path, at)
+ }
+ }
+ }
+ // Inside a field it does nothing: typing is never left unsaved.
+ var at string
+ var stayed bool
+ s.rig.Run(wide(), chromedp.Navigate(s.rig.Origin+card+"/edit"), chromedp.WaitReady(`[fichas-main] form`),
+ chromedp.Evaluate[chromedp.Void](`Array.prototype.find.call(document.querySelectorAll('[fichas-main] input, [fichas-main] textarea'), function (el) { return !/^(hidden|radio|checkbox|submit)$/.test(el.type) && el.checkVisibility(); }).focus()`),
+ chromedp.KeyEvent("k", chromedp.KeyModifiers(mod)), chromedp.Sleep(400*time.Millisecond),
+ harness.Into(&at, chromedp.Evaluate[string](`location.pathname`)),
+ harness.Into(&stayed, chromedp.Evaluate[bool](`document.activeElement.matches('[fichas-main] input, [fichas-main] textarea')`)))
+ if at != card+"/edit" || !stayed {
+ t.Errorf("modifier %v: the shortcut inside a field went to %s (focus kept: %v)", mod, at, stayed)
+ }
+ }
+}
+
+// shiftRecorder keeps every layout shift from the start of the load
+// that moved something in the bar (this gate's subject; the page body
+// is not), naming what moved.
+const shiftRecorder = `(function () {
+ window.__shifts = [];
+ try {
+ new PerformanceObserver(function (list) {
+ list.getEntries().forEach(function (entry) {
+ (entry.sources || []).forEach(function (source) {
+ var el = source.node && (source.node.nodeType === 1 ? source.node : source.node.parentElement);
+ if (el && el.closest("[estilo-bar]")) __shifts.push(el.outerHTML.slice(0, 80) + " " + entry.value);
+ });
+ });
+ }).observe({ type: "layout-shift", buffered: true });
+ } catch (error) {}
+})()`
+
+// No shift (Mapa's L5, for the bar): every control in the bar is where
+// the server drew it (scripts off) once the page's scripts have run, and
+// no layout shift moves anything in the bar from the start of the load,
+// on the list and on a card.
+func TestTheBarMovesNothing(t *testing.T) {
+ s := seedCards(t, 3)
+ 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(" "); }))`
+ s.rig.Run(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
+ _, err := cdp.Call(ctx, target, page.AddScriptToEvaluateOnNewDocument,
+ page.AddScriptToEvaluateOnNewDocumentParams{Source: shiftRecorder})
+ return err
+ }))
+ for _, path := range []string{"/t/t_customer", cardPath(s.ids[0])} {
+ for _, width := range []int64{1440, 1000} {
+ load := func(live bool) string {
+ var boxes string
+ s.rig.Run(scriptsOn(live), viewport(width),
+ chromedp.Navigate(s.rig.Origin+path), chromedp.WaitReady(`[estilo-bar-end]`), chromedp.Sleep(300*time.Millisecond),
+ harness.Into(&boxes, chromedp.Evaluate[string](bar)))
+ return boxes
+ }
+ off, on := load(false), load(true)
+ if off != on {
+ t.Errorf("%s at %dpx: the bar moved once scripts ran:\noff %s\non %s", path, width, off, on)
+ }
+ var shifts string
+ s.rig.Run(harness.Into(&shifts, chromedp.Evaluate[string](`JSON.stringify(window.__shifts || [])`)))
+ if shifts != "[]" {
+ t.Errorf("%s at %dpx: the bar shifted: %s", path, width, shifts)
+ }
+ }
+ }
+ s.rig.Run(scriptsOn(true))
+}
diff --git a/internal/fichastest/browser_search_icon_test.go b/internal/fichastest/browser_search_icon_test.go
deleted file mode 100644
index da0ec44..0000000
--- a/internal/fichastest/browser_search_icon_test.go
+++ /dev/null
@@ -1,272 +0,0 @@
-//go:build browser
-
-package fichastest
-
-import (
- "context"
- "encoding/json"
- "fmt"
- "testing"
- "time"
-
- "amadan.net/rastrillo/rastrillo/harness"
- "github.com/chromedp/cdproto/cdp"
- "github.com/chromedp/cdproto/emulation"
- "github.com/chromedp/cdproto/input"
- "github.com/chromedp/cdproto/page"
- "github.com/chromedp/chromedp"
- "github.com/chromedp/chromedp/kb"
-)
-
-// The bar'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 goes
-// to the list's Find box; it moves nothing as the page loads; axe finds
-// nothing serious; and on a touch screen a tap lands on it anywhere in
-// 44px.
-
-// barSearch is the bar's Search, on screen from 800px.
-const barSearch = `[estilo-bar-actions] a[href$="#find"]`
-
-// searchFacts is what the bar's Search shows and says. Misses lists the
-// middles of the tooltip's edges a pointer could not reach (it 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 raw string
- rig.Run(harness.Into(&raw, chromedp.Evaluate[string](fmt.Sprintf(searchFacts, barSearch))))
- var got searchShows
- if err := json.Unmarshal([]byte(raw), &got); err != nil {
- t.Fatal(err)
- }
- return got
-}
-
-// hoverOver moves the mouse to the middle of selector's element.
-func hoverOver(selector string) chromedp.Action[chromedp.Void] {
- return chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
- box, err := chromedp.Run(ctx, chromedp.Dimensions(selector))
- if err != nil {
- return err
- }
- q := box.Content
- return chromedp.Do(ctx, chromedp.MouseEvent(input.DispatchMouseEventTypeMouseMoved, (q[0]+q[4])/2, (q[1]+q[5])/2),
- chromedp.Sleep(200*time.Millisecond))
- })
-}
-
-func scriptsOn(on bool) chromedp.Action[chromedp.Void] {
- return send(emulation.SetScriptExecutionDisabled, emulation.SetScriptExecutionDisabledParams{Value: !on})
-}
-
-func TestTheBarsSearchIsTheLensAlone(t *testing.T) {
- s := seedCards(t, 3)
- for _, path := range []string{"/t/t_customer", cardPath(s.ids[0])} {
- for _, width := range []int64{1440, 1000, 800} {
- s.rig.Run(
- send(emulation.SetDeviceMetricsOverride, emulation.SetDeviceMetricsOverrideParams{Width: width, Height: 900, DeviceScaleFactor: 1}),
- chromedp.Navigate(s.rig.Origin+path),
- chromedp.WaitVisible(barSearch),
- )
- got := showsOf(t, s.rig)
- if got.Text != "" || got.Name != "Search" || got.Keys != "Meta+K Control+K" || got.Tip != `"Search ⌘K"` {
- t.Errorf("%s at %dpx: the bar's Search is %+v", path, width, got)
- }
- if got.Width != got.Height || got.Width < 24 {
- t.Errorf("%s at %dpx: the lens is %vx%v, not a square of at least 24px", path, width, got.Width, got.Height)
- }
- if got.Shown != "0" {
- t.Errorf("%s at %dpx: the tooltip shows at rest (opacity %s)", path, width, got.Shown)
- }
- s.rig.Run(hoverOver(barSearch))
- if got := showsOf(t, s.rig); got.Shown != "1" || got.Misses != "" {
- t.Errorf("%s at %dpx: on hover the tooltip is at opacity %s, cut off at %q", path, 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.
- var focused bool
- s.rig.Run(hoverOver("[fichas-main]"), chromedp.Focus(barSearch),
- chromedp.KeyEvent(kb.Tab, chromedp.KeyModifiers(chromedp.ModifierShift)), chromedp.KeyEvent(kb.Tab),
- chromedp.Sleep(200*time.Millisecond),
- harness.Into(&focused, chromedp.Evaluate[bool](`document.querySelector('`+barSearch+`').matches(":focus-visible")`)))
- if !focused {
- t.Fatalf("%s at %dpx: the lens did not take keyboard focus", path, width)
- }
- if got := showsOf(t, s.rig); got.Shown != "1" {
- t.Errorf("%s at %dpx: on focus the tooltip is at opacity %s", path, width, got.Shown)
- }
- axeCheck(t, s.rig, path, width, "")
- }
- }
-
- // The same action as before: the list's Find box, with scripts and
- // without (a link to #find).
- var active bool
- var hash string
- s.rig.Run(
- wide(), chromedp.Navigate(s.rig.Origin+"/t/t_customer"), chromedp.WaitVisible(barSearch),
- chromedp.Click(barSearch), chromedp.Sleep(200*time.Millisecond),
- harness.Into(&active, chromedp.Evaluate[bool](`document.activeElement === document.querySelector('[data-live-search] input[name="q"]')`)),
- scriptsOn(false), chromedp.Navigate(s.rig.Origin+"/t/t_customer"), chromedp.WaitReady(barSearch),
- chromedp.Click(barSearch), chromedp.Sleep(300*time.Millisecond),
- harness.Into(&hash, chromedp.Evaluate[string](`location.pathname + location.hash`)),
- scriptsOn(true),
- )
- // ⌘K on a card, where there is no Find box, goes where the lens
- // goes: the list's Find box.
- var after string
- s.rig.Run(
- chromedp.Navigate(s.rig.Origin+cardPath(s.ids[0])), chromedp.WaitVisible(barSearch),
- chromedp.KeyEvent("k", chromedp.KeyModifiers(chromedp.ModifierMeta)),
- chromedp.WaitVisible(`[data-live-search] input[name="q"]`),
- harness.Into(&after, chromedp.Evaluate[string](`location.pathname + location.hash`)),
- )
- if after != "/t/t_customer#find" {
- t.Errorf("⌘K on a card went to %s", after)
- }
- if !active {
- t.Error("the lens did not focus the Find box")
- }
- if hash != "/t/t_customer#find" {
- t.Errorf("with scripts off the lens went to %s", hash)
- }
-
- // Below 800px the actions are the Menu sheet's rows, which keep the
- // word and the shortcut.
- var row string
- s.rig.Run(
- send(emulation.SetDeviceMetricsOverride, emulation.SetDeviceMetricsOverrideParams{Width: 390, Height: 844, DeviceScaleFactor: 1}),
- chromedp.Navigate(s.rig.Origin+"/t/t_customer"), chromedp.WaitVisible("[estilo-bar-more] > summary"),
- harness.Into(&row, chromedp.Evaluate[string](`document.querySelector('[estilo-menu="sheet"] a[href$="#find"]').textContent`)),
- )
- if row != "Search⌘K" {
- t.Errorf("the Menu sheet's Search row reads %q", row)
- }
-}
-
-// shiftRecorder keeps every layout shift from the start of the load
-// that moved something in the bar (this gate's subject; the page body
-// is not), naming what moved.
-const shiftRecorder = `(function () {
- window.__shifts = [];
- try {
- new PerformanceObserver(function (list) {
- list.getEntries().forEach(function (entry) {
- (entry.sources || []).forEach(function (source) {
- var el = source.node && (source.node.nodeType === 1 ? source.node : source.node.parentElement);
- if (el && el.closest("[estilo-bar]")) __shifts.push(el.outerHTML.slice(0, 80) + " " + entry.value);
- });
- });
- }).observe({ type: "layout-shift", buffered: true });
- } catch (error) {}
-})()`
-
-// No shift (Mapa's L5, for the bar): the lens and every control beside
-// it are where the server drew them (scripts off) once the page's
-// scripts have run, and no layout shift moves anything in the bar from
-// the start of the load, on the list and on a card.
-func TestTheBarsSearchMovesNothing(t *testing.T) {
- s := seedCards(t, 3)
- 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(" "); }))`
- s.rig.Run(chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
- _, err := cdp.Call(ctx, target, page.AddScriptToEvaluateOnNewDocument,
- page.AddScriptToEvaluateOnNewDocumentParams{Source: shiftRecorder})
- return err
- }))
- for _, path := range []string{"/t/t_customer", cardPath(s.ids[0])} {
- for _, width := range []int64{1440, 1000} {
- load := func(live bool) string {
- var boxes string
- s.rig.Run(scriptsOn(live),
- send(emulation.SetDeviceMetricsOverride, emulation.SetDeviceMetricsOverrideParams{Width: width, Height: 900, DeviceScaleFactor: 1}),
- chromedp.Navigate(s.rig.Origin+path), chromedp.WaitReady(barSearch), chromedp.Sleep(300*time.Millisecond),
- harness.Into(&boxes, chromedp.Evaluate[string](bar)))
- return boxes
- }
- off, on := load(false), load(true)
- if off != on {
- t.Errorf("%s at %dpx: the bar moved once scripts ran:\noff %s\non %s", path, width, off, on)
- }
- var shifts string
- s.rig.Run(harness.Into(&shifts, chromedp.Evaluate[string](`JSON.stringify(window.__shifts || [])`)))
- if shifts != "[]" {
- t.Errorf("%s at %dpx: the bar shifted: %s", path, width, 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) {
- s := seedCards(t, 3)
- var coarse bool
- var misses string
- s.rig.Run(
- send(emulation.SetDeviceMetricsOverride, emulation.SetDeviceMetricsOverrideParams{Width: 1024, Height: 768, DeviceScaleFactor: 1}),
- chromedp.Navigate(s.rig.Origin+"/t/t_customer"), chromedp.WaitVisible(barSearch),
- // Touch emulation, then a reload so the page re-evaluates its
- // media queries (TestNoZoomOnTap).
- send(emulation.SetTouchEmulationEnabled, emulation.SetTouchEmulationEnabledParams{Enabled: true, MaxTouchPoints: 5}),
- chromedp.Reload(), chromedp.WaitVisible(barSearch),
- harness.Into(&coarse, chromedp.Evaluate[bool](`matchMedia('(pointer: coarse)').matches`)),
- harness.Into(&misses, chromedp.Evaluate[string](`(function () {
- var a = document.querySelector('`+barSearch+`'), 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 + ")" : "");
-})()`)),
- send(emulation.SetTouchEmulationEnabled, emulation.SetTouchEmulationEnabledParams{Enabled: false}),
- )
- if !coarse {
- t.Fatal("the touch-screen emulation did not apply; this would measure desktop styles")
- }
- if misses != "" {
- t.Errorf("a tap misses the lens at %s", misses)
- }
-}