oficina / slides Public

Editor: one inventory of where every field lives

TestQuieterNothingIsLost asserts each needle in the homes table is in its
home and nowhere else in the editor page outside templates. It replaces
the per-field table of TestEditorTidyNothingIsLost; the rest of that test
stays as TestEditorTidyCardShape.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev bdaee615079641f0ebda1c7c24b120185916fdfe parent 998cf1f
2 files changed, +199 −87
  • internal/slidestest/editor_tidy_test.go +9 −87
  • internal/slidestest/quieter_inventory_test.go +190 −0
diff --git a/internal/slidestest/editor_tidy_test.go b/internal/slidestest/editor_tidy_test.go
index 2bd15e5..aa27af5 100644
--- a/internal/slidestest/editor_tidy_test.go
+++ b/internal/slidestest/editor_tidy_test.go
@@ -538,14 +538,15 @@ func tidyGroups(form string) []tidyGroup {
return out
}
-// TestEditorTidyNothingIsLost (spec E8, E10, §4.2, §4.3): every field,
-// command and list the inspector held on main (read off main's
-// editor.html at the plan's base, with the stage bar's five marks) is
-// still in the card, in the form and the group the spec puts it in;
-// the five slide commands that left the card are still in the Slide
-// menu and in each slide's own menu in the strip; and the stage bar
-// keeps the view switch and no marks.
-func TestEditorTidyNothingIsLost(t *testing.T) {
+// TestEditorTidyCardShape (spec E8, E10, §4.2, §4.3): the card's forms
+// hold their groups in the spec's order, each group opening in estilo's
+// shape; Delete block follows the last group; the delete confirmation
+// precedes the slide's groups; the five slide commands that left the
+// card are still in the Slide menu and in each slide's own menu in the
+// strip; and the stage bar keeps the view switch and no marks. Which
+// field lives in which form and group is TestQuieterNothingIsLost's
+// table (quieter_inventory_test.go).
+func TestEditorTidyCardShape(t *testing.T) {
a := newApp(t)
cookies := signedIn(t, a, allowedAddress)
page := mustGet(t, a, deckWithSlides(t, a, cookies, 2), http.StatusOK, cookies).Body.String()
@@ -563,85 +564,6 @@ func TestEditorTidyNothingIsLost(t *testing.T) {
}
}
- // group "" is the form itself, outside every group.
- type needle struct{ needle, section, group string }
- var table []needle
- for _, n := range []string{"title", "theme", "accent", "font-heading", "font-body"} {
- table = append(table, needle{`name="rst-deck-` + n + `"`, "deck", "deck"})
- }
- table = append(table,
- needle{`data-command="accent-reset"`, "deck", "deck"},
- needle{`<fieldset slides-unused-assets`, "deck", "deck"},
- )
- for _, n := range []string{"layout", "template", "background", "background-color", "transition", "phone"} {
- table = append(table, needle{`name="rst-slide-` + n + `"`, "slide", "slide"})
- }
- table = append(table,
- needle{`slides-confirm`, "slide", ""},
- needle{`data-command="slide-delete"`, "slide", ""},
- needle{`data-command="slide-delete-cancel"`, "slide", ""},
- needle{`slides-blocks-buttons`, "slide", "boxes"},
- )
- for _, kind := range []string{"heading", "text", "list", "quote", "image", "columns", "code", "shape", "table", "divider", "spacer"} {
- table = append(table, needle{`data-add-block="` + kind + `"`, "slide", "boxes"})
- }
- for _, f := range []struct{ name, group string }{
- {"level", "style"}, {"size", "style"}, {"style", "style"}, {"cite", "style"}, {"count", "style"},
- {"language", "style"}, {"kind", "style"}, {"fill", "style"}, {"stroke", "style"}, {"strokeWidth", "style"},
- {"label", "style"}, {"rows", "style"}, {"cols", "style"}, {"header", "style"}, {"spacer-size", "style"},
- {"align", "alignment"},
- {"radius", "style"}, // R16: Style for images and shapes alike, not the spec table's Image
- {"image", "image"}, {"fit", "image"},
- {"alt", "description"}, {"decorative", "description"},
- {"region", "place"}, {"x", "place"}, {"y", "place"}, {"w", "place"}, {"h", "place"},
- {"phone-hidden", "phone"}, {"phone-order", "phone"}, {"phone-size", "phone"},
- } {
- table = append(table, needle{`name="rst-block-` + f.name + `"`, "block", f.group})
- }
- for _, mark := range []string{"b", "i", "c", "h", "href"} {
- table = append(table, needle{`data-mark="` + mark + `"`, "block", "text"})
- }
- table = append(table,
- needle{`slides-phone-badge`, "block", "phone"},
- needle{`data-command="phone-reset"`, "block", "phone"},
- needle{`data-command="block-forward"`, "block", "place"},
- needle{`data-command="block-back"`, "block", "place"},
- needle{`data-command="block-move-up"`, "block", "place"},
- needle{`data-command="block-move-down"`, "block", "place"},
- needle{`data-command="block-delete"`, "block", ""},
- )
-
- for _, n := range table {
- c := strings.Count(card, n.needle)
- if c == 0 {
- t.Errorf("%s is not in the card", n.needle)
- continue
- }
- form := forms[n.section]
- if f := strings.Count(form, n.needle); f != c {
- t.Errorf("%s: %d of the %d in the card are in the %s form", n.needle, f, c, n.section)
- continue
- }
- groups := tidyGroups(form)
- for off := 0; ; {
- i := strings.Index(form[off:], n.needle)
- if i < 0 {
- break
- }
- i += off
- off = i + len(n.needle)
- in := ""
- for _, g := range groups {
- if g.start < i && i < g.end {
- in = g.name
- }
- }
- if in != n.group {
- t.Errorf("%s is in the %s form's group %q, want %q", n.needle, n.section, in, n.group)
- }
- }
- }
-
// The groups themselves: estilo's labelled group, its label's id the
// group's name, in the spec's order.
for _, w := range []struct {
diff --git a/internal/slidestest/quieter_inventory_test.go b/internal/slidestest/quieter_inventory_test.go
new file mode 100644
index 0000000..d5cd32f
--- /dev/null
+++ b/internal/slidestest/quieter_inventory_test.go
@@ -0,0 +1,190 @@
+package slidestest
+
+import (
+ "net/http"
+ "regexp"
+ "strings"
+ "testing"
+)
+
+// The quieter editor's inventory (docs/superpowers/specs/2026-11-17-quieter-editor-design.md):
+// one table naming where every field and command of the editor lives.
+// A task that moves a control changes that control's row first; the test
+// then says whether the markup agrees. A needle must be found in its
+// home and nowhere else in the editor page outside <template> elements.
+
+// The homes. A block field's home is homeCardBlock+":"+group, the group
+// being the data-group of the card's block form ("" is the form's tail
+// after its last group, where Delete block sits).
+const (
+ homeCardSlide = "card-slide" // the card's slide form, every group of it
+ homeCardBlock = "card-block" // + ":" + group, the card's block form
+ homeCardDeck = "card-deck" // the card's deck form; Task Q2 retires it
+ homePopBackground = "pop-background" // #slides-pop-background[popover]
+ homePopTransition = "pop-transition" // #slides-pop-transition[popover]
+ homeDeckDialog = "deck-dialog" // <dialog slides-deck-dialog>
+ homeBoxMenu = "box-menu" // [slides-box-menu]
+ homeInsertMenu = "insert-menu" // the menubar's Insert menu
+ homeOutline = "outline" // #slides-outline[popover]
+ homePhoneOnly = "phone-only" // what only the phone view shows
+ homeStrip = "strip" // the strip's own rows
+)
+
+// needle is one control, found by a string specific enough to mean only
+// it, and the home it has today.
+type needle struct{ needle, home string }
+
+// homes is the inventory, from the editor on main: every field, command
+// and list the old inspector held, plus the stage bar's five marks.
+var homes = buildHomes()
+
+func buildHomes() []needle {
+ var t []needle
+ add := func(home string, needles ...string) {
+ for _, n := range needles {
+ t = append(t, needle{n, home})
+ }
+ }
+
+ for _, n := range []string{"title", "theme", "accent", "font-heading", "font-body"} {
+ add(homeCardDeck, `name="rst-deck-`+n+`"`)
+ }
+ add(homeCardDeck, `data-command="accent-reset"`, `<fieldset slides-unused-assets`)
+
+ for _, n := range []string{"layout", "template", "background", "background-color", "transition", "phone"} {
+ add(homeCardSlide, `name="rst-slide-`+n+`"`)
+ }
+ add(homeCardSlide,
+ `slides-confirm`, `data-command="slide-delete"`, `data-command="slide-delete-cancel"`,
+ `slides-blocks-buttons`)
+ for _, kind := range []string{"heading", "text", "list", "quote", "image", "columns", "code", "shape", "table", "divider", "spacer"} {
+ add(homeCardSlide, `data-add-block="`+kind+`"`)
+ }
+
+ for _, f := range []struct{ name, group string }{
+ {"level", "style"}, {"size", "style"}, {"style", "style"}, {"cite", "style"}, {"count", "style"},
+ {"language", "style"}, {"kind", "style"}, {"fill", "style"}, {"stroke", "style"}, {"strokeWidth", "style"},
+ {"label", "style"}, {"rows", "style"}, {"cols", "style"}, {"header", "style"}, {"spacer-size", "style"},
+ {"align", "alignment"},
+ {"radius", "style"}, // R16: Style for images and shapes alike, not the spec table's Image
+ {"image", "image"}, {"fit", "image"},
+ {"alt", "description"}, {"decorative", "description"},
+ {"region", "place"}, {"x", "place"}, {"y", "place"}, {"w", "place"}, {"h", "place"},
+ {"phone-hidden", "phone"}, {"phone-order", "phone"}, {"phone-size", "phone"},
+ } {
+ add(homeCardBlock+":"+f.group, `name="rst-block-`+f.name+`"`)
+ }
+ for _, mark := range []string{"b", "i", "c", "h", "href"} {
+ add(homeCardBlock+":text", `data-mark="`+mark+`"`)
+ }
+ add(homeCardBlock+":phone", `slides-phone-badge`, `data-command="phone-reset"`)
+ add(homeCardBlock+":place",
+ `data-command="block-forward"`, `data-command="block-back"`,
+ `data-command="block-move-up"`, `data-command="block-move-down"`)
+ add(homeCardBlock+":", `data-command="block-delete"`)
+ return t
+}
+
+// homeOf is the slice of page that home denotes, or "" when the page
+// has no such markup (yet). To give a new home a case, add one line to
+// the switch: find its opening tag, return extentAt of it.
+func homeOf(page, home string) string {
+ // from returns the element whose opening tag matches re.
+ from := func(re string) string {
+ loc := regexp.MustCompile(re).FindStringIndex(page)
+ if loc == nil {
+ return ""
+ }
+ return extent(page, loc[0])
+ }
+ form := func(section string) string {
+ card := from(`<aside slides-inspector`)
+ for _, loc := range regexp.MustCompile(`<form [^>]*slides-inspector-form[^>]*>`).FindAllStringIndex(card, -1) {
+ if strings.Contains(card[loc[0]:loc[1]], `data-section="`+section+`"`) {
+ return extent(card, loc[0])
+ }
+ }
+ return ""
+ }
+
+ switch {
+ case home == homeCardSlide:
+ return form("slide")
+ case home == homeCardDeck:
+ return form("deck")
+ case strings.HasPrefix(home, homeCardBlock+":"):
+ block, group := form("block"), strings.TrimPrefix(home, homeCardBlock+":")
+ gs := tidyGroups(block)
+ if group == "" {
+ if len(gs) == 0 {
+ return ""
+ }
+ return block[gs[len(gs)-1].end:]
+ }
+ for _, g := range gs {
+ if g.name == group {
+ return block[g.start:g.end]
+ }
+ }
+ return ""
+ case home == homePopBackground:
+ return from(`<[a-z]+ [^>]*id="slides-pop-background"`)
+ case home == homePopTransition:
+ return from(`<[a-z]+ [^>]*id="slides-pop-transition"`)
+ case home == homeDeckDialog:
+ return from(`<dialog [^>]*slides-deck-dialog`)
+ case home == homeBoxMenu:
+ return from(`<div [^>]*slides-box-menu`)
+ case home == homeInsertMenu:
+ return from(`<details [^>]*slides-menu="insert"`)
+ case home == homeOutline:
+ return from(`<[a-z]+ [^>]*id="slides-outline"`)
+ case home == homeStrip:
+ return from(`<ol [^>]*slides-strip[\s>]`)
+ }
+ return ""
+}
+
+// TestQuieterNothingIsLost: every needle in homes is in its home, and
+// nowhere else in the editor page outside <template> elements.
+func TestQuieterNothingIsLost(t *testing.T) {
+ a := newApp(t)
+ cookies := signedIn(t, a, allowedAddress)
+ page := mustGet(t, a, deckWithSlides(t, a, cookies, 2), http.StatusOK, cookies).Body.String()
+ live := regexp.MustCompile(`(?s)<template.*?</template>`).ReplaceAllString(page, "")
+
+ for _, n := range homes {
+ where := homeOf(live, n.home)
+ if where == "" {
+ t.Errorf("%s: its home %q has no markup in the editor page", n.needle, n.home)
+ continue
+ }
+ in, all := strings.Count(where, n.needle), strings.Count(live, n.needle)
+ if in == all && in > 0 {
+ continue
+ }
+ t.Errorf("%s: %d of its %d occurrences are in its home %q; found in: %s",
+ n.needle, in, all, n.home, foundIn(live, n.needle))
+ }
+}
+
+// foundIn names the homes (the ones the table uses, with the block
+// form's groups) whose markup holds needle, for a failure message.
+func foundIn(live, needle string) string {
+ var got []string
+ for _, h := range []string{
+ homeCardSlide, homeCardDeck, homePopBackground, homePopTransition, homeDeckDialog,
+ homeBoxMenu, homeInsertMenu, homeOutline, homeStrip, homeCardBlock + ":",
+ homeCardBlock + ":style", homeCardBlock + ":text", homeCardBlock + ":alignment",
+ homeCardBlock + ":image", homeCardBlock + ":description", homeCardBlock + ":place",
+ homeCardBlock + ":phone",
+ } {
+ if strings.Contains(homeOf(live, h), needle) {
+ got = append(got, h)
+ }
+ }
+ if len(got) == 0 {
+ return "no home in the table"
+ }
+ return strings.Join(got, ", ")
+}