Editor: an image's limits are a quiet line under its file field again
Ruling R17: "PNG, JPEG, WebP or SVG, up to 20 MB." (block.image.hint) is drawn again, muted and in the small type, under the image's file field, which it still describes (aria-describedby), and hidden with the field for any other box. The no-store line is the same element, unchanged. It is not an rst-field-hint, so TestQuieterBlockCardIsStyle still holds the form to no standing help, and now asserts the line. TestQuieterBlockCardImageLimits (newTidyEditorWith binds a store).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 files changed,
+63
−4
internal/slides/static/editor.css+5 −0internal/slides/templates/editor.html+4 −3internal/slidestest/browser_editor_tidy_test.go+8 −1internal/slidestest/browser_quieter_box_test.go+36 −0internal/slidestest/quieter_test.go+10 −0
diff --git a/internal/slides/static/editor.css b/internal/slides/static/editor.css| index 9984536..3764572 100644 |
| --- a/internal/slides/static/editor.css |
| +++ b/internal/slides/static/editor.css |
| @@ -1393,6 +1393,11 @@ summary[slides-card-row]::-webkit-details-marker { |
| the ones no slide uses. The status line is text and only text — |
| "error" is a colour ON a sentence that already says what happened, |
| never the sentence itself (§8, WCAG 1.4.1). */ |
| +[slides-asset-hint] { |
| + font-size: var(--rst-fs-xs); |
| + line-height: 1.35; |
| + margin: 0; |
| +} |
| [slides-asset-status]:empty { |
| display: none; |
| } |
diff --git a/internal/slides/templates/editor.html b/internal/slides/templates/editor.html| index 0c3ec02..935c298 100644 |
| --- a/internal/slides/templates/editor.html |
| +++ b/internal/slides/templates/editor.html |
| @@ -740,9 +740,10 @@ |
| <label rst-field-label for="rst-block-image">{{.L "block.image.file"}}</label> |
| <input rst-input id="rst-block-image" name="rst-block-image" type="file" slides-asset-input |
| accept="{{.AcceptTypes}}" aria-describedby="slides-asset-hint"{{if not .HasStore}} disabled{{end}}> |
| - {{/* The limits are said, not drawn: no standing help (spec §3). |
| - Why the input is disabled is drawn, since nothing else says. */}} |
| - {{if .HasStore}}<p class="rst-sr-only" id="slides-asset-hint">{{.L "block.image.hint"}}</p>{{else}}<p rst-text-muted id="slides-asset-hint">{{.L "block.image.nostore"}}</p>{{end}} |
| + {{/* One quiet line under the field (ruling R17): the limits, before |
| + a file is picked; or, with no object store, why the field is |
| + disabled. */}} |
| + <p rst-text-muted slides-asset-hint id="slides-asset-hint">{{if .HasStore}}{{.L "block.image.hint"}}{{else}}{{.L "block.image.nostore"}}{{end}}</p> |
| <p rst-text-muted slides-asset-status role="status" aria-live="polite"></p> |
| </div> |
| <fieldset rst-field slides-seg-field data-types="image"> |
diff --git a/internal/slidestest/browser_editor_tidy_test.go b/internal/slidestest/browser_editor_tidy_test.go| index a7338ed..7e770de 100644 |
| --- a/internal/slidestest/browser_editor_tidy_test.go |
| +++ b/internal/slidestest/browser_editor_tidy_test.go |
| @@ -17,6 +17,7 @@ import ( |
| "testing" |
| "time" |
| + "amadan.net/rastrillo/rastrillo/blobs" |
| "amadan.net/rastrillo/rastrillo/harness" |
| "github.com/chromedp/cdproto/input" |
| "github.com/chromedp/cdproto/network" |
| @@ -61,7 +62,13 @@ func openTidyEditorOn(t *testing.T, width, height int64, deck func(a *testApp, c |
| // (for a deck whose editor has nothing to bind, an empty one). |
| func newTidyEditor(t *testing.T, width, height int64, deck func(a *testApp, cookies []*http.Cookie) string) *tidyEditor { |
| t.Helper() |
| - rig, app := newRigApp(t, nil) |
| + return newTidyEditorWith(t, nil, width, height, deck) |
| +} |
| + |
| +// newTidyEditorWith is newTidyEditor with an object store bound (nil: none). |
| +func newTidyEditorWith(t *testing.T, store blobs.Store, width, height int64, deck func(a *testApp, cookies []*http.Cookie) string) *tidyEditor { |
| + t.Helper() |
| + rig, app := newRigApp(t, store) |
| cookies := signedIn(t, app, allowedAddress) |
| var set []chromedp.Action |
| for _, c := range cookies { |
diff --git a/internal/slidestest/browser_quieter_box_test.go b/internal/slidestest/browser_quieter_box_test.go| index 9ee33f1..b027b41 100644 |
| --- a/internal/slidestest/browser_quieter_box_test.go |
| +++ b/internal/slidestest/browser_quieter_box_test.go |
| @@ -12,6 +12,7 @@ import ( |
| "strings" |
| "testing" |
| + "amadan.net/rastrillo/rastrillo/blobs" |
| "github.com/chromedp/cdproto/input" |
| "github.com/chromedp/chromedp" |
| "github.com/chromedp/chromedp/kb" |
| @@ -602,3 +603,38 @@ func TestQuieterPlaceClosesOnReload(t *testing.T) { |
| t.Errorf("session storage holds %v; want nothing kept for Position and size", stored) |
| } |
| } |
| + |
| +// TestQuieterBlockCardImageLimits (ruling R17): an image's options show |
| +// its limits in one quiet line under the file field, describing it; a |
| +// heading's options do not show it. |
| +func TestQuieterBlockCardImageLimits(t *testing.T) { |
| + var slide string |
| + store, err := blobs.Dir(t.TempDir()) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + te := newTidyEditorWith(t, store, 1280, 720, func(a *testApp, cookies []*http.Cookie) string { |
| + var path string |
| + path, slide = deckWithEveryKind(t, a, cookies) |
| + return path |
| + }) |
| + te.openOn(slide) |
| + te.rig.Run(waitFor(editorBound)) |
| + const hint = `document.querySelector('#slides-asset-hint')` |
| + te.selectBox("image") |
| + var seen struct { |
| + Shown, Describes bool |
| + Text string |
| + } |
| + te.rig.Run(chromedp.Evaluate(`(h => ({ Shown: h.checkVisibility() && h.getBoundingClientRect().height > 0, Text: h.textContent.trim(), |
| + Describes: document.querySelector('#rst-block-image').getAttribute('aria-describedby') === h.id }))(`+hint+`)`, &seen)) |
| + if !seen.Shown || !seen.Describes || seen.Text != "PNG, JPEG, WebP or SVG, up to 20 MB." { |
| + t.Errorf("an image selected: the limits line is %+v; want it drawn, saying the limits, describing the file field", seen) |
| + } |
| + te.selectBox("heading") |
| + var shown bool |
| + te.rig.Run(chromedp.Evaluate(hint+`.checkVisibility()`, &shown)) |
| + if shown { |
| + t.Error("a heading selected: the image's limits line is drawn") |
| + } |
| +} |
diff --git a/internal/slidestest/quieter_test.go b/internal/slidestest/quieter_test.go| index 59daeef..ed21ce8 100644 |
| --- a/internal/slidestest/quieter_test.go |
| +++ b/internal/slidestest/quieter_test.go |
| @@ -473,6 +473,16 @@ func TestQuieterBlockCardIsStyle(t *testing.T) { |
| t.Errorf("the block form still holds %s", gone) |
| } |
| } |
| + // R17: one quiet line under the image's file field, describing it: |
| + // its limits (with an object store; this app has none, so the page |
| + // says why the field is disabled, in the same line). |
| + line := `<p rst-text-muted slides-asset-hint id="slides-asset-hint">` |
| + if image := regexp.MustCompile(`(?s)<div rst-field data-types="image">\s*<label rst-field-label for="rst-block-image">.*?</p>`).FindString(form); !strings.Contains(image, line) || !strings.Contains(image, `aria-describedby="slides-asset-hint"`) { |
| + t.Errorf("the image file field has no %s describing it:\n%s", line, image) |
| + } |
| + if tmpl := readSource(t, "templates/editor.html"); !strings.Contains(tmpl, line+`{{if .HasStore}}{{.L "block.image.hint"}}{{else}}`) { |
| + t.Errorf("editor.html does not draw the image's limits (block.image.hint) in %s", line) |
| + } |
| for _, seg := range []struct { |
| name string |