7df061c00f
- settings.html: Aktív/Inaktív rows -> run-blue check / neutral gray (Inaktív no longer red), update states -> run/crit/progress with sprite check/x/spinner, pencil + cancel buttons -> icons, storage badges -> tags, host-disk bar + JS drive capBar -> meters (usageColorClass -> nominal/warn/crit), state-text-* consumers on the new suffixes incl. JS-built class names. - debug.html, app_info.html, storage_init/attach.html, logs.html: emoji -> sprite icons or plain text in templates AND JS strings. - catchall.html (standalone, no sprite): v2 token sweep of its inline style, status emoji -> inline SVGs; a stopped app renders neutral, not red. - login.html: two-tone H1 (last word blue-bright). - setup_hub_versions.html: stale var(--border,#30363d) fallback -> v2. - Test Group F grep gate: all 34 banned patterns at ZERO across internal/web + internal/setup; Scenario E test now asserts the '--bg-0: #0A1220' token literal.
59 lines
2.0 KiB
Go
59 lines
2.0 KiB
Go
package web
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestServeFontHandler asserts the vendored woff2 files are embedded and served
|
|
// with the right content type + immutable caching (design system v2, D0 Part 1.1).
|
|
func TestServeFontHandler(t *testing.T) {
|
|
s := &Server{}
|
|
for _, name := range []string{"pjs-latin.woff2", "pjs-latin-ext.woff2", "jbm-latin.woff2", "jbm-latin-ext.woff2"} {
|
|
rec := httptest.NewRecorder()
|
|
req := httptest.NewRequest("GET", "/static/fonts/"+name, nil)
|
|
s.serveFontHandler(rec, req, name)
|
|
if rec.Code != 200 {
|
|
t.Errorf("%s: status = %d, want 200", name, rec.Code)
|
|
}
|
|
if ct := rec.Header().Get("Content-Type"); ct != "font/woff2" {
|
|
t.Errorf("%s: Content-Type = %q, want font/woff2", name, ct)
|
|
}
|
|
if cc := rec.Header().Get("Cache-Control"); !strings.Contains(cc, "immutable") {
|
|
t.Errorf("%s: Cache-Control = %q, want immutable", name, cc)
|
|
}
|
|
// woff2 magic number: "wOF2"
|
|
if body := rec.Body.Bytes(); len(body) < 4 || string(body[:4]) != "wOF2" {
|
|
t.Errorf("%s: body is not a woff2 file (len=%d)", name, len(body))
|
|
}
|
|
}
|
|
|
|
// Unknown font → 404, and path traversal is neutralized by filepath.Base.
|
|
rec := httptest.NewRecorder()
|
|
s.serveFontHandler(rec, httptest.NewRequest("GET", "/static/fonts/nope.woff2", nil), "nope.woff2")
|
|
if rec.Code != 404 {
|
|
t.Errorf("unknown font: status = %d, want 404", rec.Code)
|
|
}
|
|
}
|
|
|
|
// TestStyleCSSAccessor asserts the exported accessor returns the embedded
|
|
// stylesheet (consumed by the setup wizard) with the vendored font-face rules
|
|
// and no CDN import.
|
|
func TestStyleCSSAccessor(t *testing.T) {
|
|
data, err := StyleCSS()
|
|
if err != nil {
|
|
t.Fatalf("StyleCSS() error: %v", err)
|
|
}
|
|
css := string(data)
|
|
if len(css) < 10000 {
|
|
t.Fatalf("StyleCSS() length = %d, want > 10000", len(css))
|
|
}
|
|
if !strings.Contains(css, "@font-face") || !strings.Contains(css, "/static/fonts/pjs-latin.woff2") {
|
|
t.Error("StyleCSS() missing vendored @font-face rules")
|
|
}
|
|
if strings.Contains(css, "fonts.googleapis"+".com") {
|
|
t.Error("StyleCSS() still references the Google Fonts CDN")
|
|
}
|
|
}
|