package gallery import ( "fmt" "strings" "testing" ) // TestTheColumnPreviewRestsShorterThanItOpens: the column's footer // menus open downward under the page, and a box that always held them // open showed about 300px of nothing under the page at rest. So the // column has a rest height, and every rest height is written beside // the open one for view.js to switch to: under the open height on // Desktop and on Mobile in every locale, since a rest height at or // over the open one could only hide a short open box. A key without // one carries no rest height at all, so view.js leaves it alone. func TestTheColumnPreviewRestsShorterThanItOpens(t *testing.T) { column := "layout-column/" + mustEntry(t, "layout-column").Default if _, ok := previewRestHeights[column]; !ok { t.Errorf("%s has no rest height; its box holds the open footer menus at rest", column) } m := manifest(t) for key, rest := range previewRestHeights { name, state, _ := strings.Cut(key, "/") if e, ok := m.Entry(name); !ok || !hasState(e, state) { t.Errorf("previewRestHeights[%q] names no example state", key) continue } for _, locale := range Locales { open, openMobile := previewHeightsFor(locale, key) if rest.Desktop >= open || rest.Mobile >= openMobile { t.Errorf("%s in %s rests at %d, %d and opens at %d, %d; the rest height must be under the open one", key, locale, rest.Desktop, rest.Mobile, open, openMobile) } want := fmt.Sprintf("--ds-hr: %dpx; --ds-hmr: %dpx", rest.Desktop, rest.Mobile) if got := string(previewStyle(locale, key)); !strings.Contains(got, want) { t.Errorf("%s in %s: the widget's style is %q, want it to carry %q", key, locale, got, want) } } } for _, key := range []string{"button/default", "dropdown/" + mustEntry(t, "dropdown").Default} { if got := string(previewStyle("en", key)); strings.Contains(got, "--ds-hr") { t.Errorf("%s has no rest height and its style %q carries one", key, got) } } }