Files
felhom-controller/controller/internal/web/r574_debug_copy_test.go
T
admin 391967bcf1 R-574: handler_debug.go literals classified; the 38 page-copy ones move to the bundle
39 Hungarian literals: 38 are debug-page copy (every writeDebugJSON message/error, rendered
into the result line by debug.html, plus the pre-0.83 agent notice rendered in the log
viewer) -> 30 debug.api.* keys (hu byte-equal, parity gate green; en added). One is PAYLOAD:
the 'Teszt esemény' text sent to the hub as the test event's message stays a literal. The
diagnostic dump carries no Hungarian. TestR574_DebugPageCopyFollowsTheLanguage pins hu bytes
and en rendering.

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

70 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 (
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"gitea.dooplex.hu/admin/felhom-controller/internal/agentapi"
)
// R-574 — handler_debug.go's literals, classified once: 38 are PAGE COPY (every writeDebugJSON
// message/error, which debug.html prints into the result line, plus the pre-0.83 agent `notice`,
// which it prints into the log viewer) and were moved to the bundle (debug.api.*); ONE is PAYLOAD —
// the `Teszt esemény: %s (%s)` text handed to PushTestEventSync, which travels to the hub as the
// test event's own message — and stays a literal on purpose. The diagnostic dump carries no
// Hungarian.
//
// The consequence pinned here: the Hungarian page is byte-for-byte what it was (the parity gate
// proves the bundle text; this proves the handler reads it), and an English page is English.
// RED-PROOF (REPORT): put either producer back to its literal and the English rows fail.
func TestR574_DebugPageCopyFollowsTheLanguage(t *testing.T) {
type debugResp struct {
OK bool `json:"ok"`
Error string `json:"error"`
Data struct {
Notice string `json:"notice"`
} `json:"data"`
}
run := func(t *testing.T, lang string, call func(s *Server, w http.ResponseWriter, r *http.Request)) debugResp {
t.Helper()
s := testServer(t)
if s.settings == nil {
t.Fatal("testServer has no settings — the language cannot be set")
}
s.settings.SetConfigLanguage(lang)
w := httptest.NewRecorder()
call(s, w, httptest.NewRequest(http.MethodPost, "/api/debug/x", nil))
var resp debugResp
if err := json.Unmarshal(w.Body.Bytes(), &resp); err != nil {
t.Fatalf("decode: %v (%s)", err, w.Body.String())
}
return resp
}
dbDump := func(s *Server, w http.ResponseWriter, r *http.Request) {
s.backupMgr = nil
s.debugTriggerDBDump(w, r)
}
notice := func(s *Server, w http.ResponseWriter, r *http.Request) {
s.agentLogsFn = func(context.Context) (agentapi.AgentLogsResponse, error) {
return agentapi.AgentLogsResponse{}, &agentapi.StatusError{Path: "/debug/logs", Code: http.StatusNotFound}
}
s.debugAgentLogs(w, r)
}
if got := run(t, "hu", dbDump).Error; got != "Backup manager nincs konfigurálva" {
t.Errorf("hu error = %q — the Hungarian bytes moved", got)
}
if got := run(t, "en", dbDump).Error; got != "Backup manager is not configured" {
t.Errorf("en error = %q — the handler does not read the bundle", got)
}
if got := run(t, "hu", notice).Data.Notice; got != "Az ügynök naplónézete az ügynök következő frissítése után érhető el." {
t.Errorf("hu notice = %q — the Hungarian bytes moved", got)
}
if got := run(t, "en", notice).Data.Notice; got != "The agent’s log view becomes available after the agent’s next update." {
t.Errorf("en notice = %q — the handler does not read the bundle", got)
}
}