package web
import (
"bytes"
"strings"
"testing"
)
// The fleet family's nav follows the same tab convention as the repo
// and explore bars: underline tabs whose ink carries a
// view-transition-name. One nav reaches all four surfaces, so none of
// them can ship unreachable again — /fleet/ops did, twice.
func TestFleetNavWearsTheSharedTabs(t *testing.T) {
for _, tc := range []struct{ tab, here string }{
{"stores", `href="/fleet" class="here"`},
{"ops", `href="/fleet/ops" class="here"`},
{"errors", `href="/fleet/exceptions" class="here"`},
} {
var buf bytes.Buffer
if err := exceptionsPage.ExecuteTemplate(&buf, "fleet-nav", pageData{FleetTab: tc.tab}); err != nil {
t.Fatal(err)
}
html := buf.String()
if !strings.Contains(html, `class="tabs fleet-tabs"`) {
t.Fatalf("fleet-nav is not the tabs convention:\n%s", html)
}
if !strings.Contains(html, tc.here) || !strings.Contains(html, `class="ink"`) {
t.Errorf("tab %s: no underline on its own surface:\n%s", tc.tab, html)
}
}
}
// Every fleet surface renders THROUGH the shared nav.
func TestExceptionsPageCarriesTheFleetNav(t *testing.T) {
var buf bytes.Buffer
if err := exceptionsPage.ExecuteTemplate(&buf, "content", pageData{FleetTab: "errors"}); err != nil {
t.Fatal(err)
}
html := buf.String()
if !strings.Contains(html, `class="tabs fleet-tabs"`) {
t.Fatalf("no fleet tabs on the exceptions page:\n%.400s", html)
}
if strings.Contains(html, `seg-box" aria-label="fleet"`) {
t.Fatal("the fleet nav still renders as a seg-box")
}
}