package web_test import ( "fmt" "fuj-management/go/internal/web" "net/http" "net/http/httptest" "strings" "testing" ) func TestHTMLHandlerSmoke(t *testing.T) { renderer, err := web.NewRenderer() if err != nil { t.Fatalf("NewRenderer: %v", err) } b := web.BuildInfo{Version: "v0", Commit: "abc1234", BuildDate: "2026-01-01"} h := web.NewHTMLHandler(renderer, b) cases := []struct { path string handler http.HandlerFunc }{ {"/adults", h.ServeAdults}, {"/juniors", h.ServeJuniors}, {"/payments", h.ServePayments}, {"/sync-bank", h.ServeSync}, {"/flush-cache", h.ServeFlushCache}, } for _, tc := range cases { t.Run(tc.path, func(t *testing.T) { req := httptest.NewRequest(http.MethodGet, tc.path, nil) w := httptest.NewRecorder() tc.handler(w, req) if w.Code != http.StatusOK { t.Errorf("status = %d, want 200", w.Code) } if ct := w.Header().Get("Content-Type"); !strings.HasPrefix(ct, "text/html") { t.Errorf("Content-Type = %q, want text/html", ct) } body := w.Body.String() if n := strings.Count(body, `class="active"`); n != 1 { t.Errorf(`class="active" count = %d, want 1`, n) } want := fmt.Sprintf(`href="%s" class="active"`, tc.path) if !strings.Contains(body, want) { t.Errorf("missing active link %q in body", want) } }) } }