v0.306.0: R-570 — the off-site note decides on its kind only; the pre-0.251.0 text fallback is deleted
gates / gates (push) Successful in 1m14s
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
This commit is contained in:
@@ -1055,13 +1055,7 @@ func (s *Server) backupsOffboxData(data map[string]interface{}, lang string) {
|
||||
}
|
||||
}
|
||||
|
||||
// offboxStaleWarningMarker is the substring the zero-toggled offbox run wrote into LastWarning before
|
||||
// v0.251.0, when the run started recording a KIND beside it (R-553). It is kept ONLY to read boxes
|
||||
// upgraded with that older text already persisted — see offboxWarningDisplay.
|
||||
const (
|
||||
offboxStaleWarningMarker = "nincs mentésre jelölt alkalmazás"
|
||||
offboxSelectionChangedKey = "offbox.selection_changed"
|
||||
)
|
||||
const offboxSelectionChangedKey = "offbox.selection_changed"
|
||||
|
||||
// offboxWarningDisplay picks what the Távoli mentés page shows for the persisted
|
||||
// Offbox.LastWarning. A zero-toggled run records "Sikeres — nincs mentésre jelölt
|
||||
@@ -1069,13 +1063,10 @@ const (
|
||||
// replace it with the honest "selection changed, the next run covers it" note.
|
||||
// Pure display logic: the persisted LastWarning is never touched, and every other
|
||||
// warning (quota, partial failure) passes through verbatim.
|
||||
// R-553 — the decision is made on the KIND the run recorded, not on the words of the sentence.
|
||||
// The one text test that remains runs ONLY when there is no kind, i.e. on a box whose last off-site
|
||||
// run happened before v0.251.0 and whose persisted warning therefore predates kinds.
|
||||
//
|
||||
// R-553 legacy: remove after every fleet box has completed one off-site run on ≥ 0.251.0 (row R-570).
|
||||
// Localisation slice 2 (R-557) must not translate the producer at backup/offbox.go until that row is
|
||||
// closed — translating it while this fallback is still needed would strand exactly those boxes.
|
||||
// R-553 — the decision is made on the KIND the run recorded, never on the words of the sentence.
|
||||
// R-570 (2026-10-10): the legacy text test for pre-0.251.0 warnings is removed — every fleet box has
|
||||
// completed an off-site run on ≥ 0.251.0, so every persisted warning carries its kind. Pinned by
|
||||
// TestR553_StaleNoteDecisionSurvivesWordingChange (no kind → verbatim).
|
||||
func (s *Server) offboxWarningDisplay(lastWarning, kind string, toggledCount int, lang string) string {
|
||||
if toggledCount < 1 {
|
||||
return lastWarning
|
||||
@@ -1083,9 +1074,6 @@ func (s *Server) offboxWarningDisplay(lastWarning, kind string, toggledCount int
|
||||
if kind == backup.OffboxWarnNoAppsSelected {
|
||||
return s.msgLang(lang, offboxSelectionChangedKey)
|
||||
}
|
||||
if kind == "" && strings.Contains(lastWarning, offboxStaleWarningMarker) {
|
||||
return s.msgLang(lang, offboxSelectionChangedKey)
|
||||
}
|
||||
return lastWarning
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/backup"
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/settings"
|
||||
)
|
||||
|
||||
@@ -13,8 +14,8 @@ import (
|
||||
// COMPANION red-proof (recorded in REPORT): make offboxWarningDisplay return lastWarning
|
||||
// unconditionally → TestOffboxWarningDisplay_Pick's 1-enabled case FAILS.
|
||||
//
|
||||
// R-553 (v0.251.0): these calls pass an EMPTY kind on purpose — they are now the LEGACY path, a box
|
||||
// whose last off-site run predates kinds. The kind path is TestR553_StaleNoteDecisionSurvivesWordingChange.
|
||||
// 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."
|
||||
|
||||
@@ -22,11 +23,11 @@ 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, "", 1, "hu"); got != selectionChanged {
|
||||
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, "", 0, "hu"); got != staleZeroToggleWarning {
|
||||
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)
|
||||
@@ -47,9 +48,9 @@ func TestOffboxWarningDisplay_RemotePageRender(t *testing.T) {
|
||||
data := appRowSplitData()
|
||||
data["Offbox"] = &settings.OffboxTarget{
|
||||
Enabled: true, Host: "nas.local", LastStatus: "ok", EscrowState: "escrowed",
|
||||
LastWarning: staleZeroToggleWarning,
|
||||
LastWarning: staleZeroToggleWarning, LastWarningKind: backup.OffboxWarnNoAppsSelected,
|
||||
}
|
||||
data["OffboxWarningDisplay"] = s.offboxWarningDisplay(staleZeroToggleWarning, "", 1, "hu")
|
||||
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")
|
||||
@@ -64,9 +65,9 @@ func TestOffboxWarningDisplay_RemotePageRender(t *testing.T) {
|
||||
data["OffboxToggledCount"] = 0
|
||||
data["Offbox"] = &settings.OffboxTarget{
|
||||
Enabled: true, Host: "nas.local", LastStatus: "ok", EscrowState: "escrowed",
|
||||
LastWarning: staleZeroToggleWarning,
|
||||
LastWarning: staleZeroToggleWarning, LastWarningKind: backup.OffboxWarnNoAppsSelected,
|
||||
}
|
||||
data["OffboxWarningDisplay"] = s.offboxWarningDisplay(staleZeroToggleWarning, "", 0, "hu")
|
||||
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")
|
||||
|
||||
@@ -35,10 +35,12 @@ func TestR553_StaleNoteDecisionSurvivesWordingChange(t *testing.T) {
|
||||
{"still nothing selected → the honest note stays", hu, backup.OffboxWarnNoAppsSelected, 0, hu},
|
||||
{"a quota note passes through", "A tároló a keret 84%-át használja (42/50 GB).", "", 3,
|
||||
"A tároló a keret 84%-át használja (42/50 GB)."},
|
||||
// LEGACY: a box upgraded to v0.251.0 still carries the OLD text with no kind until its next
|
||||
// off-site run rewrites it. Until then the text test is what it has.
|
||||
{"legacy persisted text, no kind", hu, "", 1, selectionChanged},
|
||||
{"legacy: any other text without a kind is shown verbatim", "Valami más történt.", "", 1, "Valami más történt."},
|
||||
// R-570 (2026-10-10): the legacy text test is GONE. Every fleet box ran off-site on ≥ 0.251.0 (read on
|
||||
// demo-hp, demo-felhom and Tester 1: last_success 2026-10-10 ~02:16Z, controller 0.304.0), so no box carries
|
||||
// the old text without a kind. The decision is the kind and ONLY the kind: the same words with no kind are
|
||||
// shown verbatim — the words never decide again (red against the fallback: it returned the replacement).
|
||||
{"no kind: the words alone decide nothing", hu, "", 1, hu},
|
||||
{"no kind: any other text is shown verbatim", "Valami más történt.", "", 1, "Valami más történt."},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if got := s.offboxWarningDisplay(c.warning, c.kind, c.toggled, "hu"); got != c.want {
|
||||
|
||||
Reference in New Issue
Block a user