oficina / fichas Public

Clone
git clone https://amadan.net/oficina/fichas

Plain git — no account needed to clone.

Download

Download this file

1//go:build browser
2
3// The browser drive: the whole app in a real Chromium — loud on any console
4// error, failed request, 4xx/5xx, or JS value that leaked to the screen
5// unrendered. Not part of the plain suite:
6//
7// go test -tags browser ./...
8//
9// It needs a Chromium: on PATH, via RASTRILLO_CHROME, or in a Playwright
10// cache. A skip is not a pass — with no browser this fails, unless
11// RASTRILLO_BROWSER_OPTIONAL is set.
12//
13// **This file did not compile for most of fichas' life.** It called App with
14// the scaffold's original signature, and because the build tag keeps it out
15// of `make ci`, nothing noticed. A test behind a tag has to be run on
16// purpose, or it rots silently.
17package fichastest
18
19import (
20 "context"
21 "encoding/base64"
22 "io"
23 "log/slog"
24 "net/http"
25 "path/filepath"
26 "strings"
27 "testing"
28 "time"
29
30 "amadan.net/rastrillo/rastrillo/db"
31 "amadan.net/rastrillo/rastrillo/harness"
32 "github.com/chromedp/cdproto/cdp"
33 "github.com/chromedp/cdproto/emulation"
34 "github.com/chromedp/chromedp"
35
36 fichas "amadan.net/oficina/fichas/internal/fichas"
37)
38
39// browserApp is the app signed in as TestOwner, with the rig's own origin,
40// optionally seeded through the real store.
41func browserApp(t *testing.T, seed func(context.Context, *db.DB, fichas.Config)) *harness.Rig {
42 return browserAppWith(t, nil, seed)
43}
44
45// browserAppWith is browserApp with its config changed first, by
46// configure, when that is not nil.
47func browserAppWith(t *testing.T, configure func(*fichas.Config), seed func(context.Context, *db.DB, fichas.Config)) *harness.Rig {
48 return harness.New(t, func(origin string) http.Handler {
49 logger := slog.New(slog.NewTextHandler(io.Discard, nil))
50 d, err := db.Open(filepath.Join(t.TempDir(), "app.db"), logger)
51 if err != nil {
52 t.Fatalf("db.Open: %v", err)
53 }
54 t.Cleanup(func() { d.Close() })
55 cfg, err := fichas.LoadConfig(func(k string) string {
56 return map[string]string{
57 "FICHAS_DEK": base64.StdEncoding.EncodeToString(testKey()),
58 "FICHAS_INSTANCE_KEY": "browser",
59 "FICHAS_OWNERS": TestOwner,
60 "FICHAS_ORIGIN": origin,
61 "FICHAS_ALLOW_LOGGED_MAIL": "1",
62 }[k]
63 })
64 if err != nil {
65 t.Fatalf("LoadConfig: %v", err)
66 }
67 if configure != nil {
68 configure(&cfg)
69 }
70 mux, err := fichas.AppForTest(d, cfg, logger, TestOwner)
71 if err != nil {
72 t.Fatalf("AppForTest: %v", err)
73 }
74 if seed != nil {
75 seed(context.Background(), d, cfg)
76 }
77 return mux
78 })
79}
80
81func TestBrowserWalk(t *testing.T) {
82 rig := browserApp(t, nil)
83 rig.Run(chromedp.Navigate(rig.Origin + "/"))
84 rig.Screen("body", "home")
85}
86
87// TestLiveSearch types into the search box and checks the results change
88// WITHOUT a page load — the claim search.js makes. A marker on window survives
89// only if the page was never reloaded.
90func TestLiveSearch(t *testing.T) {
91 rig := browserApp(t, func(ctx context.Context, d *db.DB, cfg fichas.Config) {
92 m, err := fichas.EnsureMember(ctx, d.G, cfg.Sealer, TestOwner)
93 if err != nil {
94 t.Fatalf("member: %v", err)
95 }
96 for _, name := range []string{"Brightwater Labs", "Halden Robotics", "Oriel Housing Trust"} {
97 if _, err := fichas.CreateCard(ctx, d.G, cfg.Sealer, fichas.TypeCustomer, fichas.Person(m.ID),
98 map[string]string{fichas.FieldName: name}); err != nil {
99 t.Fatalf("seed: %v", err)
100 }
101 }
102 })
103
104 var marker bool
105 var results, location, stageHref, cardsHref string
106 rig.Run(
107 chromedp.Navigate(rig.Origin+"/"),
108 chromedp.WaitVisible(`input[name="q"]`),
109 chromedp.Evaluate[chromedp.Void](`window.__noReload = true`),
110 chromedp.SendKeys(`input[name="q"]`, "halden"),
111 chromedp.Sleep(600*time.Millisecond),
112 harness.Into(&results, chromedp.Text(`[data-live-results]`)),
113 harness.Into(&marker, chromedp.Evaluate[bool](`window.__noReload === true`)),
114 harness.Into(&location, chromedp.Evaluate[string](`location.search`)),
115 harness.Into(&stageHref, chromedp.Evaluate[string](`(document.querySelector('#list-filters a[href*="f_stage="]')||{}).getAttribute ? document.querySelector('#list-filters a[href*="f_stage="]').getAttribute('href') : ''`)),
116 harness.Into(&cardsHref, chromedp.Evaluate[string](`(function(){var a=[...document.querySelectorAll('#list-toolbar a')].find(function(x){return x.textContent.trim()==='Cards'});return a?a.getAttribute('href'):''})()`)),
117 )
118 // The tabs and filter menus must carry the TYPED search, not the one the
119 // page loaded with — or choosing a filter throws the search away.
120 if !strings.Contains(stageHref, "q=halden") {
121 t.Fatalf("after typing, the Stage filter links to %q, dropping the search", stageHref)
122 }
123 if !strings.Contains(cardsHref, "q=halden") {
124 t.Fatalf("after typing, the Cards tab links to %q, dropping the search", cardsHref)
125 }
126 if !marker {
127 t.Fatal("typing reloaded the page; search.js did not take over the search")
128 }
129 if !strings.Contains(results, "Halden Robotics") || strings.Contains(results, "Brightwater Labs") {
130 t.Fatalf("the results did not narrow as you typed:\n%s", results)
131 }
132 if !strings.Contains(location, "q=halden") {
133 t.Fatalf("the URL did not follow the search (location.search = %q)", location)
134 }
135 rig.Screen("body", "live-search")
136}
137
138// TestCmdEnterSubmits: ⌘↩ in a textarea submits its form.
139func TestCmdEnterSubmits(t *testing.T) {
140 var id int64
141 rig := browserApp(t, func(ctx context.Context, d *db.DB, cfg fichas.Config) {
142 m, _ := fichas.EnsureMember(ctx, d.G, cfg.Sealer, TestOwner)
143 c, err := fichas.CreateCard(ctx, d.G, cfg.Sealer, fichas.TypeCustomer, fichas.Person(m.ID),
144 map[string]string{fichas.FieldName: "Brightwater Labs"})
145 if err != nil {
146 t.Fatalf("seed: %v", err)
147 }
148 id = c.ID
149 })
150 var timeline string
151 path := rig.Origin + "/cards/" + itoa(id)
152 rig.Run(
153 chromedp.Navigate(path),
154 chromedp.WaitVisible(`textarea[name="f_body"]`),
155 chromedp.SendKeys(`textarea[name="f_body"]`, "Called about the pilot"),
156 chromedp.KeyEvent("\r", chromedp.KeyModifiers(chromedp.ModifierMeta)), // ⌘
157 chromedp.Sleep(800*time.Millisecond),
158 harness.Into(&timeline, chromedp.Text(`body`)),
159 )
160 if !strings.Contains(timeline, "Called about the pilot") {
161 t.Fatal("⌘↩ in the call-log textarea did not submit it")
162 }
163}
164
165func itoa(n int64) string {
166 b := []byte{}
167 if n == 0 {
168 return "0"
169 }
170 for n > 0 {
171 b = append([]byte{byte('0' + n%10)}, b...)
172 n /= 10
173 }
174 return string(b)
175}
176
177// TestAnExpiredSessionIsNotADeadEnd: when the list answer is a redirect to
178// sign-in, typing must land on sign-in rather than silently doing nothing.
179func TestAnExpiredSessionIsNotADeadEnd(t *testing.T) {
180 rig := browserApp(t, func(ctx context.Context, d *db.DB, cfg fichas.Config) {
181 m, _ := fichas.EnsureMember(ctx, d.G, cfg.Sealer, TestOwner)
182 fichas.CreateCard(ctx, d.G, cfg.Sealer, fichas.TypeCustomer, fichas.Person(m.ID),
183 map[string]string{fichas.FieldName: "Brightwater Labs"})
184 })
185 var path string
186 rig.Run(
187 chromedp.Navigate(rig.Origin+"/"),
188 chromedp.WaitVisible(`input[name="q"]`),
189 // Point the form at a URL that redirects, as an expired session's
190 // list request does, and type.
191 chromedp.Evaluate[chromedp.Void](`document.querySelector('[data-live-search] form').setAttribute('action', '/cards/new?type=nope')`),
192 chromedp.SendKeys(`input[name="q"]`, "x"),
193 chromedp.Sleep(900*time.Millisecond),
194 harness.Into(&path, chromedp.Evaluate[string](`location.pathname`)),
195 )
196 if path == "/" {
197 t.Fatal("a non-list answer left the page where it was; the search box is a dead end")
198 }
199}
200
201// TestNoZoomOnTap: iOS Safari zooms into any form control under 16px. On a
202// touch screen every text input must be at least 16px. Emulated as
203// pointer: coarse, which is how the CSS decides.
204func TestNoZoomOnTap(t *testing.T) {
205 // Both layouts: the app shell, and sign-in — the plain column with
206 // estilo's chrome, and the field every visit starts by tapping.
207 for _, page := range []struct{ path, ready string }{
208 {"/cards/new", `input[name="f_name"]`},
209 // A state of the door: AppForTest is signed in, and a bare /signin
210 // sends a signed-in browser on.
211 {"/signin?force=1", `input[name="address"]`},
212 // The list's search, and the type designer's forms.
213 {"/", `input[name="q"]`},
214 {"/cards/1", `textarea`},
215 {"/cards/1/edit", `input[name="f_name"]`},
216 {"/t/t_customer/fields/new", `input[name="label"]`}, // the options box shows only for a Choice
217 {"/types/new", `input[name="label"]`},
218 } {
219 // One card, so the list shows its search bar and there is a card
220 // to log a call against and to edit.
221 rig := browserApp(t, func(ctx context.Context, d *db.DB, cfg fichas.Config) {
222 m, err := fichas.EnsureMember(ctx, d.G, cfg.Sealer, TestOwner)
223 if err != nil {
224 t.Fatalf("member: %v", err)
225 }
226 if _, err := fichas.CreateCard(ctx, d.G, cfg.Sealer, fichas.TypeCustomer, fichas.Person(m.ID),
227 map[string]string{fichas.FieldName: "Brightwater Labs"}); err != nil {
228 t.Fatalf("seed: %v", err)
229 }
230 })
231 var smallest float64
232 var coarse bool
233 rig.Run(
234 chromedp.Navigate(rig.Origin+page.path),
235 chromedp.WaitVisible(page.ready),
236 // Touch emulation, then a reload so the page re-evaluates its
237 // media queries. SetEmulatedMedia's "pointer" feature is not
238 // emulated by this Chromium: the first version measured
239 // desktop styles while claiming a phone's. The coarse check
240 // is what caught it.
241 send(emulation.SetTouchEmulationEnabled, emulation.SetTouchEmulationEnabledParams{Enabled: true, MaxTouchPoints: 5}),
242 chromedp.Reload(),
243 chromedp.WaitVisible(page.ready),
244 harness.Into(&coarse, chromedp.Evaluate[bool](`matchMedia('(pointer: coarse)').matches`)),
245 harness.Into(&smallest, chromedp.Evaluate[float64](`Math.min(...[...document.querySelectorAll('input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea')].map(e => parseFloat(getComputedStyle(e).fontSize)))`)),
246 )
247 if !coarse {
248 t.Fatalf("%s: the touch-screen emulation did not apply; this would measure desktop styles", page.path)
249 }
250 if smallest < 16 {
251 t.Errorf("%s: a form control is %.1fpx on a touch screen; iOS will zoom when it is tapped", page.path, smallest)
252 }
253 }
254}
255
256// TestTheAccountMenuInTheBar: the account sits at the bar's end (level-up
257// §3.1), at every width the whole panel is on screen and its Sign out is
258// the thing a tap at its centre reaches; Escape closes it and gives focus
259// back to its trigger, and a click outside closes it.
260func TestTheAccountMenuInTheBar(t *testing.T) {
261 type facts struct {
262 Open bool
263 PanelTop, PanelLeft float64
264 PanelRite, VW float64
265 SignOutHit, EdgesHit bool
266 }
267 const measure = `(() => {
268 const d = document.querySelector('[estilo-bar] [estilo-account]'), p = d.querySelector('[estilo-account-panel]')
269 const out = d.querySelector('form[action="/signout"] button')
270 out.scrollIntoView({block: 'nearest'})
271 const or = out.getBoundingClientRect(), hit = document.elementFromPoint(or.left + or.width / 2, or.top + or.height / 2)
272 const pr = p.getBoundingClientRect(), mid = (pr.top + pr.bottom) / 2
273 const inP = (x) => { const h = document.elementFromPoint(x, mid); return !!h && p.contains(h) }
274 return {Open: d.open, PanelTop: pr.top, PanelLeft: pr.left, PanelRite: pr.right, VW: document.documentElement.clientWidth,
275 SignOutHit: !!hit && out.contains(hit), EdgesHit: inP(pr.left + 2) && inP(pr.right - 2)}
276 })()`
277 for _, w := range []int64{1440, 390, 320} {
278 rig := browserApp(t, nil)
279 var f facts
280 var closedByEscape, focusBack, closedByOutside bool
281 rig.Run(
282 send(emulation.SetDeviceMetricsOverride, emulation.SetDeviceMetricsOverrideParams{Width: w, Height: 800, DeviceScaleFactor: 1}),
283 chromedp.Navigate(rig.Origin+"/"),
284 chromedp.WaitVisible(`[estilo-bar] [estilo-account] > summary`),
285 chromedp.Click(`[estilo-bar] [estilo-account] > summary`),
286 chromedp.Sleep(150*time.Millisecond),
287 harness.Into(&f, chromedp.Evaluate[facts](measure)),
288 chromedp.KeyEvent("\x1b"),
289 chromedp.Sleep(100*time.Millisecond),
290 harness.Into(&closedByEscape, chromedp.Evaluate[bool](`!document.querySelector('[estilo-account]').open`)),
291 harness.Into(&focusBack, chromedp.Evaluate[bool](`document.activeElement === document.querySelector('[estilo-account] > summary')`)),
292 chromedp.Click(`[estilo-bar] [estilo-account] > summary`),
293 chromedp.Sleep(100*time.Millisecond),
294 chromedp.MouseClickXY(20, 700),
295 chromedp.Sleep(100*time.Millisecond),
296 harness.Into(&closedByOutside, chromedp.Evaluate[bool](`!document.querySelector('[estilo-account]').open`)),
297 )
298 if !f.Open {
299 t.Fatalf("%dpx: the account menu did not open", w)
300 }
301 if f.PanelTop < 0 || f.PanelLeft < 0 || f.PanelRite > f.VW+0.5 {
302 t.Errorf("%dpx: the panel is partly off screen: %+v", w, f)
303 }
304 if !f.EdgesHit {
305 t.Errorf("%dpx: the panel's edge is clipped or covered (%.0f..%.0f)", w, f.PanelLeft, f.PanelRite)
306 }
307 if !f.SignOutHit {
308 t.Errorf("%dpx: a tap at Sign out's centre does not reach it", w)
309 }
310 if !closedByEscape || !focusBack {
311 t.Errorf("%dpx: Escape closed it: %v; focus back on its trigger: %v", w, closedByEscape, focusBack)
312 }
313 if !closedByOutside {
314 t.Errorf("%dpx: a click outside left it open", w)
315 }
316 }
317}
318
319// send is one protocol command as a step: chromedp v0.21's commands are
320// values, not actions.
321func send[P any](command cdp.Command[P, cdp.Empty], params P) chromedp.Action[chromedp.Void] {
322 return chromedp.Func(func(ctx context.Context, target *chromedp.Target) error {
323 _, err := cdp.Call(ctx, target, command, params)
324 return err
325 })
326}
327
328// TestTheNameOpensTheCardAndACellEdits: the name opens the card beside
329// the list (level-up §5.4, D1), and a click on any other cell edits it in
330// place and opens nothing (Q10, ruled 2026-11-17).
331func TestTheNameOpensTheCardAndACellEdits(t *testing.T) {
332 var id int64
333 rig := browserApp(t, func(ctx context.Context, d *db.DB, cfg fichas.Config) {
334 m, _ := fichas.EnsureMember(ctx, d.G, cfg.Sealer, TestOwner)
335 c, err := fichas.CreateCard(ctx, d.G, cfg.Sealer, fichas.TypeCustomer, fichas.Person(m.ID),
336 map[string]string{fichas.FieldName: "Brightwater Labs", fichas.FieldDomain: "brightwater.example", fichas.FieldPhone: "+353 1 555 0142"})
337 if err != nil {
338 t.Fatalf("seed: %v", err)
339 }
340 id = c.ID
341 })
342 var editing bool
343 var before, search string
344 rig.Run(
345 send(emulation.SetDeviceMetricsOverride, emulation.SetDeviceMetricsOverrideParams{Width: 1440, Height: 900, DeviceScaleFactor: 1}),
346 chromedp.Navigate(rig.Origin+"/"),
347 chromedp.WaitVisible(`[fichas-grid][role="grid"] tbody tr`),
348 harness.Into(&before, chromedp.Evaluate[string](`location.pathname + location.search`)),
349 chromedp.Click(`[fichas-grid] td[data-field="f_phone"]`),
350 chromedp.WaitVisible(`[fichas-editor] input`),
351 harness.Into(&editing, chromedp.Evaluate[bool](`document.activeElement === document.querySelector('[fichas-editor] input') && location.pathname + location.search === `+"`"+`/`+"`"+``)),
352 chromedp.KeyEvent("\x1b"),
353 chromedp.Click(`[fichas-title-link]`),
354 chromedp.WaitVisible(`[fichas-pane] [fichas-quiet-title]`),
355 harness.Into(&search, chromedp.Evaluate[string](`location.search`)),
356 )
357 if !editing {
358 t.Error("a click on the phone cell did not open its editor in place")
359 }
360 if search != "?card="+itoa(id) {
361 t.Fatalf("the name opened %q, want the card beside the list", search)
362 }
363}
364
365// TestRailIconsSitOnTheTextsCentreLine: each rail link's icon is centred
366// on its label. rastrillo v0.35's display: block on these links once put
367// every icon on the text's baseline, 3.5px high, unnoticed by any test.
368func TestRailIconsSitOnTheTextsCentreLine(t *testing.T) {
369 rig := browserApp(t, nil)
370 var offsets []float64
371 rig.Run(
372 // A desktop width: below 800px the rail folds behind Menu.
373 send(emulation.SetDeviceMetricsOverride, emulation.SetDeviceMetricsOverrideParams{Width: 1440, Height: 800, DeviceScaleFactor: 1}),
374 chromedp.Navigate(rig.Origin+"/"),
375 chromedp.WaitVisible(`[fichas-rail] a[fichas-rail-item]`),
376 harness.Into(&offsets, chromedp.Evaluate[[]float64](`[...document.querySelectorAll('[fichas-rail] a[fichas-rail-item]')].map(a => {
377 const i = a.querySelector('svg').getBoundingClientRect()
378 const r = document.createRange(); r.selectNodeContents(a.querySelector('[fichas-rail-label]')); const tx = r.getBoundingClientRect()
379 return (i.top + i.height / 2) - (tx.top + tx.height / 2)
380 })`)),
381 )
382 if len(offsets) < 2 {
383 t.Fatalf("the rail has %d links; want the types and New type", len(offsets))
384 }
385 for i, off := range offsets {
386 if off < -1 || off > 1 {
387 t.Errorf("rail link %d: its icon is %.1fpx off its label's centre line", i, off)
388 }
389 }
390}
391
392// TestChoiceOptionsShowOnlyForAChoice: the add-field form shows the box
393// for a Choice's options only while Choice is picked, with no script.
394func TestChoiceOptionsShowOnlyForAChoice(t *testing.T) {
395 rig := browserApp(t, nil)
396 var before, after bool
397 const shown = `getComputedStyle(document.querySelector('[fichas-choice-options]')).display !== 'none'`
398 rig.Run(
399 chromedp.Navigate(rig.Origin+"/t/t_customer/fields/new"),
400 chromedp.WaitVisible(`input[name="label"]`),
401 harness.Into(&before, chromedp.Evaluate[bool](shown)),
402 chromedp.Evaluate[chromedp.Void](`document.querySelector('input[name="kind"][value="enum"]').click()`),
403 harness.Into(&after, chromedp.Evaluate[bool](shown)),
404 )
405 if before {
406 t.Error("the options box shows while Text is picked")
407 }
408 if !after {
409 t.Error("the options box does not show once Choice is picked")
410 }
411}
412
413// TestPrimaryButtonsAreFilled: a form's primary submit is filled with the
414// accent, and a danger submit is not a plain white pill. rst-btn's value
415// is a word list ("primary lg"); the depth styles once matched only
416// rst-btn="primary" exactly and turned every form's Save white.
417func TestPrimaryButtonsAreFilled(t *testing.T) {
418 var id int64
419 rig := browserApp(t, func(ctx context.Context, d *db.DB, cfg fichas.Config) {
420 m, _ := fichas.EnsureMember(ctx, d.G, cfg.Sealer, TestOwner)
421 c, err := fichas.CreateCard(ctx, d.G, cfg.Sealer, fichas.TypeCustomer, fichas.Person(m.ID), map[string]string{fichas.FieldName: "Brightwater Labs"})
422 if err != nil {
423 t.Fatalf("seed: %v", err)
424 }
425 id = c.ID
426 })
427 const fill = `(() => {
428 const probe = document.createElement('span'); probe.style.color = 'var(--rst-accent)'; document.body.append(probe)
429 const accent = getComputedStyle(probe).color; probe.remove()
430 const b = document.querySelector('[rst-page] form [rst-btn~="primary"], [rst-page] form [rst-btn~="danger"]')
431 return { bg: getComputedStyle(b).backgroundColor, accent, label: b.textContent.trim() }
432 })()`
433 type facts struct{ Bg, Accent, Label string }
434 for _, page := range []string{"/cards/new?type=t_customer", "/t/t_customer/fields/new", "/cards/" + itoa(id) + "/delete"} {
435 var f facts
436 rig.Run(
437 chromedp.Navigate(rig.Origin+page),
438 chromedp.WaitVisible(`[rst-page] form [rst-btn]`),
439 harness.Into(&f, chromedp.Evaluate[facts](fill)),
440 )
441 if strings.HasSuffix(page, "/delete") {
442 if f.Bg == "rgb(255, 255, 255)" || f.Bg == "rgba(0, 0, 0, 0)" {
443 t.Errorf("%s: the danger button %q is not filled (%s)", page, f.Label, f.Bg)
444 }
445 continue
446 }
447 if f.Bg != f.Accent {
448 t.Errorf("%s: the primary %q is %s, not the accent %s", page, f.Label, f.Bg, f.Accent)
449 }
450 }
451}
452
453// TestTheViewTabsSitInTheToolbarsRow: rastrillo puts a margin under a
454// block of tabs, and in the list's toolbar row it only pushed the row
455// apart and lifted the tabs off its centre line (Calendar's 18px gap,
456// oficina/calendar #48). Mutation: deleting the fichas.css rule fails it.
457func TestTheViewTabsSitInTheToolbarsRow(t *testing.T) {
458 rig := browserApp(t, func(ctx context.Context, d *db.DB, cfg fichas.Config) {
459 m, _ := fichas.EnsureMember(ctx, d.G, cfg.Sealer, TestOwner)
460 fichas.CreateCard(ctx, d.G, cfg.Sealer, fichas.TypeCustomer, fichas.Person(m.ID),
461 map[string]string{fichas.FieldName: "Brightwater Labs"})
462 })
463 var margin string
464 var offset float64
465 rig.Run(
466 chromedp.Navigate(rig.Origin+"/?view=cards"),
467 chromedp.WaitVisible(`[fichas-toolbar] [rst-seg-tabs]`),
468 harness.Into(&margin, chromedp.Evaluate[string](`getComputedStyle(document.querySelector('[fichas-toolbar] > [rst-seg-tabs]')).marginBlockEnd`)),
469 harness.Into(&offset, chromedp.Evaluate[float64](`(() => {
470 const bar = document.querySelector('[fichas-toolbar]').getBoundingClientRect();
471 const tabs = document.querySelector('[fichas-toolbar] > [rst-seg-tabs]').getBoundingClientRect();
472 return Math.abs((tabs.top + tabs.bottom) / 2 - (bar.top + bar.bottom) / 2);
473 })()`)),
474 )
475 if margin != "0px" {
476 t.Errorf("the view tabs keep a %s margin under them in the toolbar row", margin)
477 }
478 if offset > 1 {
479 t.Errorf("the view tabs sit %.1fpx off the toolbar's centre line", offset)
480 }
481}
482