| index 720aac6..0d43943 100644 |
| --- a/internal/sheets/chrome_test.go |
| +++ b/internal/sheets/chrome_test.go |
| @@ -151,9 +151,10 @@ func TestTheSignedOutCorner(t *testing.T) { |
| } |
| } |
| |
| -// §6: the switcher shows only when Home names a hub directory, and then |
| -// holds "All apps" alone (Paul's §13 answer 2) — no tiles yet. |
| -func TestTheSwitcherIsAllAppsOnly(t *testing.T) { |
| +// §6: the switcher shows only when Home names a hub directory. It holds |
| +// the suite's six apps as tiles at their hosts under the directory's, |
| +// with Sheets marked current, and "All apps" below a divider. |
| +func TestTheSwitcherShowsTheSuite(t *testing.T) { |
| app, cookies := signIn(t) |
| if body := page(t, app, cookies, "/sheets").Body.String(); strings.Contains(body, "estilo-switcher") { |
| t.Error("a standalone instance shows a switcher; there is no directory to switch through") |
| @@ -161,13 +162,44 @@ func TestTheSwitcherIsAllAppsOnly(t *testing.T) { |
| f := newHomeFixtureWith(t, "https://oficina.example.com") |
| f.local(t, signedInAddress) |
| body := f.request(t, "GET", "/sheets", nil, false).Body.String() |
| - for _, want := range []string{`<details estilo-switcher name="estilo-menus">`, `aria-label="Oficina apps"`, `<a estilo-menu-item href="https://oficina.example.com/"><span estilo-menu-label>All apps</span></a>`} { |
| - if !strings.Contains(body, want) { |
| - t.Errorf("the switcher lacks %s", want) |
| + if !strings.Contains(body, `aria-label="Oficina apps"`) { |
| + t.Error("the switcher is not labelled Oficina apps") |
| + } |
| + start := strings.Index(body, `<details estilo-switcher name="estilo-menus">`) |
| + if start < 0 { |
| + t.Fatal("no switcher", body) |
| + } |
| + panel := body[start:] |
| + panel = panel[:strings.Index(panel, "</details>")] |
| + grid, allApps, ok := strings.Cut(panel, "<hr>") |
| + if !ok || !strings.Contains(allApps, `<a estilo-menu-item href="https://oficina.example.com/"><span estilo-menu-label>All apps</span></a>`) { |
| + t.Error("the switcher does not offer All apps below the tiles", panel) |
| + } |
| + var tiles []string |
| + for _, tile := range strings.Split(grid, "<a estilo-switcher-app ")[1:] { |
| + tiles = append(tiles, tile[:strings.Index(tile, "</a>")]) |
| + } |
| + want := []string{"docs", "sheets", "slides", "calendar", "memoria", "calls"} |
| + names := []string{"Docs", "Sheets", "Slides", "Calendar", "Memoria", "Calls"} |
| + if len(tiles) != len(want) { |
| + t.Fatalf("%d tiles, want %d: %s", len(tiles), len(want), grid) |
| + } |
| + for i, slug := range want { |
| + head := `href="https://` + slug + `.oficina.example.com/"` |
| + if slug == "sheets" { |
| + head += ` aria-current="true"` |
| } |
| + head += `><img src="/static/estilo/brand/` + slug + `.svg" alt="" width="32" height="32"><span>` + names[i] |
| + if !strings.HasPrefix(tiles[i], head) { |
| + t.Errorf("tile %d = %s, want it to start %s", i, tiles[i], head) |
| + } |
| + } |
| + if strings.Count(grid, "aria-current") != 1 || !strings.Contains(tiles[1], "<span estilo-visually-hidden> (this app)</span>") { |
| + t.Error("Sheets is not the one current tile", grid) |
| } |
| - if strings.Contains(body, "estilo-switcher-app") { |
| - t.Error("the switcher renders app tiles before Home's /apps/<slug> hop is ready") |
| + // Every tile's icon is served here, publicly: no cookies at all. |
| + if rec := do(t, app, httptest.NewRequest(http.MethodGet, "/static/estilo/brand/calls.svg", nil)); rec.Code != http.StatusOK { |
| + t.Errorf("a tile's icon is %d", rec.Code) |
| } |
| } |
| |