| index 2492c89..e2ab388 100644 |
| --- a/internal/browsertest/oficina_test.go |
| +++ b/internal/browsertest/oficina_test.go |
| @@ -5,10 +5,12 @@ package browsertest |
| import ( |
| "context" |
| "encoding/json" |
| + "fmt" |
| "net/http" |
| "os" |
| "path/filepath" |
| "testing" |
| + "time" |
| |
| "github.com/chromedp/chromedp" |
| |
| @@ -177,3 +179,44 @@ func TestOficinaRail(t *testing.T) { |
| drive(t, rig, chromedp.Navigate(rig.Origin+"/"), chromedp.WaitVisible(chromedp.CSS(".hello"))) |
| viewportShot(t, rig, "home-desktop") |
| } |
| + |
| +// The open Ask panel keeps a gap to the Oficina rail at every width the |
| +// rail shows at, and nothing runs off the screen. |
| +func TestAskPanelBesideRail(t *testing.T) { |
| + f := equipotest.New(t) |
| + apps := teamApps(t) |
| + var b *baseApp |
| + rig := newRig(t, func(origin string) http.Handler { |
| + cfg := baseConfig(origin) |
| + cfg.EquipoOrigin = f.URL |
| + cfg.OficinaApps = apps |
| + b = newBase(t, cfg) |
| + return b.handler |
| + }) |
| + drive(t, rig, chromedp.EmulateViewport(1280, 800)) |
| + signInByEmail(t, rig, rig.Origin, b.mail) |
| + for _, width := range []int64{601, 640, 700, 800, 900, 1024, 1280} { |
| + drive(t, rig, chromedp.EmulateViewport(width, 800), chromedp.Navigate(rig.Origin+"/"), chromedp.WaitVisible(chromedp.CSS(`a.ask`)), |
| + chromedp.Click(chromedp.CSS(`a.ask`)), |
| + chromedp.Poll[chromedp.Void](`(() => { const p = document.querySelector("#ask-panel"); return p.open && getComputedStyle(p).transform === "none" && getComputedStyle(p).opacity === "1"; })()`, |
| + chromedp.WithPollingTimeout(5*time.Second))) |
| + if got := harness.Evaluate[string](rig, `(() => { |
| + const problems = [], vw = document.documentElement.clientWidth; |
| + const rail = document.querySelector("nav.rail").getBoundingClientRect(); |
| + const p = document.querySelector("#ask-panel").getBoundingClientRect(); |
| + if (rail.width === 0) problems.push("no rail"); |
| + if (p.left < rail.right + 12 || p.width < 200) problems.push("panel starts at " + p.left + ", rail ends at " + rail.right); |
| + if (p.right > vw) problems.push("panel ends at " + p.right + " of " + vw); |
| + if (p.width > 460.5) problems.push("panel is " + p.width + " wide"); |
| + if (document.documentElement.scrollWidth > vw) problems.push("page is " + document.documentElement.scrollWidth + " wide"); |
| + return problems.join("; "); |
| + })()`); got != "" { |
| + t.Errorf("at %dx800: %s", width, got) |
| + } |
| + if width == 800 || width == 1280 { |
| + viewportShot(t, rig, fmt.Sprintf("panel-%d", width)) |
| + } |
| + drive(t, rig, chromedp.KeyEvent("\u001b"), |
| + chromedp.Poll[chromedp.Void](`!document.querySelector("#ask-panel").open`, chromedp.WithPollingTimeout(5*time.Second))) |
| + } |
| +} |