Files
felhom-controller/controller/internal/web/r562_locale_format_test.go
T
admin fd28d70bff v0.308.0: controller batch 2026-10-12 — clear-address warning (R-922), secret sweep over every page (R-255), read_failed (R-266), no NVMe heat band (R-333), share globe (R-577), Hungarian dates and numbers (R-562), lost-drive option pinned (R-521)
Operator rulings 2026-10-12, 09 §3 decisions 196, 204-207, 223, 227. MinAgent 0.131.0 unchanged.
R-255's sweep found one leak, fixed here: an optional-config secret_input was rendered into its
settings page; it is now revealed on demand. Hungarian parity fixtures re-captured once for R-562.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
2026-10-12 15:13:59 +02:00

73 lines
2.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package web
import (
"strings"
"testing"
"time"
)
// R-562 (`09` §3 decision 223): the dashboard prints dates and numbers the reader's way — Hungarian
// „2026. 09. 14. 05:12" and a decimal comma, English „2026-09-14 05:12" and a decimal point. Asserted
// on a RENDERED page in both languages (the backups page carries a date-time and a GB size), and on
// the func set the templates call.
//
// RED-PROOF (REPORT.md): make i18n.FormatDateTime / FormatDecimal ignore the language → the
// Hungarian half fails.
func TestR562_BackupsPageFormatsPerLanguage(t *testing.T) {
var c i18nCase
for _, x := range i18nCases() {
if x.name == "backups_full" {
c = x
}
}
if c.name == "" {
t.Fatal("parity case backups_full not found")
}
s := i18nTestServer(t)
hu := renderI18nCase(t, s, "hu", c)
en := renderI18nCase(t, s, "en", c)
for _, want := range []string{"2026. 09. 14. 05:12", "5,0 GB", "42,5 GB"} {
if !strings.Contains(hu, want) {
t.Errorf("hu: the page does not carry %q", want)
}
}
for _, bad := range []string{"2026-09-14 05:12", "5.0 GB"} {
if strings.Contains(hu, bad) {
t.Errorf("hu: the page still carries the ISO/point form %q", bad)
}
}
for _, want := range []string{"2026-09-14 05:12", "5.0 GB", "42.5 GB"} {
if !strings.Contains(en, want) {
t.Errorf("en: the page does not carry %q", want)
}
}
if strings.Contains(en, "2026. 09. 14.") || strings.Contains(en, "5,0 GB") {
t.Error("en: the page carries the Hungarian date or decimal comma")
}
}
func TestR562_FormatFuncsPerLanguage(t *testing.T) {
at := time.Date(2026, 10, 10, 13, 4, 0, 0, time.UTC) // 15:04 in Budapest (CEST)
hu, en := formatFuncs("hu"), formatFuncs("en")
check := func(name, got, want string) {
t.Helper()
if got != want {
t.Errorf("%s: got %q, want %q", name, got, want)
}
}
check("hu fmtTime", hu["fmtTime"].(func(time.Time) string)(at), "2026. 10. 10. 15:04")
check("en fmtTime", en["fmtTime"].(func(time.Time) string)(at), "2026-10-10 15:04")
check("hu fmtTimeStr", hu["fmtTimeStr"].(func(string) string)("2026-10-10T13:04:00Z"), "2026. 10. 10. 15:04")
check("en fmtTimeStr", en["fmtTimeStr"].(func(string) string)("2026-10-10T13:04:00Z"), "2026-10-10 15:04")
check("hu fmtGB", hu["fmtGB"].(func(float64) string)(42.5), "42,5 GB")
check("en fmtGB", en["fmtGB"].(func(float64) string)(42.5), "42.5 GB")
check("hu fmtBytes", hu["fmtBytes"].(func(int64) string)(1610612736), "1,5 GB")
check("en fmtBytes", en["fmtBytes"].(func(int64) string)(1610612736), "1.5 GB")
check("hu fmtLoad", hu["fmtLoad"].(func(float64) string)(0.25), "0,25")
check("en fmtLoad", en["fmtLoad"].(func(float64) string)(0.25), "0.25")
check("hu numText", hu["numText"].(func(string) string)("12.0 MB"), "12,0 MB")
check("en numText", en["numText"].(func(string) string)("12.0 MB"), "12.0 MB")
check("zero time", hu["fmtTime"].(func(time.Time) string)(time.Time{}), "–")
}