oficina / fichas Public

Rhythm review fixes: the edit form's fields a step apart, and the audit wider

Fable's review of c5e05e9 (APPROVE AFTER FIXES, no High):

- M1: the edit form wrote each field's hidden was input between it and
  the field before, which hid that field from the stack's rule, so its
  fields sat at the 8px floor (12px on the new-card form). The was
  inputs now come first, beside return_to. TestTheFormsFieldsAreAStepApart
  measures every two fields (and a conflict's fieldset) at --rst-sp-3 on
  the edit form, after a conflict and on the new-card form; it fails with
  the inputs interleaved (8px). No other stack in Fichas interleaves them;
  AGENTS.md says to write hidden inputs first.
- L1: contract_prepare's box and its fields form are stacks, and its two
  GET phases are in the audit (the rig mounts the release). Its signed
  phases are named as the exception in AGENTS.md.
- L2: the scriptless rows switch page scripts off (scriptsOn(false)),
  wait on server markup and switch them back; the edit form has one too.
- L3: the audit reads a new field as a Choice with Advanced open, and the
  server's errors on a new card, a new field and a new type.
- L4: the card's pane keeps --rst-sp-5 inline at every width, so at 1440
  the card beside the list has its four field columns again.
- L5: the View menu's density buttons and column checks are at least
  2rem, and 44px on a phone.
- L6: the rail's allowances quote level-up R1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev a86faa9431ff151367bbaa0e743ff041fb0c4998 parent c5e05e9
8 files changed, +185 −52
  • AGENTS.md +5 −2
  • internal/fichas/static/fichas.css +6 −0
  • internal/fichas/static/frame.css +2 −2
  • internal/fichas/static/grid.css +0 −1
  • internal/fichas/templates/card_edit.html +5 −1
  • internal/fichas/templates/contract_prepare.html +2 −2
  • internal/fichastest/browser_rhythm_test.go +156 −44
  • internal/fichastest/browser_test.go +9 −0

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.352s
?   	amadan.net/oficina/fichas/internal/fichas/icons	[no test files]
ok  	amadan.net/oficina/fichas/internal/fichas/locale	0.007s
ok  	amadan.net/oficina/fichas/internal/fichas/seal	(cached)
ok  	amadan.net/oficina/fichas/internal/fichastest	2.614s
?   	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
=== spacing ===
go tool fiesta spacing \
	-skip tokens.css -skip shell.css \
	-skip theme.css -skip busy.css -skip chrome.css -skip menu.css \
	-skip sky.css -skip savestatus.css -skip brand/brand.css \
	internal/fichas/static
diff --git a/AGENTS.md b/AGENTS.md
index 9d23d61..28d2d28 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -76,8 +76,11 @@ mechanically.
margin, padding and gap is `var(--rst-sp-N)` or carries a
`/* spacing-allow: why */`. `make spacing` (in `make ci`) checks the
stylesheets; `TestTheScreensKeepTheRhythm` (in `make browser`) runs
- Fiesta's rhythm audit over every screen at 1440 and 390px. A new
- screen joins its list.
+ Fiesta's rhythm audit over every screen at 1440 and 390px (the
+ contract's last two phases excepted: they need a signed release). A
+ new screen joins its list. A hidden input between two of a stack's
+ blocks hides the first from the stack's rule (the second falls to its
+ 8px floor): write hidden inputs first, as the edit form does.
## Serving
diff --git a/internal/fichas/static/fichas.css b/internal/fichas/static/fichas.css
index 65354a1..9460198 100644
--- a/internal/fichas/static/fichas.css
+++ b/internal/fichas/static/fichas.css
@@ -269,6 +269,7 @@
background: var(--rst-surface-2);
}
[fichas-view-seg] button {
+ min-block-size: 2rem;
padding: var(--rst-sp-1) var(--rst-sp-2);
border: 0;
border-radius: 6px;
@@ -289,11 +290,16 @@
[fichas-view-check] {
display: flex;
align-items: center;
+ min-block-size: 2rem;
gap: var(--rst-sp-2);
padding: var(--rst-sp-1) 0;
font-size: var(--rst-fs-sm);
cursor: pointer;
}
+/* A phone's finger: the View menu's targets at 44px (level-up §5.8). */
+@media (max-width: 799.98px) {
+ [fichas-view-seg] button, [fichas-view-check] { min-block-size: 44px; }
+}
[fichas-view-check]:has(input:disabled) { color: var(--rst-text-muted); cursor: default; }
/* The dropdown styles every button in it as a menu row; this one is the
panel's action, filled as a primary is. */
diff --git a/internal/fichas/static/frame.css b/internal/fichas/static/frame.css
index c5f258e..7598c7b 100644
--- a/internal/fichas/static/frame.css
+++ b/internal/fichas/static/frame.css
@@ -49,10 +49,10 @@
display: grid;
grid-template-columns: 16px minmax(0, 1fr) auto;
align-items: center;
- /* spacing-allow: level-up R1, the rail's rows keep today's grid: the icon 10px from its label */
+ /* spacing-allow: level-up spec R1, "its rows keep today's grid": the icon 10px from its label */
gap: 10px;
min-block-size: 36px;
- /* spacing-allow: level-up R1, today's grid: the icon column 10px in from the row's edge, its highlight */
+ /* spacing-allow: level-up spec R1, "its rows keep today's grid": the icon 10px in from the row's highlight */
padding: 0 10px;
border: 0;
border-radius: 8px;
diff --git a/internal/fichas/static/grid.css b/internal/fichas/static/grid.css
index a3a1249..83972dc 100644
--- a/internal/fichas/static/grid.css
+++ b/internal/fichas/static/grid.css
@@ -137,7 +137,6 @@
[fichas-narrow-list] a[aria-current] { background: var(--rst-accent-soft); border-inline-start-color: var(--rst-accent); }
[fichas-narrow-face] { display: flex; align-items: center; gap: var(--rst-sp-2); font-size: var(--rst-fs-sm); }
[fichas-pane] { padding: var(--rst-sp-5) var(--rst-sp-5) var(--rst-sp-6); min-inline-size: 0; }
-@media (min-width: 1280px) { [fichas-pane] { padding-inline: var(--rst-sp-6); } }
[fichas-full-card] { max-inline-size: 64rem; }
[fichas-card-top] { display: flex; align-items: center; gap: var(--rst-sp-2); flex-wrap: wrap; }
diff --git a/internal/fichas/templates/card_edit.html b/internal/fichas/templates/card_edit.html
index 602ec71..12f96e4 100644
--- a/internal/fichas/templates/card_edit.html
+++ b/internal/fichas/templates/card_edit.html
@@ -12,8 +12,12 @@
conflict, each conflicting field offers theirs and mine. */}}
<form method="post" action="/cards/{{$c.Card.ID}}" fichas-form rst-stack novalidate>
<input type="hidden" name="return_to" value="{{.ReturnTo}}">
+ {{/* Every was first, beside return_to: a hidden input between two
+ fields hides the first from the stack's rule, and the second would
+ sit at the stack's 8px gap, not a field's 12px. */}}
+ {{range $f := $c.Fields}}<input type="hidden" name="was.{{$f.Def.Key}}" value="{{index $.Was $f.Def.Key}}">
+ {{end}}
{{range $f := $c.Fields}}
- <input type="hidden" name="was.{{$f.Def.Key}}" value="{{index $.Was $f.Def.Key}}">
{{with index $.Conflicts $f.Def.Key}}
<fieldset fichas-conflict id="{{$f.Def.Key}}">
<legend>{{$f.Label}}</legend>
diff --git a/internal/fichas/templates/contract_prepare.html b/internal/fichas/templates/contract_prepare.html
index 4375806..65ae6f0 100644
--- a/internal/fichas/templates/contract_prepare.html
+++ b/internal/fichas/templates/contract_prepare.html
@@ -1,9 +1,9 @@
{{define "title"}}Prepare contract · Fichas{{end}}
{{define "content"}}
<header fichas-appbar><h1 fichas-appbar-title>Prepare a contract <span>Selected customer details → Oficina Docs</span></h1></header>
-<div rst-box>
+<div rst-box rst-stack>
{{if eq .Phase "choose"}}<h2>Choose a live customer</h2><p>Select the customer whose details belong in this agreement.</p>{{range .Cards}}<p><a rst-btn href="/contracts/prepare?flow={{$.Flow}}&amp;card={{.Card.ID}}">{{.Title}} →</a></p>{{else}}<p>No customer cards are available.</p>{{end}}{{end}}
-{{if eq .Phase "fields"}}<h2>{{.Card.Title}}</h2><p>Choose the fields to use. Notes and call entries are not included automatically.</p><form method="post" action="/contracts/review"><input type="hidden" name="flow" value="{{.Flow}}"><input type="hidden" name="card" value="{{.Card.Card.ID}}"><input type="hidden" name="revision" value="{{.Card.Card.Revision}}">
+{{if eq .Phase "fields"}}<h2>{{.Card.Title}}</h2><p>Choose the fields to use. Notes and call entries are not included automatically.</p><form method="post" action="/contracts/review" rst-stack><input type="hidden" name="flow" value="{{.Flow}}"><input type="hidden" name="card" value="{{.Card.Card.ID}}"><input type="hidden" name="revision" value="{{.Card.Card.Revision}}">
{{range .Card.Fields}}{{if or (eq .Def.Kind "text") (eq .Def.Kind "date") (eq .Def.Kind "email") (eq .Def.Kind "phone")}}<p><label><input type="checkbox" name="field" value="{{.Def.Key}}" {{if eq .Def.Key "f_name"}}checked{{end}}> <strong>{{.Label}}</strong> — {{.Value}}</label></p>{{end}}{{end}}
<button rst-btn="primary">Review selected details →</button></form>{{end}}
{{if eq .Phase "review"}}<h2>Approve these details for your contract</h2><dl rst-detail>{{range .Release.Fields}}<dt>{{.Label}}</dt><dd>{{.Value}}</dd>{{end}}</dl><p>Destination: <strong>{{.Destination}}</strong><br>Importer and signer: <strong>{{.Importer}}</strong><br>Source revision: {{.Release.Revision}}</p><p>This authorises these selected values for one contract you sign yourself. Docs must issue it within 30 minutes. Later edits or deletion in Fichas will not retract this approved copy. There is no external-recipient access in this pilot.</p><p>Issued demo records are available for seven days. Existing encrypted backups follow the app’s backup policy; deletion from this screen cannot recall downloaded copies or guarantee backup erasure.</p><form method="post" action="/contracts/approve"><input type="hidden" name="payload" value="{{.Payload}}"><input type="hidden" name="signature" value="{{.Signature}}"><button rst-btn="primary">Approve these details</button></form>{{end}}
diff --git a/internal/fichastest/browser_rhythm_test.go b/internal/fichastest/browser_rhythm_test.go
index aacdd19..824a76f 100644
--- a/internal/fichastest/browser_rhythm_test.go
+++ b/internal/fichastest/browser_rhythm_test.go
@@ -3,9 +3,11 @@
package fichastest
import (
- "cmp"
"context"
+ "crypto/ed25519"
+ "crypto/rand"
"fmt"
+ "math"
"testing"
"time"
@@ -25,28 +27,47 @@ import (
// Name a region here only if it is a component's internals.
var rhythmSkip []string
-// asWithoutScript puts the card back as it is drawn with scripts off:
-// grid.js marks the page live (data-fichas-live) and the card's Save
-// changes button goes, as each field saves on its own. Page scripts
-// cannot be switched off for the audit, which is itself a script.
-const asWithoutScript = `document.body.removeAttribute("data-fichas-live")`
+// contractFlow is any well-formed flow: the contract's first two phases
+// (choose a customer, choose its fields) are GETs a signed-in person
+// reaches with one. Its last two need a signed release, so the audit
+// reads the phases a person sees first.
+const contractFlow = "00000000-0000-4000-8000-000000000000"
+
+// rhythmScreen is one state of one screen: the path, what to wait for
+// once it is drawn, whether page scripts run, and an optional step in
+// the page (open Advanced, submit a form) and what to wait for after it.
+type rhythmScreen struct {
+ name, path, ready string
+ noScript bool
+ act, then string
+}
// TestTheScreensKeepTheRhythm: Fiesta's rhythm audit (Paul, 2026-11-22:
// "Can we somehow put something in place to avoid weird spacing issues
// like this in future?") over Fichas' own screens: the grid, the cards
-// view, the card beside the list, the card's own page, its History and
-// every form (a card's, a field's, a type's, the card layout), at a
-// desktop width and a phone's, with scripts on. Every gap between
-// two blocks is a step of the scale, no text rests on a control, and
-// every heading sits closer to its content than to what comes before.
+// view, the card beside the list and on its own page (with scripts and
+// without), its History, every form (a card's, a field's, a type's, the
+// card layout, the contract's first two phases) with Advanced open, the
+// choices box shown and the server's errors drawn, at a desktop width
+// and a phone's. Every gap between two blocks is a step of the scale, no
+// text rests on a control, and every heading sits closer to its content
+// than to what comes before.
//
-// It failed on main before the rhythm swap (b/ 2026-11-22): the card's
-// heading, meta line, fields and call log were 14, 28 and 10px apart,
-// and the grid's help line sat 11.2px over the count.
+// It failed on main before the rhythm swap (95 findings, 2026-11-22):
+// the card's heading, meta line, fields and call log were 14, 28 and
+// 10px apart, and the grid's help line sat 11.2px over the count.
func TestTheScreensKeepTheRhythm(t *testing.T) {
var id int64
var empty string
- rig := browserApp(t, func(ctx context.Context, d *db.DB, cfg fichas.Config) {
+ // The contract's release is configured, so its pages are mounted.
+ _, key, err := ed25519.GenerateKey(rand.Reader)
+ if err != nil {
+ t.Fatal(err)
+ }
+ release := func(cfg *fichas.Config) {
+ cfg.ContractRelease = &fichas.ContractReleaseConfig{Destination: "https://docs.example.com", Importer: TestOwner, Team: "test-team", Key: key}
+ }
+ rig := browserAppWith(t, release, func(ctx context.Context, d *db.DB, cfg fichas.Config) {
m, err := fichas.EnsureMember(ctx, d.G, cfg.Sealer, TestOwner)
if err != nil {
t.Fatalf("member: %v", err)
@@ -74,38 +95,46 @@ func TestTheScreensKeepTheRhythm(t *testing.T) {
})
card := cardPath(id)
split := "/t/t_customer?sort=f_name&card=" + itoa(id)
- screens := []struct{ name, path, ready, prep string }{
- {"the grid", "/t/t_customer?sort=f_name", `[fichas-grid] tbody tr`, ""},
- {"the grid under a notice", "/t/t_customer?sort=f_name&saved=1", `[fichas-notice]`, ""},
- {"a type with no cards", "/t/" + empty, `[rst-empty]`, ""},
- {"the cards view", "/t/t_customer?sort=f_name&view=cards", `[fichas-card-grid]`, ""},
- {"the card beside the list", split, `[fichas-pane] form[data-card-ready]`, ""},
- {"the card beside the list, as without script", split, `[fichas-pane] form[data-card-ready]`, asWithoutScript},
- {"the card beside the list under a notice", split + "&saved=1", `[fichas-pane] form[data-card-ready]`, ""},
- {"the card's page", card, `form[data-card-ready]`, ""},
- {"the card's page, as without script", card, `form[data-card-ready]`, asWithoutScript},
- {"the card's History", card + "/history", `[fichas-history]`, ""},
- {"the card's edit form", card + "/edit", `form[fichas-form]`, ""},
- {"Delete, confirmed", card + "/delete", `[fichas-appbar]`, ""},
- {"a new card", "/cards/new?type=t_customer", `form[fichas-form]`, ""},
- {"the fields", "/t/t_customer/fields", `[fichas-grid]`, ""},
- {"a new field", "/t/t_customer/fields/new", `form[fichas-form]`, ""},
- {"a field's edit form", "/fields/" + fichas.FieldStage + "/edit", `form[fichas-form]`, ""},
- {"a new type", "/types/new", `form[fichas-form]`, ""},
- {"the card layout", "/t/t_customer/layout", `[fichas-layout-editor]`, ""},
+ // submit sends a form past the browser's own checks, so the server's
+ // errors are what is drawn.
+ submit := func(form string) string {
+ return `HTMLFormElement.prototype.submit.call(document.querySelector(` + "`" + form + "`" + `))`
+ }
+ screens := []rhythmScreen{
+ {name: "the grid", path: "/t/t_customer?sort=f_name", ready: `[fichas-grid][role="grid"] tbody tr`},
+ {name: "the grid under a notice", path: "/t/t_customer?sort=f_name&saved=1", ready: `[fichas-notice]`},
+ {name: "a type with no cards", path: "/t/" + empty, ready: `[rst-empty]`},
+ {name: "the cards view", path: "/t/t_customer?sort=f_name&view=cards", ready: `[fichas-card-grid]`},
+ {name: "the card beside the list", path: split, ready: `[fichas-pane] form[data-card-ready]`},
+ {name: "the card beside the list, without script", path: split, ready: `[fichas-pane] [fichas-card-save]`, noScript: true},
+ {name: "the card beside the list under a notice", path: split + "&saved=1", ready: `[fichas-pane] form[data-card-ready]`},
+ {name: "the card's page", path: card, ready: `form[data-card-ready]`},
+ {name: "the card's page, without script", path: card, ready: `[fichas-card-save]`, noScript: true},
+ {name: "the card's History", path: card + "/history", ready: `[fichas-history]`},
+ {name: "the card's edit form", path: card + "/edit", ready: `form[fichas-form]`},
+ {name: "the card's edit form, without script", path: card + "/edit", ready: `form[fichas-form]`, noScript: true},
+ {name: "Delete, confirmed", path: card + "/delete", ready: `[fichas-appbar]`},
+ {name: "a new card", path: "/cards/new?type=t_customer", ready: `form[fichas-form]`},
+ {name: "a new card, refused", path: "/cards/new?type=t_customer", ready: `form[fichas-form]`,
+ act: submit(`form[fichas-form]`), then: `[rst-field-error]`},
+ {name: "the fields", path: "/t/t_customer/fields", ready: `[fichas-grid]`},
+ {name: "a new field", path: "/t/t_customer/fields/new", ready: `form[fichas-form]`},
+ {name: "a new field, a Choice, Advanced open", path: "/t/t_customer/fields/new", ready: `form[fichas-form]`,
+ act: `document.querySelector('input[name="kind"][value="enum"]').checked = true; document.querySelector('[fichas-advanced]').open = true`,
+ then: `[fichas-choice-options] textarea`},
+ {name: "a new field, refused", path: "/t/t_customer/fields/new", ready: `form[fichas-form]`,
+ act: submit(`form[fichas-form]`), then: `[rst-field-error]`},
+ {name: "a field's edit form", path: "/fields/" + fichas.FieldStage + "/edit", ready: `form[fichas-form]`},
+ {name: "a new type", path: "/types/new", ready: `form[fichas-form]`},
+ {name: "a new type, refused", path: "/types/new", ready: `form[fichas-form]`,
+ act: submit(`form[fichas-form]`), then: `[rst-field-error]`},
+ {name: "the card layout", path: "/t/t_customer/layout", ready: `[fichas-layout-editor]`},
+ {name: "a contract: choose a customer", path: "/contracts/prepare?flow=" + contractFlow, ready: `[rst-box]`},
+ {name: "a contract: choose its fields", path: "/contracts/prepare?flow=" + contractFlow + "&card=" + itoa(id), ready: `[rst-box] form`},
}
for _, width := range []int64{1440, 390} {
for _, s := range screens {
- ctx, cancel := context.WithTimeout(rig.Context(), 30*time.Second)
- var found []rhythm.Finding
- err := chromedp.Do(ctx,
- viewport(width),
- chromedp.Navigate(rig.Origin+s.path),
- chromedp.WaitVisible(chromedp.CSS(s.ready)),
- chromedp.Evaluate[chromedp.Void](cmp.Or(s.prep, "0")),
- harness.Into(&found, chromedp.Evaluate[[]rhythm.Finding](
- rhythm.Expression("main", rhythm.Options{Skip: rhythmSkip}))))
- cancel()
+ found, err := auditScreen(rig, width, s)
if err != nil {
t.Fatalf("%s at %dpx: %v", s.name, width, err)
}
@@ -115,3 +144,86 @@ func TestTheScreensKeepTheRhythm(t *testing.T) {
}
}
}
+
+// auditScreen draws one screen state and reads the audit over main.
+// Scripts are switched back on afterwards, whatever happened.
+func auditScreen(rig *harness.Rig, width int64, s rhythmScreen) ([]rhythm.Finding, error) {
+ ctx, cancel := context.WithTimeout(rig.Context(), 30*time.Second)
+ defer cancel()
+ defer rig.Run(scriptsOn(true))
+ steps := []chromedp.Action[chromedp.Void]{scriptsOn(!s.noScript), viewport(width), chromedp.Navigate(rig.Origin + s.path)}
+ if s.noScript {
+ // No page script, so no script-made marker: wait on the server's
+ // markup, through the DOM domain.
+ steps = append(steps, chromedp.WaitReady(chromedp.CSS(s.ready)))
+ } else {
+ steps = append(steps, chromedp.WaitVisible(chromedp.CSS(s.ready)))
+ }
+ if s.act != "" {
+ steps = append(steps, chromedp.Evaluate[chromedp.Void](s.act), chromedp.WaitVisible(chromedp.CSS(s.then)))
+ }
+ var found []rhythm.Finding
+ steps = append(steps, harness.Into(&found, chromedp.Evaluate[[]rhythm.Finding](
+ rhythm.Expression("main", rhythm.Options{Skip: rhythmSkip}))))
+ return found, chromedp.Do(ctx, steps...)
+}
+
+// fieldGaps is the space between each two neighbouring fields (rst-field
+// or a conflict's fieldset) of a form, and the scale's --rst-sp-3 in px.
+const fieldGaps = `(() => {
+ const form = document.querySelector('form[fichas-form]');
+ const root = parseFloat(getComputedStyle(document.documentElement).fontSize);
+ const step = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--rst-sp-3')) * root;
+ const field = e => e.hasAttribute('rst-field') || e.hasAttribute('fichas-conflict');
+ const kids = [...form.children].filter(e => e.getBoundingClientRect().height > 0);
+ const gaps = [];
+ for (let i = 1; i < kids.length; i++) {
+ if (field(kids[i - 1]) && field(kids[i])) gaps.push(kids[i].getBoundingClientRect().top - kids[i - 1].getBoundingClientRect().bottom);
+ }
+ return {step, gaps};
+})()`
+
+// TestTheFormsFieldsAreAStepApart: the rhythm audit cannot see a gap that
+// is on the scale but the wrong step. The edit form once wrote each
+// field's hidden "was" input between it and the field before, which hid
+// that field from the stack's rule: its fields sat at the stack's 8px
+// floor, where the new-card form's sit at --rst-sp-3 (Fable, the rhythm
+// swap's review, M1). Every two fields, and a conflict's fieldset beside
+// a field, are --rst-sp-3 apart, on the edit form, after a conflict, and
+// on the new-card form.
+func TestTheFormsFieldsAreAStepApart(t *testing.T) {
+ s := seedCards(t, 1)
+ type spacing struct {
+ Step float64 `json:"step"`
+ Gaps []float64 `json:"gaps"`
+ }
+ check := func(name string, got spacing) {
+ t.Helper()
+ if len(got.Gaps) < 4 {
+ t.Fatalf("%s: %d gaps between fields; this test would pass vacuously", name, len(got.Gaps))
+ }
+ for i, g := range got.Gaps {
+ if math.Abs(g-got.Step) > 0.5 {
+ t.Errorf("%s: fields %d and %d are %.1fpx apart, want --rst-sp-3, %.1fpx", name, i, i+1, g, got.Step)
+ }
+ }
+ }
+ id := s.ids[0]
+ for _, path := range []string{cardPath(id) + "/edit", "/cards/new?type=t_customer"} {
+ var got spacing
+ s.rig.Run(wide(), chromedp.Navigate(s.rig.Origin+path), chromedp.WaitVisible(`form[fichas-form]`),
+ harness.Into(&got, chromedp.Evaluate[spacing](fieldGaps)))
+ check(path, got)
+ }
+
+ // A conflict: a teammate changes City under the open edit form, and
+ // Save draws theirs and mine as a fieldset among the fields.
+ var got spacing
+ s.rig.Run(wide(), chromedp.Navigate(s.rig.Origin+cardPath(id)+"/edit"), chromedp.WaitVisible(`#`+s.city))
+ s.teammate(t, id, s.city, "Galway", "")
+ s.rig.Run(chromedp.SetValue(`#`+s.city, "Cork"),
+ chromedp.Evaluate[chromedp.Void](`HTMLFormElement.prototype.submit.call(document.querySelector('form[fichas-form]'))`),
+ chromedp.WaitVisible(`[fichas-conflict]`),
+ harness.Into(&got, chromedp.Evaluate[spacing](fieldGaps)))
+ check("the edit form after a conflict", got)
+}
diff --git a/internal/fichastest/browser_test.go b/internal/fichastest/browser_test.go
index 4a9cdb9..77b4f74 100644
--- a/internal/fichastest/browser_test.go
+++ b/internal/fichastest/browser_test.go
@@ -39,6 +39,12 @@ import (
// browserApp is the app signed in as TestOwner, with the rig's own origin,
// optionally seeded through the real store.
func browserApp(t *testing.T, seed func(context.Context, *db.DB, fichas.Config)) *harness.Rig {
+ return browserAppWith(t, nil, seed)
+}
+
+// browserAppWith is browserApp with its config changed first, by
+// configure, when that is not nil.
+func browserAppWith(t *testing.T, configure func(*fichas.Config), seed func(context.Context, *db.DB, fichas.Config)) *harness.Rig {
return harness.New(t, func(origin string) http.Handler {
logger := slog.New(slog.NewTextHandler(io.Discard, nil))
d, err := db.Open(filepath.Join(t.TempDir(), "app.db"), logger)
@@ -58,6 +64,9 @@ func browserApp(t *testing.T, seed func(context.Context, *db.DB, fichas.Config))
if err != nil {
t.Fatalf("LoadConfig: %v", err)
}
+ if configure != nil {
+ configure(&cfg)
+ }
mux, err := fichas.AppForTest(d, cfg, logger, TestOwner)
if err != nil {
t.Fatalf("AppForTest: %v", err)