package slidestest import ( "fmt" "html" "net/http" "os" "path/filepath" "regexp" "strings" "sync/atomic" "testing" ) // The quieter editor (docs/superpowers/specs/2026-11-17-quieter-editor-design.md), // as the server renders it. // TestQuieterStripMarkup (spec §6.1): the strip's foot is gone; New // slide and its layouts chevron are li[slides-strip-new], the
    's // last child, after every slide; and each slide's link carries its // label as its title, the tooltip that stands in for the words no // longer drawn under the picture; and each link starts with the slide's // number as text, drawn (aria-hidden) and said (visually hidden). func TestQuieterStripMarkup(t *testing.T) { a := newApp(t) cookies := signedIn(t, a, allowedAddress) page := mustGet(t, a, deckWithSlides(t, a, cookies, 40), http.StatusOK, cookies).Body.String() live := regexp.MustCompile(`(?s)`).ReplaceAllString(page, "") if strings.Contains(page, "slides-strip-foot") { t.Error("the editor still has a slides-strip-foot") } if css := readStatic(t, "editor.css"); strings.Contains(css, "slides-strip-foot") { t.Error("static/editor.css still styles slides-strip-foot") } ol := homeOf(live, homeStrip) if ol == "" { t.Fatal("no
      in the editor") } row := regexp.MustCompile(`
    1. ]`).FindStringIndex(ol) if row == nil { t.Fatalf("the strip has no
    2. :\n%s", ol) } tail := ol[row[0]:] if li := extent(tail, 0); li == "" || !regexp.MustCompile(`^\s*
    $`).MatchString(tail[len(li):]) { t.Errorf("
  1. is not the strip's last child:\n%s", tail) } else { for _, want := range []string{`data-command="new-slide"`, `slides-layouts-toggle`, `popovertarget="slides-layouts"`, `id="slides-layouts"`} { if !strings.Contains(li, want) { t.Errorf("the New slide row has no %s:\n%s", want, li) } } } if n := strings.Count(ol[:row[0]], "
  2. `).FindAllString(ol, -1) link := regexp.MustCompile(`]*\btitle="([^"]*)"`) label := regexp.MustCompile(`([^<]*)`) for i, li := range items { l, w := link.FindStringSubmatch(li), label.FindStringSubmatch(li) switch { case l == nil: t.Errorf("slide %d's link has no title:\n%s", i+1, li) case w == nil: t.Errorf("slide %d has no [slides-strip-label]:\n%s", i+1, li) case l[1] != w[1] || l[1] == "": t.Errorf("slide %d's link is titled %q, its label is %q", i+1, l[1], w[1]) } // The number is text: drawn and hidden from a screen reader, and // its twin said, both before the label inside the link. n := fmt.Sprint(i + 1) want := ` ` + n + ` ` if !strings.Contains(li, want) { t.Errorf("slide %d's link does not start with its number, drawn and said, before the label:\n%s", i+1, li) } } if regexp.MustCompile(`counter\(|counter-(reset|increment)`).MatchString(readStatic(t, "editor.css")) { t.Error("static/editor.css still draws a CSS counter: the number is text now, and a counter could be said twice") } // The item the bundle clones has the title too, for relabel() to fill. tmpl := regexp.MustCompile(`(?s)`).FindString(page) if !regexp.MustCompile(`]*\btitle=`).MatchString(tmpl) { t.Errorf("the strip item template's link has no title:\n%s", tmpl) } } // The block in static/editor.css that holds every value the editor // needs and the published set lacks (spec §7), and the published sizes // and radii a declaration outside it uses instead. const ( namedValuesStart = "/* slides: named values */" namedValuesEnd = "/* end named values */" publishedSizes = "--rst-fs-xs|sm|base|lg, --rst-radius, --rst-radius-sm, --rst-radius-pill, --estilo-float-radius" ) // TestQuieterDeckSettingsMarkup (spec §8): the deck's settings are a // after , inside [slides-editor] so // its events reach the bundle, named by its own title; it holds the // deck form, method="dialog", with every deck control but the title // and one submit button, Close. Nothing in it carries the card's old // Deck group label. File has the row that opens it; the card holds no // deck form. func TestQuieterDeckSettingsMarkup(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)`).ReplaceAllString(page, "") open := regexp.MustCompile(`]*>`).FindStringSubmatchIndex(live) if open == nil { t.Fatalf("no in the editor") } dialog := extent(live, open[0]) if main := strings.Index(live, ""); main < 0 || open[0] < main { t.Error("the deck dialog is not after ") } if root := strings.Index(live, "
    ([^<]*)`).FindStringSubmatch(dialog) if title == nil || title[1] != "Deck settings" { t.Errorf("the dialog's aria-labelledby names %v, want an

    saying Deck settings", title) } forms := regexp.MustCompile(`
    ]*>`).FindAllString(dialog, -1) if len(forms) != 1 || forms[0] != `` { t.Errorf("the dialog's forms are %q, want one ", forms) } for _, want := range []string{ `name="rst-deck-theme"`, `name="rst-deck-accent"`, `data-command="accent-reset"`, `name="rst-deck-font-heading"`, `name="rst-deck-font-body"`, `
    ]*\stype="submit"[^>]*>([^<]*)`).FindAllStringSubmatch(dialog, -1) if len(submits) != 1 || submits[0][1] != "Close" { t.Errorf("the dialog's submit buttons are %q, want one, Close", submits) } if n := strings.Count(dialog, "Deck<`} { if strings.Contains(dialog, old) { t.Errorf("the deck dialog still has the card's Deck group label (%s)", old) } } file := regexp.MustCompile(`(?s)]*slides-menu="file".*?`).FindString(live) row := `` if !strings.Contains(file, row) { t.Errorf("the File menu has no %s:\n%s", row, file) } if n := strings.Count(live, `data-open-dialog="slides-deck-dialog"`); n != 1 { t.Errorf("%d rows open the deck dialog, want File's alone", n) } card := extent(live, strings.Index(live, "