package brand import ( "bytes" "encoding/json" "net/http" "net/http/httptest" "os" "testing" "amadan.net/oficina/estilo.git/theme" ) // The icons' colours and the apps' accents are one ring: icons.json must // carry exactly the hues theme/apps.go does, app for app. func TestIconHuesAreTheThemeRing(t *testing.T) { raw, err := os.ReadFile("icons.json") if err != nil { t.Fatal(err) } var icons []struct { ID string `json:"id"` Hue *float64 `json:"hue"` } if err := json.Unmarshal(raw, &icons); err != nil { t.Fatal(err) } seen := map[string]bool{} for _, icon := range icons { seen[icon.ID] = true app, ok := theme.Lookup(icon.ID) switch { case !ok: t.Errorf("icons.json has %q, which is not on the theme ring", icon.ID) case icon.ID == "oficina": if icon.Hue != nil { t.Error("Oficina's mark is every hue, not one; its icons.json hue must be null") } case icon.Hue == nil || *icon.Hue != app.Hue: t.Errorf("%s: icons.json hue %v, theme ring %v", icon.ID, icon.Hue, app.Hue) } if SVG(icon.ID) == nil { t.Errorf("%s has no generated svg/", icon.ID) } } for _, app := range theme.Apps() { if !seen[app.Slug] { t.Errorf("%s is on the theme ring but has no icon", app.Slug) } } } func TestEveryAppHasAnIcon(t *testing.T) { for _, slug := range []string{"oficina", "docs", "sheets", "slides", "calendar", "calls", "memoria", "fichas", "mail", "files"} { body := SVG(slug) if !bytes.HasPrefix(bytes.TrimSpace(body), []byte("