Files
llmgw/internal/web/admin_guard_test.go
Ilker ManapandClaude Opus 5.5 11231d8c2b The portal in English and Turkish: a catalogue per language, a switcher at the foot of every page, landing.language, Turkish numbers and dates
Every template and handler message in internal/web goes through a JSON
catalogue under internal/web/locales/<code>/, with English as the fallback.
The language is the person's choice (a cookie set by /_lang/{code}), else
Accept-Language, else landing.language. Tests refuse a key some language
lacks, a translation with other arguments than English, and template text
left in English.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-05 00:12:53 +02:00

28 lines
1.0 KiB
Go

package web
import (
"net/http/httptest"
"strings"
"testing"
)
func TestTheGuardrailsPageShowsNamesAndCounts(t *testing.T) {
rec := httptest.NewRecorder()
render(rec, nil, "admin_guard", guardPageData{
Nav: Nav{Admin: true, Guard: true, Current: "guard"}, Window: "7d", Windows: []string{"24h", "7d"},
Policies: []string{"base", "finance"}, Default: []string{"base"},
Attachments: []guardAttachmentRow{{Scope: "project", Who: "Acme/fin/payroll", Policy: "finance"}},
Counts: []guardCountRow{{Where: "Acme/fin/payroll", Action: "blocked", Policy: "base,finance", Category: "iban", Count: 3}},
Events: []guardEventRow{{At: "2026-10-04 10:00:00", RequestID: "req_1", Action: "blocked", Category: "iban", Status: 400}},
})
body := rec.Body.String()
for _, want := range []string{"Acme/fin/payroll", "base,finance", "req_1", `href="/admin/guard" aria-current="page"`, `href="?window=24h"`} {
if !strings.Contains(body, want) {
t.Errorf("no %q", want)
}
}
if rec.Code != 200 {
t.Errorf("status %d: %s", rec.Code, body)
}
}