oficina / slides Public

Editor: strings and dead selectors under test; estilo rounds the switch

TestEditorTidyStrings: the strings table's keys are in en.toml with its
English and in editorStrings (Text, Alignment, On a phone and Deck reuse
format.label, block.align, block.phone and inspector.deck); every listed
key is read by editor.html, its type.<block> menus or editor.go's
page.S; every key the template reads is listed; the old inspector's and
notes switch's keys are gone. The catalog's note on the view switch
says icons now.

TestEditorTidyNoDeadSelectors: editor.css and the bundle's sources name
no data-inspector-off, slides-notes-toggle or details[slides-inspector],
and editor.css no longer rounds the switch's first segment itself:
estilo's :nth-child(1 of [estilo-seg-item]) does, after the legend.

Also: the deck list's ground must read var(--slides-desk), and the
strip-foot test's diagnostic no longer slices at -1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev cd560e079d24e77192dd5159e08b2b930455f79f parent 964a8b9
3 files changed, +177 −12
  • internal/slides/locales/en.toml +4 −3
  • internal/slides/static/editor.css +3 −8
  • internal/slidestest/editor_tidy_test.go +170 −1
diff --git a/internal/slides/locales/en.toml b/internal/slides/locales/en.toml
index 81dc564..d6504c7 100644
--- a/internal/slides/locales/en.toml
+++ b/internal/slides/locales/en.toml
@@ -324,9 +324,10 @@ slides.editor.presence.more = "{n} more people on this slide"
slides.editor.presence.joined = "{name} opened this deck"
slides.editor.presence.left = "{name} closed this deck"
-# The desktop/phone switcher on the stage (spec §3.2). Three visible
-# words, never icons alone: which view is on decides where an edit
-# lands.
+# The desktop/phone switcher on the stage (spec §3.2). Three icons,
+# each named in words by these keys (its accessible name and tooltip),
+# and three rows in the View menu: which view is on decides where an
+# edit lands.
slides.editor.view = "View"
slides.editor.view.desktop = "Desktop"
slides.editor.view.phone = "Phone"
diff --git a/internal/slides/static/editor.css b/internal/slides/static/editor.css
index caf8a1c..06d6d8d 100644
--- a/internal/slides/static/editor.css
+++ b/internal/slides/static/editor.css
@@ -1247,10 +1247,9 @@
/* Three radios drawn as estilo's segmented control ([estilo-seg]): it
styles the segments, hides each radio over its label (still focusable
and arrow-key operable) and draws the checked and focused ones. What
- is left is the fieldset's own box, the legend (read, not seen: the
- <legend> is the fieldset's first child, so :first-child never matches
- the first segment and its corner is rounded here) and the icon's
- size, set small enough to keep the pill compact. */
+ is left is the fieldset's own box (its <legend> is read, not seen;
+ estilo rounds the first and last segment after it all the same) and
+ the icon's size, set small enough to keep the pill compact. */
[slides-switcher] {
flex: 0 0 auto;
margin: 0;
@@ -1258,10 +1257,6 @@
padding: 0;
border: 0;
}
-[slides-switcher] > label:nth-child(2) {
- border-start-start-radius: 8px;
- border-end-start-radius: 8px;
-}
[slides-switcher] > label { min-inline-size: 36px; }
[slides-switcher] svg { inline-size: 16px; block-size: 16px; }
diff --git a/internal/slidestest/editor_tidy_test.go b/internal/slidestest/editor_tidy_test.go
index ec3f2c2..112cae6 100644
--- a/internal/slidestest/editor_tidy_test.go
+++ b/internal/slidestest/editor_tidy_test.go
@@ -65,6 +65,9 @@ func TestEditorTidyDeskIsEstilos(t *testing.T) {
if strings.Contains(rule, "gradient") {
t.Errorf("the deck list's ground still has a gradient:\n%s", rule)
}
+ if !strings.Contains(rule, "var(--slides-desk)") {
+ t.Errorf("the deck list's ground does not read var(--slides-desk):\n%s", rule)
+ }
}
func readStatic(t *testing.T, name string) string {
@@ -93,7 +96,11 @@ func TestEditorTidyNewSlideInStripFoot(t *testing.T) {
}
foot := regexp.MustCompile(`(?s)</ol>\s*<div slides-strip-foot>\s*<div slides-strip-add>`).FindStringIndex(nav)
if foot == nil {
- t.Errorf("[slides-strip-add] is not the first thing in a <div slides-strip-foot> after the list:\n%s", nav[strings.LastIndex(nav, "</ol>"):])
+ tail := nav
+ if i := strings.LastIndex(nav, "</ol>"); i >= 0 {
+ tail = nav[i:]
+ }
+ t.Errorf("[slides-strip-add] is not the first thing in a <div slides-strip-foot> after the list:\n%s", tail)
}
}
@@ -715,3 +722,165 @@ func TestEditorTidyBarControls(t *testing.T) {
t.Errorf("undo and redo share the name %q", buttons[0][2])
}
}
+
+// readSource is a file of the slides package, by its path under
+// internal/slides.
+func readSource(t *testing.T, name string) string {
+ t.Helper()
+ b, err := os.ReadFile(filepath.Join("..", "slides", filepath.FromSlash(name)))
+ if err != nil {
+ t.Fatal(err)
+ }
+ return string(b)
+}
+
+// goStrings is the quoted strings of the Go var declared as
+// `var name = []string{…}` in src.
+func goStrings(t *testing.T, src, name string) []string {
+ t.Helper()
+ block := regexp.MustCompile(`(?s)var ` + name + ` = \[\]string\{(.*?)\}`).FindStringSubmatch(src)
+ if block == nil {
+ t.Fatalf("editor.go declares no var %s = []string{…}", name)
+ }
+ var out []string
+ for _, m := range regexp.MustCompile(`"([^"]*)"`).FindAllStringSubmatch(block[1], -1) {
+ out = append(out, m[1])
+ }
+ return out
+}
+
+// TestEditorTidyStrings: the strings of the tidied editor are catalog
+// keys, each in en.toml with the strings table's English and in
+// editorStrings; every key in editorStrings is read (by editor.html
+// through L, by its add-block menus as type.<block type>, or by
+// editor.go itself through page.S); every key editor.html reads is in
+// editorStrings; and the keys the old inspector and notes switch read
+// are gone from both. The table's group labels that already had a key
+// with the same English reuse it: Text is format.label, Alignment
+// block.align, On a phone block.phone and Deck inspector.deck.
+func TestEditorTidyStrings(t *testing.T) {
+ toml := readSource(t, "locales/en.toml")
+ catalog := map[string]string{}
+ for _, m := range regexp.MustCompile(`(?m)^slides\.editor\.(\S+) = "(.*)"$`).FindAllStringSubmatch(toml, -1) {
+ catalog[m[1]] = m[2]
+ }
+ src := readSource(t, "editor.go")
+ listed := map[string]bool{}
+ keys := goStrings(t, src, "editorStrings")
+ for _, k := range keys {
+ listed[k] = true
+ }
+
+ for _, c := range []struct{ key, english string }{
+ {"head.format", "Format"},
+ {"notes.title", "Notes"},
+ {"notes.close", "Close notes"},
+ {"notes.open", "Show notes"},
+ {"notes.open.has", "Show notes (this slide has notes)"},
+ {"notes.resize", "Resize notes"},
+ {"view.both.title", "Both, side by side"},
+ {"group.style", "Style"},
+ {"group.image", "Image"},
+ {"group.description", "Description"},
+ {"group.place", "Place"},
+ {"group.boxes", "Boxes"},
+ {"group.slide", "This slide"},
+ // reused, not new
+ {"format.label", "Text"},
+ {"block.align", "Alignment"},
+ {"block.phone", "On a phone"},
+ {"inspector.deck", "Deck"},
+ } {
+ if got, ok := catalog[c.key]; !ok {
+ t.Errorf("en.toml has no slides.editor.%s", c.key)
+ } else if got != c.english {
+ t.Errorf("slides.editor.%s is %q, want %q", c.key, got, c.english)
+ }
+ if !listed[c.key] {
+ t.Errorf("editorStrings does not list %s", c.key)
+ }
+ }
+
+ // Each group in the card is labelled by the key the table gives it.
+ tmpl := readSource(t, "templates/editor.html")
+ for group, key := range map[string]string{
+ "slide": "group.slide", "boxes": "group.boxes", "deck": "inspector.deck",
+ "style": "group.style", "text": "format.label", "alignment": "block.align",
+ "image": "group.image", "description": "group.description", "place": "group.place",
+ "phone": "block.phone",
+ } {
+ label := `<span estilo-inspector-label id="slides-g-` + group + `">{{.L "` + key + `"}}</span>`
+ if !strings.Contains(tmpl, label) {
+ t.Errorf("editor.html has no %s", label)
+ }
+ }
+
+ // Every listed key is read, and every key read is listed.
+ read := map[string]bool{}
+ for _, m := range regexp.MustCompile(`\.L "([^"]+)"`).FindAllStringSubmatch(tmpl, -1) {
+ read[m[1]] = true
+ }
+ for _, m := range regexp.MustCompile(`\.L \(printf "([^"%]*)%s" \.\)`).FindAllStringSubmatch(tmpl, -1) {
+ for _, b := range goStrings(t, src, "blockTypes") {
+ read[m[1]+b] = true
+ }
+ }
+ for _, m := range regexp.MustCompile(`page\.S\["([^"]+)"\]`).FindAllStringSubmatch(src, -1) {
+ read[m[1]] = true
+ }
+ for _, k := range keys {
+ if !read[k] {
+ t.Errorf("editorStrings lists %s, which nothing reads", k)
+ }
+ if _, ok := catalog[k]; !ok {
+ t.Errorf("editorStrings lists %s, which en.toml does not define", k)
+ }
+ }
+ for _, m := range regexp.MustCompile(`\.L "([^"]+)"`).FindAllStringSubmatch(tmpl, -1) {
+ if !listed[m[1]] {
+ t.Errorf("editor.html reads %s, which editorStrings does not list", m[1])
+ }
+ }
+
+ // The old inspector's and the notes switch's keys are gone.
+ for _, k := range []string{"head.inspector", "inspector", "inspector.empty", "inspector.slide", "inspector.block", "inspector.blocks", "slide.notes.show"} {
+ if _, ok := catalog[k]; ok {
+ t.Errorf("en.toml still defines slides.editor.%s", k)
+ }
+ if listed[k] {
+ t.Errorf("editorStrings still lists %s", k)
+ }
+ }
+
+ // The view switch is icons now; the catalog's note on it says so.
+ if strings.Contains(toml, "never icons alone") {
+ t.Error("en.toml still says the view switch is words, never icons alone")
+ }
+}
+
+// TestEditorTidyNoDeadSelectors: what the inspector's <details>, its
+// off switch and the notes switch were drawn and wired by is gone from
+// the stylesheet and the bundle's sources; and the view switch's first
+// corner is estilo's, which rounds the first segment after a <legend>.
+func TestEditorTidyNoDeadSelectors(t *testing.T) {
+ files := []string{filepath.Join("..", "slides", "static", "editor.css"), filepath.Join("..", "..", "fixtures", "editor-entry.js")}
+ mjs, err := filepath.Glob(filepath.Join("..", "..", "fixtures", "*.mjs"))
+ if err != nil || len(mjs) == 0 {
+ t.Fatalf("no fixtures/*.mjs (%v)", err)
+ }
+ files = append(files, mjs...)
+ for _, f := range files {
+ b, err := os.ReadFile(f)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, dead := range []string{"data-inspector-off", "slides-notes-toggle", "details[slides-inspector]"} {
+ if strings.Contains(string(b), dead) {
+ t.Errorf("%s still mentions %s", filepath.Base(f), dead)
+ }
+ }
+ }
+ if regexp.MustCompile(`\[slides-switcher\][^{]*nth-child`).MatchString(readStatic(t, "editor.css")) {
+ t.Error("static/editor.css still rounds the view switch's first segment itself (estilo does)")
+ }
+}