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>
28 lines
1.0 KiB
Go
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)
|
|
}
|
|
}
|