9e5b88146e
gates / gates (push) Successful in 1m14s
Fleet condition read on each box's settings.json 2026-10-10 (offbox.last_success ~02:16Z on 0.304.0). Red-proof: the new no-kind row of TestR553_StaleNoteDecisionSurvivesWordingChange failed against the fallback. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
82 lines
3.9 KiB
Go
82 lines
3.9 KiB
Go
package web
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"gitea.dooplex.hu/admin/felhom-controller/internal/backup"
|
|
"gitea.dooplex.hu/admin/felhom-controller/internal/settings"
|
|
)
|
|
|
|
// v0.126.0 Part E — the stale zero-toggle warning line tells the truth. Display-pick only:
|
|
// the persisted LastWarning is never mutated; the page swaps the stale "nincs mentésre
|
|
// jelölt alkalmazás" run-result for the selection-changed note once ≥1 app is toggled.
|
|
// COMPANION red-proof (recorded in REPORT): make offboxWarningDisplay return lastWarning
|
|
// unconditionally → TestOffboxWarningDisplay_Pick's 1-enabled case FAILS.
|
|
//
|
|
// R-570 (2026-10-10): the legacy no-kind path is gone; these calls carry the kind the run records. The
|
|
// no-kind contract (verbatim) is pinned by TestR553_StaleNoteDecisionSurvivesWordingChange.
|
|
|
|
const staleZeroToggleWarning = "Sikeres — nincs mentésre jelölt alkalmazás volt a futáskor."
|
|
|
|
func TestOffboxWarningDisplay_Pick(t *testing.T) {
|
|
s, _, _ := newOffboxWebServer(t)
|
|
selectionChanged := s.msgLang("hu", offboxSelectionChangedKey)
|
|
// warning + ≥1 enabled → the replacement line
|
|
if got := s.offboxWarningDisplay(staleZeroToggleWarning, backup.OffboxWarnNoAppsSelected, 1, "hu"); got != selectionChanged {
|
|
t.Errorf("stale warning + 1 toggled: got %q, want the selection-changed line", got)
|
|
}
|
|
// warning + 0 enabled → the original line, verbatim (the v0.123.0 honesty stays)
|
|
if got := s.offboxWarningDisplay(staleZeroToggleWarning, backup.OffboxWarnNoAppsSelected, 0, "hu"); got != staleZeroToggleWarning {
|
|
t.Errorf("stale warning + 0 toggled: got %q, want the original warning unchanged", got)
|
|
}
|
|
// any OTHER warning passes through regardless of toggles (quota, partial failure)
|
|
quota := "A tároló a keret 84%-át használja (42/50 GB)."
|
|
if got := s.offboxWarningDisplay(quota, "", 3, "hu"); got != quota {
|
|
t.Errorf("non-stale warning must pass through verbatim, got %q", got)
|
|
}
|
|
// no warning → no line
|
|
if got := s.offboxWarningDisplay("", "", 2, "hu"); got != "" {
|
|
t.Errorf("empty warning must stay empty, got %q", got)
|
|
}
|
|
}
|
|
|
|
func TestOffboxWarningDisplay_RemotePageRender(t *testing.T) {
|
|
s, _, _ := newOffboxWebServer(t)
|
|
selectionChanged := s.msgLang("hu", offboxSelectionChangedKey)
|
|
// ≥1 toggled: the page shows the replacement, NOT the stale line.
|
|
data := appRowSplitData()
|
|
data["Offbox"] = &settings.OffboxTarget{
|
|
Enabled: true, Host: "nas.local", LastStatus: "ok", EscrowState: "escrowed",
|
|
LastWarning: staleZeroToggleWarning, LastWarningKind: backup.OffboxWarnNoAppsSelected,
|
|
}
|
|
data["OffboxWarningDisplay"] = s.offboxWarningDisplay(staleZeroToggleWarning, backup.OffboxWarnNoAppsSelected, 1, "hu")
|
|
html := renderBackupPage(t, "backups_remote", data)
|
|
if !strings.Contains(html, selectionChanged) {
|
|
t.Error("selection-changed note missing with 1 app toggled")
|
|
}
|
|
if strings.Contains(html, staleZeroToggleWarning) {
|
|
t.Error("the stale zero-toggle line still renders alongside the replacement")
|
|
}
|
|
|
|
// 0 toggled: the original warning + the v0.123.0 zero-toggle hint, unchanged.
|
|
data = appRowSplitData()
|
|
data["OffboxApps"] = []OffboxAppRow{{Name: "calibre-web", DisplayName: "Calibre-Web", Slug: "calibre-web", Enabled: false}}
|
|
data["OffboxToggledCount"] = 0
|
|
data["Offbox"] = &settings.OffboxTarget{
|
|
Enabled: true, Host: "nas.local", LastStatus: "ok", EscrowState: "escrowed",
|
|
LastWarning: staleZeroToggleWarning, LastWarningKind: backup.OffboxWarnNoAppsSelected,
|
|
}
|
|
data["OffboxWarningDisplay"] = s.offboxWarningDisplay(staleZeroToggleWarning, backup.OffboxWarnNoAppsSelected, 0, "hu")
|
|
html = renderBackupPage(t, "backups_remote", data)
|
|
if !strings.Contains(html, staleZeroToggleWarning) {
|
|
t.Error("0 toggled: the original run warning must render unchanged")
|
|
}
|
|
if strings.Contains(html, selectionChanged) {
|
|
t.Error("0 toggled: the selection-changed note must NOT render")
|
|
}
|
|
if !strings.Contains(html, "Nincs távoli mentésre jelölt alkalmazás — jelölj ki legalább egyet.") {
|
|
t.Error("0 toggled: the v0.123.0 hint must stay")
|
|
}
|
|
}
|