All checks were successful
Deploy to K8s / deploy (push) Successful in 7s
Stand up the Go-native HTML frontend foundation: - base.tmpl layout + nav/footer partials (three-tier nav, active-link highlighting) - terminal-green-on-black theme extracted to static/css/app.css (served via embed.FS) - HTMLHandler with stub pages for all five routes; / redirects to /adults - NewRenderer parses per-page template sets at startup so parse failures abort boot - Smoke test: each route returns 200 text/html with exactly one class="active" link Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
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)
|
|
}
|
|
})
|
|
}
|
|
}
|