//go:build browser // The editor's chrome against the suite's: the header is estilo's stacked // bar, "Saved" does not stay on screen, and the strip's ⋮ has no outline. package slidestest import ( "testing" "time" "github.com/chromedp/chromedp" "github.com/chromedp/chromedp/kb" ) func TestEditorHeaderIsTheSuites(t *testing.T) { te := openTidyEditor(t, 3, 1440, 900) var got string te.rig.Run(evalInto(&got, `(() => { const q = s => document.querySelector(s), out = [] const want = (name, have, is) => { if (have !== is) out.push(name + ' is ' + have + ', want ' + is) } want('the bar', q('[slides-head]').getBoundingClientRect().height, 56) want('the title', getComputedStyle(q('[slides-head-title]')).fontSize, '16px') want('a menu', getComputedStyle(q('[estilo-menubar-title]')).fontSize, '13px') want('the icon', q('[slides-head-brand] img').getBoundingClientRect().width, 32) want('the history pill', q('[slides-history]').getBoundingClientRect().height, 28) want('the history outline', getComputedStyle(q('[slides-history]')).outlineStyle, 'none') return out.join('; ') })()`)) if got != "" { t.Error(got) } for _, width := range []int64{390, 320} { te.size(width, 800) var over float64 te.rig.Run(chromedp.Sleep(200*time.Millisecond), evalInto(&over, `document.documentElement.scrollWidth - innerWidth`)) if over > 0 { t.Errorf("at %dpx the page is %vpx wider than the window", width, over) } } } func TestEditorSavedFadesAfterASave(t *testing.T) { te := openTidyEditor(t, 3, 1440, 900) const opacity = `getComputedStyle(document.querySelector('[estilo-save-status]')).opacity` var rest string te.rig.Run(evalInto(&rest, opacity)) if rest != "0" { t.Errorf("a page that has just opened shows its save line: opacity %s", rest) } te.rig.Run( chromedp.Evaluate[chromedp.Void](`(() => { const i = document.querySelector('[slides-head-title]') i.value = 'Renamed' i.dispatchEvent(new Event('change', { bubbles: true })) })()`), waitFor(`document.querySelector('[estilo-save-status]').dataset.state === 'saved' && `+opacity+` === '1'`), waitFor(opacity+` === '0'`), ) } // Escape in the title goes back to the deck's current title, not the one // the page opened with: estilo's bar restores the field's default value. func TestEditorTitleEscapeKeepsTheLastRename(t *testing.T) { te := openTidyEditor(t, 3, 1440, 900) const field = `document.querySelector('[slides-head-title]')` te.rig.Run( chromedp.Evaluate[chromedp.Void](field+`.select()`), chromedp.SendKeys(chromedp.CSS(`[slides-head-title]`), "Second title"+kb.Enter), waitFor(`document.title.includes('Second title') && document.querySelector('[estilo-save-status]').dataset.state === 'saved'`), chromedp.Evaluate[chromedp.Void](field+`.select()`), chromedp.SendKeys(chromedp.CSS(`[slides-head-title]`), "Abandoned"+kb.Escape), waitFor(field+`.value === 'Second title' && document.activeElement !== `+field), chromedp.Sleep(500*time.Millisecond), waitFor(`document.querySelector('[estilo-save-status]').dataset.state === 'saved'`), chromedp.Reload(), chromedp.WaitVisible(chromedp.CSS(`[slides-editor]`)), waitFor(editorBound), waitFor(field+`.value === 'Second title'`), ) } func TestEditorStripMenuHasNoOutline(t *testing.T) { te := openTidyEditor(t, 3, 1440, 900) var got string te.rig.Run(evalInto(&got, `(() => { const s = getComputedStyle(document.querySelector('[slides-strip-item] [slides-strip-menu] > summary')) return s.borderTopColor + ' ' + s.width })()`)) if got != "rgba(0, 0, 0, 0) 24px" { t.Errorf("the strip's menu button: %s", got) } }