oficina / slides Public

Tests: walk the whole talk; the watcher check signs out

The walk (SLIDES_WALK=1) builds 105 talk slides plus 64 parked or
full-only, 240 presses, and presses each in the presenter window.
TestInPlaceSlideChangesKeepFocusAndAreAnnounced took the signed-in
presenter for a watcher; on a session with a position that page now
carries the controls, so the watcher half signs out first.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 852e3f639f61794b0157641cf2ee99002445446d parent e13978c
2 files changed, +105 −0
  • internal/slidestest/presenter_walk_browser_test.go +101 −0
  • internal/slidestest/races_browser_test.go +4 −0
diff --git a/internal/slidestest/presenter_walk_browser_test.go b/internal/slidestest/presenter_walk_browser_test.go
new file mode 100644
index 0000000..7515d19
--- /dev/null
+++ b/internal/slidestest/presenter_walk_browser_test.go
@@ -0,0 +1,101 @@
+//go:build browser
+
+// The talk's whole shape, walked press by press (Task 16). It is slow
+// and only runs when asked: SLIDES_WALK=1 go test -tags browser -run
+// TestPresenterWalksTheWholeTalk ./internal/slidestest/
+package slidestest
+
+import (
+ "fmt"
+ "os"
+ "strconv"
+ "strings"
+ "testing"
+
+ "github.com/chromedp/chromedp"
+ "github.com/chromedp/chromedp/kb"
+)
+
+// TestPresenterWalksTheWholeTalk is a deck of the talk's real size: 105
+// slides in the talk (34 of them with four steps), 40 parked and 24
+// shown only in the full version. In the core talk that is 104 slide
+// changes and 136 steps, 240 presses. Every press must change the
+// window's slide or step, and the document must never scroll.
+func TestPresenterWalksTheWholeTalk(t *testing.T) {
+ if os.Getenv("SLIDES_WALK") == "" {
+ t.Skip("set SLIDES_WALK=1 to walk the whole talk")
+ }
+ mt := newMovesTalk(t)
+ // Start from an empty deck of our own on the same rig.
+ sqid := mt.fr.deck(t, "Walk", `[]`)
+ var ops []string
+ add := func(id, head, talk string, steps int) {
+ ops = append(ops,
+ `{"op":"add_slide","id":`+quote(id)+`,"layout":"flow","template":"title-body"}`,
+ `{"op":"add_block","slide":`+quote(id)+`,"id":`+quote(id+"h")+`,"type":"heading","region":"heading","props":{"level":1},"markdown":`+quote(head)+`}`)
+ for k := 1; k <= steps; k++ {
+ b := quote(id + "b" + strconv.Itoa(k))
+ ops = append(ops,
+ `{"op":"add_block","slide":`+quote(id)+`,"id":`+b+`,"type":"text","region":"body","markdown":`+quote("line "+strconv.Itoa(k))+`}`,
+ `{"op":"set_block","slide":`+quote(id)+`,"id":`+b+`,"step":`+strconv.Itoa(k)+`}`)
+ }
+ if talk != "" {
+ ops = append(ops, `{"op":"set_slide","id":`+quote(id)+`,"talk":`+quote(talk)+`}`)
+ }
+ }
+ for i := range 105 {
+ steps := 0
+ if i%3 == 0 && i/3 < 34 {
+ steps = 4
+ }
+ add(fmt.Sprintf("t%03d", i), fmt.Sprintf("Talk %03d", i), "", steps)
+ // Interleave the others: 64 across the 105.
+ if i < 64 {
+ talk := "parked"
+ if i%8 < 3 {
+ talk = "full"
+ }
+ add(fmt.Sprintf("x%03d", i), fmt.Sprintf("Aside %03d", i), talk, 0)
+ }
+ }
+ for i := 0; i < len(ops); i += 100 {
+ mt.fr.ops(t, sqid, "["+strings.Join(ops[i:min(i+100, len(ops))], ",")+"]")
+ }
+ mt.session, mt.token = startPresenting(t, mt.fr.app, "/d/"+sqid, mt.fr.cookies)
+
+ ctx := mt.fr.rig.Context()
+ open(t, ctx, mt.fr.rig.Origin, mt.presenter())
+ var scroll struct{ Y, SH, VH float64 }
+ const scrollJS = `({ Y: window.scrollY, SH: document.documentElement.scrollHeight, VH: innerHeight })`
+ seen := map[string]bool{}
+ presses := 0
+ before := state(t, ctx)
+ if before.Mode != "core" {
+ t.Fatalf("the window starts in mode %q, want core", before.Mode)
+ }
+ for {
+ if !strings.HasPrefix(before.Now, "Talk") {
+ t.Fatalf("press %d: the window shows %q, which is not a talk slide", presses, before.Now)
+ }
+ seen[before.Slide] = true
+ run(t, ctx, key(kb.ArrowRight))
+ got := state(t, ctx)
+ if got.Slide == before.Slide && got.Step == before.Step {
+ break // the last press of the talk moves nothing
+ }
+ presses++
+ if got.Mode != "core" {
+ t.Fatalf("press %d: the mode became %q", presses, got.Mode)
+ }
+ run(t, ctx, chromedp.Evaluate(scrollJS, &scroll))
+ if scroll.Y != 0 || scroll.SH > scroll.VH {
+ t.Fatalf("press %d: the document scrolls: %+v", presses, scroll)
+ }
+ before = got
+ }
+ seen[before.Slide] = true
+ if len(seen) != 105 || presses != 240 {
+ t.Fatalf("walked %d slides and %d presses, want 105 and 240", len(seen), presses)
+ }
+ mt.waitRow(t, "t104", 0)
+}
diff --git a/internal/slidestest/races_browser_test.go b/internal/slidestest/races_browser_test.go
index fac1d85..d7c457b 100644
--- a/internal/slidestest/races_browser_test.go
+++ b/internal/slidestest/races_browser_test.go
@@ -11,6 +11,7 @@ import (
"testing"
"time"
+ "github.com/chromedp/cdproto/network"
"github.com/chromedp/cdproto/page"
"github.com/chromedp/chromedp"
)
@@ -401,6 +402,9 @@ func TestInPlaceSlideChangesKeepFocusAndAreAnnounced(t *testing.T) {
fr.until(t, `document.querySelector('[slides-surface]').dataset.slide === '2' && document.querySelector('[slides-announce]').textContent !== ''`)
fr.rig.Run(chromedp.Sleep(500 * time.Millisecond))
check("projector, the Next button", "next", "Slide 2 of 3: Second")
+ // A watcher is somebody who is not signed in: on a session with a
+ // position the signed-in presenter gets the controls here instead.
+ fr.rig.Run(network.ClearBrowserCookies())
fr.goTo(t, "/p/"+session+"?slide=2")
fr.rig.Run(chromedp.Sleep(300 * time.Millisecond))
fr.eval(t, `document.querySelector('[slides-bar] a[rel="next"]').focus(); true`, nil)