//go:build browser // Seeing a slide's steps, and marking what is in the talk (steps and // presenter spec §4, In the editor; fixtures/play-through.mjs, // strip.mjs, commands.mjs): the "N presses" control in the slide's // bottom end corner that plays the slide through on the stage, Esc (or a // change of slide, or an edit) back to the finished slide; the strip's // count, the dashed edge on a full-only slide and the slim bar of a // parked one, final at the first paint; Skip in the short version and // Park, exclusive toggles in the strip's menu and the Slide menu; and // Deck settings' How things arrive. Every write is read back over the // API. package slidestest import ( "context" "encoding/json" "fmt" "net/http" "regexp" "strings" "testing" "amadan.net/rastrillo/rastrillo/harness" "github.com/chromedp/cdproto/accessibility" "github.com/chromedp/cdproto/cdp" "github.com/chromedp/cdproto/page" "github.com/chromedp/chromedp" "github.com/chromedp/chromedp/kb" ) // talkEditorDeck: a slide whose three texts arrive on presses 1, 2 and // 3 under a heading that arrives with it; a slide without steps; a // full-only slide; a parked one; and a last plain one. const talkEditorDeck = `[ {"op":"add_slide","id":"pressslide1","layout":"flow","template":"title-body"}, {"op":"add_block","slide":"pressslide1","id":"presshead001","type":"heading","region":"heading","props":{"level":1},"markdown":"Three presses"}, {"op":"add_block","slide":"pressslide1","id":"presstext001","type":"text","region":"body","markdown":"First"}, {"op":"add_block","slide":"pressslide1","id":"presstext002","type":"text","region":"body","markdown":"Second"}, {"op":"add_block","slide":"pressslide1","id":"presstext003","type":"text","region":"body","markdown":"Third"}, {"op":"set_block","slide":"pressslide1","id":"presstext001","step":1}, {"op":"set_block","slide":"pressslide1","id":"presstext002","step":2}, {"op":"set_block","slide":"pressslide1","id":"presstext003","step":3}, {"op":"add_slide","id":"plainslide2","layout":"flow","template":"title-body"}, {"op":"add_block","slide":"plainslide2","id":"plainhead002","type":"heading","region":"heading","props":{"level":1},"markdown":"No presses"}, {"op":"add_block","slide":"plainslide2","id":"plaintext002","type":"text","region":"body","markdown":"Words"}, {"op":"add_slide","id":"fullslide01","layout":"flow","template":"title-body"}, {"op":"add_block","slide":"fullslide01","id":"fullhead0001","type":"heading","region":"heading","props":{"level":1},"markdown":"Only in full"}, {"op":"set_slide","id":"fullslide01","talk":"full"}, {"op":"add_slide","id":"parkslide01","layout":"flow","template":"title-body"}, {"op":"add_block","slide":"parkslide01","id":"parkhead0001","type":"heading","region":"heading","props":{"level":1},"markdown":"Parked one"}, {"op":"set_slide","id":"parkslide01","talk":"parked"}, {"op":"add_slide","id":"lastslide01","layout":"flow","template":"title-body"}, {"op":"add_block","slide":"lastslide01","id":"lasthead0001","type":"heading","region":"heading","props":{"level":1},"markdown":"The end"}]` // openTalkEditor opens the editor on talkEditorDeck's first slide, and // an agent's token to read the deck back and to edit it as a colleague. func openTalkEditor(t *testing.T) (*tidyEditor, string) { t.Helper() te := openTidyEditorOn(t, 1280, 800, func(a *testApp, cookies []*http.Cookie) string { return quieterDeck(t, a, cookies, talkEditorDeck) }) token := mintAgent(t, te.app, te.cookies, "talk-editor") te.goToSlide("pressslide1") return te, token } // pressesSel is the stage's presses control. const pressesSel = `[slides-stage-pane] [slides-presses]` // pressesState: the control's words, whether it is drawn, and the // boxes on the stage waiting for a press, in the slide's order. type pressesState struct { Text string Shown bool Waiting []string } const pressesStateJS = `(() => { const b = document.querySelector('` + pressesSel + `') const waiting = [...document.querySelectorAll('[slides-stage] [data-waiting]')].map(e => e.closest('[slides-block]')?.dataset.id || '?') return { Text: b ? b.textContent.trim() : '', Shown: !!b && b.checkVisibility(), Waiting: waiting } })()` func (te *tidyEditor) presses() pressesState { var s pressesState te.rig.Run(evalInto(&s, pressesStateJS)) return s } // untilPresses waits until the control says text, with the boxes given // waiting (and only those), and none of them drawn. func (te *tidyEditor) untilPresses(t *testing.T, text string, waiting ...string) { t.Helper() want := strings.Join(waiting, " ") te.rig.Run(waitFor(`(() => { const s = ` + pressesStateJS + ` const hidden = [...document.querySelectorAll('[slides-stage] [data-waiting]')].every(e => !e.checkVisibility({ visibilityProperty: true })) return s.Text === ` + quote(text) + ` && s.Waiting.join(' ') === ` + quote(want) + ` && hidden })()`)) } // TestPlayThroughWalksThePresses: on a slide with three presses the // control says so, a real button at the slide's bottom end corner, // outside the slide and never over it; a click plays press 1, → and Space while it has // focus play the next ones, each hiding what has not yet arrived; a // click after the last is the finished slide again. Nothing is written. func TestPlayThroughWalksThePresses(t *testing.T) { te, token := openTalkEditor(t) te.rig.Run(waitFor(`document.querySelector('` + pressesSel + `')?.checkVisibility()`)) if s := te.presses(); s.Text != "3 presses" || len(s.Waiting) != 0 { t.Errorf("at rest the control is %+v, want 3 presses and nothing waiting", s) } te.atCorner(t, "at rest") te.rig.Screen(`[slides-stage-pane]`, "a slide with three presses, at rest") te.rig.Run(waitFor(`document.querySelector('`+pressesSel+`')`), chromedp.Click(chromedp.CSS(pressesSel))) te.untilPresses(t, "Press 1 of 3. Esc shows the finished slide.", "presstext002", "presstext003") te.atCorner(t, "playing press 1") te.rig.Screen(`[slides-stage-pane]`, "playing: press 1 of 3") te.rig.Run(waitFor(`document.activeElement === document.querySelector('`+pressesSel+`')`), chromedp.KeyEvent(kb.ArrowRight)) te.untilPresses(t, "Press 2 of 3. Esc shows the finished slide.", "presstext003") te.rig.Run(chromedp.KeyEvent(" ")) te.untilPresses(t, "Press 3 of 3. Esc shows the finished slide.") te.atCorner(t, "playing press 3") te.rig.Run(chromedp.Click(chromedp.CSS(pressesSel))) te.untilPresses(t, "3 presses") te.atCorner(t, "back at rest") s := te.apiSlide(t, token, "pressslide1") if stepOf(s, "presstext001") != 1 || stepOf(s, "presstext002") != 2 || stepOf(s, "presstext003") != 3 || s["talk"] != nil { t.Errorf("playing the slide changed it: %v", s) } } // atCorner checks the presses control is a real button just under the // slide's bottom end corner, its end edge on the slide's whatever its // words: never over the slide or the notes, never past the slide's // start or the window's edges, and at least a 24px target. func (te *tidyEditor) atCorner(t *testing.T, when string) { t.Helper() var where string te.rig.Run(chromedp.Sleep(100e6), evalInto(&where, `(() => { const b = document.querySelector('`+pressesSel+`'), s = document.querySelector('[slides-stage] [slides-slide]') const r = b.getBoundingClientRect(), q = s.getBoundingClientRect(), out = [] if (b.tagName !== 'BUTTON' || b.type !== 'button') out.push('it is a ' + b.tagName + ', not a button') if (b.closest('[slides-slide]')) out.push('it is inside the slide') if (r.top < q.bottom) out.push('it is over the slide: ' + JSON.stringify(r) + ' on ' + JSON.stringify(q)) if (Math.abs(q.right - r.right) > 1 || r.top - q.bottom > 8 || r.left < q.left - 0.5) out.push('it is not at the bottom end corner: ' + JSON.stringify(r) + ' under ' + JSON.stringify(q)) if (r.left < 0 || r.right > document.documentElement.clientWidth) out.push('it is past the window: ' + JSON.stringify(r)) const notes = document.querySelector('[slides-notes-pane]')?.getBoundingClientRect() if (notes && notes.height && r.bottom > notes.top) out.push('it is over the notes: ' + JSON.stringify(r) + ' above ' + JSON.stringify(notes)) if (r.width < 24 || r.height < 24) out.push('it is smaller than a 24px target: ' + r.width + 'x' + r.height) if (b.scrollWidth > b.clientWidth + 1) out.push('its words overflow it: ' + b.scrollWidth + ' in ' + b.clientWidth) return out.join('; ') })()`)) if where != "" { t.Errorf("%s, the presses control (%q): %s", when, te.presses().Text, where) } } // TestEscReturnsToTheFinishedSlide: while playing, Esc, a change of // slide, an edit here and a colleague's edit each show the finished // slide again. func TestEscReturnsToTheFinishedSlide(t *testing.T) { te, token := openTalkEditor(t) play := func() { te.rig.Run( waitFor(`document.querySelector('`+pressesSel+`')?.checkVisibility()`), chromedp.Click(chromedp.CSS(pressesSel)), ) te.untilPresses(t, "Press 1 of 3. Esc shows the finished slide.", "presstext002", "presstext003") } play() te.rig.Run(chromedp.KeyEvent(kb.Escape)) te.untilPresses(t, "3 presses") te.rig.Run(waitFor(`document.activeElement === document.querySelector('` + pressesSel + `')`)) // At 320px wide the whole sentence stays at the corner, inside the // slide's width and the window, and Esc puts the count back there. te.size(320, 700) te.rig.Run(chromedp.Evaluate[chromedp.Void](`document.querySelector('` + pressesSel + `').scrollIntoView({ block: 'center' })`)) te.atCorner(t, "320px, at rest") play() te.atCorner(t, "320px, playing") te.rig.Run(chromedp.KeyEvent(kb.Escape)) te.untilPresses(t, "3 presses") te.atCorner(t, "320px, after Esc") te.size(1280, 800) play() te.goToSlide("plainslide2") if s := te.presses(); s.Shown || len(s.Waiting) != 0 { t.Errorf("on a slide without presses after leaving one being played: %+v", s) } te.goToSlide("pressslide1") te.untilPresses(t, "3 presses") // An edit here: a word typed into the first text, the one shown. play() te.rig.Run(chromedp.Evaluate[chromedp.Void](`(() => { const p = document.querySelector('[slides-stage] [slides-block][data-id="presstext001"] p') const r = document.createRange(); r.selectNodeContents(p); r.collapse(false) const s = getSelection(); s.removeAllRanges(); s.addRange(r) p.closest('[contenteditable]').focus() })()`), chromedp.KeyEvent("!")) te.untilPresses(t, "3 presses") te.untilSlide(t, token, "pressslide1", "with First!", func(s map[string]any) bool { b, _ := blockOf(s, "presstext001") return strings.Contains(fmt.Sprint(b), "First!") }) // A colleague's. play() apiJSON(t, te.app, http.MethodPost, "/api/v1/decks/"+te.sqid()+"/ops", token, `{"ops":[{"op":"set_slide","id":"pressslide1","transition":"fade"}]}`, http.StatusOK) te.untilPresses(t, "3 presses") } // TestNoPressControlWithoutSteps: a slide with no steps has no control // and no count in the strip, and a slide whose last step is taken away // loses both. func TestNoPressControlWithoutSteps(t *testing.T) { te, token := openTalkEditor(t) te.goToSlide("plainslide2") te.rig.Run(chromedp.Sleep(300e6)) if s := te.presses(); s.Shown { t.Errorf("a slide without steps shows the control %+v", s) } if c := te.stripCount("plainslide2"); c.Text != "" || c.Shown { t.Errorf("a slide without steps has a count in the strip: %+v", c) } te.goToSlide("pressslide1") te.rig.Run(waitFor(`document.querySelector('` + pressesSel + `')?.checkVisibility()`)) apiJSON(t, te.app, http.MethodPost, "/api/v1/decks/"+te.sqid()+"/ops", token, `{"ops":[{"op":"set_block","slide":"pressslide1","id":"presstext001","step":null},{"op":"set_block","slide":"pressslide1","id":"presstext002","step":null},{"op":"set_block","slide":"pressslide1","id":"presstext003","step":null}]}`, http.StatusOK) te.rig.Run(waitFor(`!document.querySelector('` + pressesSel + `')?.checkVisibility()`)) te.rig.Run(waitFor(`!document.querySelector('[slides-strip-item][data-slide-id="pressslide1"] [slides-strip-presses]')?.checkVisibility()`)) } // stripCount is slide id's count in the strip: its words, whether they // are drawn, and whether they sit in its picture's bottom end corner. type stripCountState struct { Text string Shown bool Corner bool Visible bool } func (te *tidyEditor) stripCount(id string) stripCountState { var c stripCountState te.rig.Run(evalInto(&c, `(() => { const li = document.querySelector('[slides-strip-item][data-slide-id="`+id+`"]') const c = li.querySelector('[slides-strip-presses]'), th = li.querySelector('[slides-thumb]') if (!c) return { Text: '', Shown: false } const r = c.getBoundingClientRect(), q = th.getBoundingClientRect() return { Text: c.textContent.trim(), Shown: c.checkVisibility(), Corner: r.right <= q.right + 0.5 && r.bottom <= q.bottom + 0.5 && q.right - r.right <= 12 && q.bottom - r.bottom <= 12 && r.left >= q.left && r.top >= q.top } })()`)) return c } // stripIndex is slide id's place in the strip, 1-based. func (te *tidyEditor) stripIndex(id string) int { var n int te.rig.Run(evalInto(&n, `[...document.querySelectorAll('[slides-strip] > [slides-strip-item]')].findIndex(li => li.dataset.slideId === '`+id+`') + 1`)) return n } // TestStripCountsPresses: a slide with presses carries the count, small, // in its picture's bottom end corner and in its link's name; it follows // a step added to a slide that had none. func TestStripCountsPresses(t *testing.T) { te, token := openTalkEditor(t) if c := te.stripCount("pressslide1"); c.Text != "3 presses" || !c.Shown || !c.Corner { t.Errorf("the slide with three presses: its count is %+v, want 3 presses drawn in the picture's bottom end corner", c) } if name := stripName(t, te.rig, 0); name != "1 Three presses 3 presses Current slide" && name != "1 Three presses Current slide 3 presses" { t.Errorf("the slide with three presses is named %q, want its count in it", name) } if c := te.stripCount("lastslide01"); c.Text != "" || c.Shown { t.Errorf("a slide without steps has a count %+v", c) } te.rig.Screen(`[slides-strip-nav]`, "the strip, a slide with three presses") apiJSON(t, te.app, http.MethodPost, "/api/v1/decks/"+te.sqid()+"/ops", token, `{"ops":[{"op":"set_block","slide":"plainslide2","id":"plaintext002","step":1}]}`, http.StatusOK) te.rig.Run(waitFor(`document.querySelector('[slides-strip-item][data-slide-id="plainslide2"] [slides-strip-presses]')?.textContent.trim() === '1 press'`)) if c := te.stripCount("plainslide2"); !c.Shown || !c.Corner { t.Errorf("a step added: the count is %+v, want 1 press drawn in the corner", c) } } // TestAFullOnlySlideHasADashedEdge: the full-only slide's picture has a // dashed edge and its name says Full version only; the others have // neither, and taking it off takes both away. func TestAFullOnlySlideHasADashedEdge(t *testing.T) { te, token := openTalkEditor(t) edge := func(id string) string { var s string te.rig.Run(evalInto(&s, `(t => { const c = getComputedStyle(t); return c.outlineStyle + ' ' + c.borderTopStyle })(document.querySelector('[slides-strip-item][data-slide-id="`+id+`"] [slides-thumb]'))`)) return s } if e := edge("fullslide01"); !strings.Contains(e, "dashed") { t.Errorf("the full-only slide's picture's edge is %q, want dashed", e) } for _, id := range []string{"pressslide1", "plainslide2", "lastslide01"} { if e := edge(id); strings.Contains(e, "dashed") { t.Errorf("%s's picture's edge is %q, want no dashes", id, e) } } n := te.stripIndex("fullslide01") if name := stripName(t, te.rig, n-1); name != "3 Only in full Full version only" { t.Errorf("the full-only slide is named %q, want 3 Only in full Full version only", name) } te.rig.Screen(`[slides-strip-nav]`, "the strip, a full-only slide") apiJSON(t, te.app, http.MethodPost, "/api/v1/decks/"+te.sqid()+"/ops", token, `{"ops":[{"op":"set_slide","id":"fullslide01","talk":null}]}`, http.StatusOK) te.rig.Run(waitFor(`!document.querySelector('[slides-strip-item][data-slide-id="fullslide01"]').hasAttribute('data-talk')`)) if e := edge("fullslide01"); strings.Contains(e, "dashed") { t.Errorf("back in the talk, the slide's edge is still %q", e) } if name := stripName(t, te.rig, n-1); name != "3 Only in full" { t.Errorf("back in the talk, the slide is named %q", name) } } // TestAParkedSlideIsASlimBarInPlace: the parked slide keeps its place // in the strip, drawn as a slim bar showing its title and no picture, // and named with Parked after its title. func TestAParkedSlideIsASlimBarInPlace(t *testing.T) { te, _ := openTalkEditor(t) if n := te.stripIndex("parkslide01"); n != 4 { t.Errorf("the parked slide is %d in the strip, want 4, its place in the deck", n) } var bar struct { Bar, Thumb float64 Title string TitleShown bool PictureShown bool Number, NumberT string } te.rig.Run(evalInto(&bar, `(() => { const li = document.querySelector('[slides-strip-item][data-slide-id="parkslide01"]') const other = document.querySelector('[slides-strip-item][data-slide-id="lastslide01"]') const label = li.querySelector('[slides-strip-label]') const r = label.getBoundingClientRect() return { Bar: li.getBoundingClientRect().height, Thumb: other.getBoundingClientRect().height, Title: label.textContent, TitleShown: label.checkVisibility() && r.width > 40 && r.height > 8, PictureShown: li.querySelector('[slides-thumb]').checkVisibility(), Number: li.querySelector('[slides-strip-number]').textContent } })()`)) if bar.Bar <= 0 || bar.Bar > bar.Thumb/2 { t.Errorf("the parked slide is %.1fpx tall beside a slide's %.1fpx, want a slim bar", bar.Bar, bar.Thumb) } if bar.Title != "Parked one" || !bar.TitleShown { t.Errorf("the parked bar's title is %q (drawn %v), want Parked one drawn", bar.Title, bar.TitleShown) } if bar.PictureShown { t.Error("the parked bar still draws the slide's picture") } if bar.Number != "4" { t.Errorf("the parked bar's number is %q, want 4", bar.Number) } if name := stripName(t, te.rig, 3); name != "4 Parked one Parked" { t.Errorf("the parked slide is named %q, want 4 Parked one Parked", name) } te.rig.Screen(`[slides-strip-nav]`, "the strip, a parked slide as a slim bar") // It still opens on the stage, finished. te.goToSlide("parkslide01") } // stripTalkJS: each strip item's data-talk, count and talk words, in // order, as "id:talk:count:words". const stripTalkJS = `[...document.querySelectorAll('[slides-strip] > [slides-strip-item]')].map(li => li.dataset.slideId + ':' + (li.dataset.talk || '') + ':' + (li.querySelector('[slides-strip-presses]')?.textContent.trim() || '') + ':' + (li.querySelector('[slides-strip-talk]')?.textContent.trim() || ''))` // TestStripIsFinalAtFirstPaint: the server draws each strip item's // talk, its words and its count; once the bundle is bound nothing of it // has changed (a watcher from the end of parsing, before any script, // saw no change). func TestStripIsFinalAtFirstPaint(t *testing.T) { te := newTidyEditor(t, 1280, 800, func(a *testApp, cookies []*http.Cookie) string { return quieterDeck(t, a, cookies, talkEditorDeck) }) body := mustGet(t, te.app, te.path, http.StatusOK, te.cookies).Body.String() live := regexp.MustCompile(`(?s)`).ReplaceAllString(body, "") for _, want := range []string{ `data-slide-id="fullslide01" data-talk="full"`, `data-slide-id="parkslide01" data-talk="parked"`, `3 presses`, `Full version only`, `Parked`, } { if !strings.Contains(live, want) { t.Errorf("the server's strip has no %s", want) } } te.rig.Run( cdpStep(page.AddScriptToEvaluateOnNewDocument, page.AddScriptToEvaluateOnNewDocumentParams{Source: ` window.__stripChanges = [] // From the end of parsing, before any script runs: the // parser's own insertions are the first paint, not changes. const watch = () => new MutationObserver(list => { for (const m of list) { const t = m.target.nodeType === 1 ? m.target : m.target.parentElement if (!t || !t.closest('[slides-strip-item]')) continue if (m.type === 'attributes' && m.attributeName !== 'data-talk' && m.attributeName !== 'aria-pressed') continue if (m.type !== 'attributes' && !t.closest('[slides-strip-presses], [slides-strip-talk], [slides-strip-label]')) continue window.__stripChanges.push(m.type + ' ' + (m.attributeName || '') + ' on ' + t.closest('[slides-strip-item]').dataset.slideId) } }).observe(document, { subtree: true, childList: true, attributes: true, characterData: true }) document.addEventListener('readystatechange', () => { if (document.readyState === 'interactive') watch() })`}), chromedp.Navigate(te.rig.Origin+te.path), chromedp.WaitVisible(chromedp.CSS(`[slides-editor]`)), waitFor(editorBound), chromedp.Sleep(500e6), ) var changes, items []string te.rig.Run(evalInto(&changes, `window.__stripChanges`), evalInto(&items, stripTalkJS)) if len(changes) != 0 { t.Errorf("the strip changed once the bundle bound: %q", changes) } want := "pressslide1::3 presses:|plainslide2:::|fullslide01:full::Full version only|parkslide01:parked::Parked|lastslide01:::" if got := strings.Join(items, "|"); got != want { t.Errorf("the strip is %s, want %s", got, want) } } // talkRows: a menu's two talk rows as the accessibility tree has them, // "role:name:pressed" each. Both menus are plain disclosures of buttons // (estilo's menubar
, rastrillo's dropdown), so a toggle row // is a button that is pressed or not, as the View menu's rows are. func (te *tidyEditor) talkRows(t *testing.T, menu string) string { t.Helper() var rows []string for _, c := range []string{"slide-talk-full", "slide-talk-parked"} { sel := menu + ` [data-command="` + c + `"], ` + menu + ` [data-slide-command="` + c + `"]` var nodes []*chromedp.Node te.rig.Run(harness.Into(&nodes, chromedp.Nodes(chromedp.CSS(sel)))) te.rig.Run(chromedp.Func(func(ctx2 context.Context, t *chromedp.Target) error { res, err := cdp.Call(ctx2, t, accessibility.GetPartialAXTree, accessibility.GetPartialAXTreeParams{BackendNodeID: nodes[0].BackendNodeID, FetchRelatives: new(false)}) if err != nil { return err } ax := res.Nodes if len(ax) == 0 { return fmt.Errorf("%s is not in the accessibility tree", sel) } n := ax[0] var role, name string if n.Role != nil { _ = json.Unmarshal(n.Role.Value, &role) } if n.Name != nil { _ = json.Unmarshal(n.Name.Value, &name) } pressed := "none" for _, p := range n.Properties { if p.Name == accessibility.PropertyNamePressed { var v any _ = json.Unmarshal(p.Value.Value, &v) pressed = fmt.Sprint(v) } } rows = append(rows, role+":"+strings.Join(strings.Fields(name), " ")+":"+pressed) return nil })) } return strings.Join(rows, " | ") } // talkRowsAre is talkRows' answer for a slide whose talk is full, parked or "". func talkRowsAre(talk string) string { return "button:Skip in the short version:" + fmt.Sprint(talk == "full") + " | button:Park:" + fmt.Sprint(talk == "parked") } const ( stripMenu = `[slides-strip-item][data-slide-id="pressslide1"] [slides-strip-menu]` slideMenu = `[slides-menu="slide"]` ) func talkIs(want string) func(map[string]any) bool { return func(s map[string]any) bool { got, _ := s["talk"].(string) return got == want } } // TestParkAndSkipAreExclusive: the strip item's menu and the Slide menu // each have Skip in the short version and Park as toggle buttons, // pressed or not in the accessibility tree; each // is one write that clears the other, and choosing a checked one again // takes it away. One undo takes one back. func TestParkAndSkipAreExclusive(t *testing.T) { te, token := openTalkEditor(t) openStrip := chromedp.Steps( chromedp.Click(chromedp.CSS(stripMenu+` > summary`)), waitFor(`document.querySelector('`+stripMenu+`').open`), ) openSlide := chromedp.Steps( chromedp.Click(chromedp.CSS(slideMenu+` > summary`)), waitFor(`document.querySelector('`+slideMenu+`').open`), ) te.rig.Run(openStrip) if got := te.talkRows(t, stripMenu); got != talkRowsAre("") { t.Errorf("the strip item's menu has %q, want %q", got, talkRowsAre("")) } te.rig.Screen(`[slides-strip-nav]`, "the strip item's menu with its talk rows") te.rig.Run(waitFor(`document.querySelector('`+stripMenu+` [data-slide-command="slide-talk-full"]')`), chromedp.Click(chromedp.CSS(stripMenu+` [data-slide-command="slide-talk-full"]`)), waitFor(`!document.querySelector('`+stripMenu+`').open`)) te.untilSlide(t, token, "pressslide1", "full only", talkIs("full")) te.rig.Run(openSlide) if got := te.talkRows(t, slideMenu); got != talkRowsAre("full") { t.Errorf("full only, the Slide menu has %q, want %q", got, talkRowsAre("full")) } te.rig.Run(waitFor(`document.querySelector('`+slideMenu+` [data-command="slide-talk-parked"]')`), chromedp.Click(chromedp.CSS(slideMenu+` [data-command="slide-talk-parked"]`)), waitFor(`!document.querySelector('`+slideMenu+`').open`)) te.untilSlide(t, token, "pressslide1", "parked", talkIs("parked")) te.rig.Run(waitFor(`document.querySelector('[slides-strip-item][data-slide-id="pressslide1"]').dataset.talk === 'parked'`)) te.rig.Run(openStrip) if got := te.talkRows(t, stripMenu); got != talkRowsAre("parked") { t.Errorf("parked, the strip item's menu has %q, want %q", got, talkRowsAre("parked")) } te.rig.Run(chromedp.KeyEvent(kb.Escape)) // One undo: full only again, not in the talk. te.rig.Run( chromedp.Click(chromedp.CSS(`[slides-menu="edit"] > summary`)), waitFor(`document.querySelector('[slides-menu="edit"]')?.open === true`), chromedp.Click(chromedp.CSS(`[slides-menu="edit"] [data-command="undo"]`)), ) te.untilSlide(t, token, "pressslide1", "full only again", talkIs("full")) // Skip again, already checked: back in the talk. te.rig.Run(openSlide, chromedp.Click(chromedp.CSS(slideMenu+` [data-command="slide-talk-full"]`))) te.untilSlide(t, token, "pressslide1", "back in the talk", talkIs("")) te.rig.Run(openSlide) if got := te.talkRows(t, slideMenu); got != talkRowsAre("") { t.Errorf("back in the talk, the Slide menu has %q, want %q", got, talkRowsAre("")) } } // TestHowThingsArriveIsSaved: Deck settings has How things arrive, // Appear at first; Fade in and Rise are written, and Appear takes the // setting away. func TestHowThingsArriveIsSaved(t *testing.T) { te, token := openTalkEditor(t) te.rig.Run(openDeckSettings()) var field struct { Label string Value string Options []string } te.rig.Run(evalInto(&field, `(() => { const s = document.querySelector('[slides-deck-dialog] [name="rst-deck-arrive"]') return { Label: s.labels[0]?.textContent.trim() || '', Value: s.value, Options: [...s.options].map(o => o.value + '=' + o.textContent.trim()) } })()`)) if field.Label != "How things arrive" || field.Value != "appear" || strings.Join(field.Options, "|") != "appear=Appear|fade=Fade in|rise=Rise" { t.Errorf("Deck settings' arrival field is %+v", field) } te.rig.Screen(`[slides-deck-dialog]`, "Deck settings with How things arrive") arrive := func() string { view := apiJSON(t, te.app, http.MethodGet, "/api/v1/decks/"+te.sqid(), token, "", http.StatusOK) meta, _ := view["meta"].(map[string]any) v, _ := meta["arrive"].(string) return v } for _, v := range []string{"fade", "rise", "appear"} { te.rig.Run(chromedp.SetValue(chromedp.CSS(`[slides-deck-dialog] [name="rst-deck-arrive"]`), v), chromedp.Evaluate[chromedp.Void](`document.querySelector('[slides-deck-dialog] [name="rst-deck-arrive"]').dispatchEvent(new Event('change', { bubbles: true }))`)) want := v if v == "appear" { want = "" } for tries := 0; arrive() != want && tries < 200; tries++ { te.rig.Run(chromedp.Sleep(100e6)) } if got := arrive(); got != want { t.Errorf("chose %s: the deck's arrive is %q, want %q", v, got, want) } } }