v0.161.0 — R-70: truthful hub-managed offsite empty state (kiépítve/automatikus banner replaces igényelhető + nincs beállítva in the pre-apply window)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NKSN3gSg4TKVBBqkwW2djR
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// R-70 (v0.161.0) — the hub-enabled empty state tells the truth. Render test per branch of the
|
||||
// gate (the v0.70.1 hub seam-wiring lesson: template gates need render tests, handler tests prove
|
||||
// nothing about reachability). Three branches:
|
||||
// 1. hub-enabled + no offbox → the "kiépítve — automatikus, folyamatban" banner (card + empty
|
||||
// state), the "igényelhető"/"Még nincs beállítva" copy GONE (a provisioned service is not
|
||||
// orderable), the own-NAS setup button untouched;
|
||||
// 2. not hub-enabled + no offbox → today's copy byte-for-byte;
|
||||
// 3. offbox configured → no banner (the configured status block renders instead).
|
||||
|
||||
const hubBannerText = "Felhom offsite tárhely kiépítve — a beállítás automatikus, folyamatban."
|
||||
|
||||
func remoteEmptyStateData(hubEnabled bool) map[string]interface{} {
|
||||
d := splitTestData()
|
||||
d["Offbox"] = nil
|
||||
d["OffboxConfigured"] = false
|
||||
d["OffboxToggledCount"] = 0
|
||||
d["OffsiteHubEnabled"] = hubEnabled
|
||||
return d
|
||||
}
|
||||
|
||||
func TestBackupsRemote_HubEnabledEmptyState_ShowsProvisioningBanner(t *testing.T) {
|
||||
html := renderBackupPage(t, "backups_remote", remoteEmptyStateData(true))
|
||||
if !strings.Contains(html, hubBannerText) {
|
||||
t.Fatalf("hub-enabled empty state must show the provisioning banner:\n%s", html)
|
||||
}
|
||||
if !strings.Contains(html, "jelezd az üzemeltetőnek") {
|
||||
t.Fatal("the banner must carry the one-day escalation pointer")
|
||||
}
|
||||
if strings.Contains(html, "igényelhető szolgáltatás") {
|
||||
t.Fatal("'igényelhető' must be GONE when the service is already provisioned (it would be a lie)")
|
||||
}
|
||||
if strings.Contains(html, "Még nincs beállítva távoli mentési cél") {
|
||||
t.Fatal("the bare empty state must be replaced by the truthful banner (DIAG-f10)")
|
||||
}
|
||||
// the own-NAS path stays untouched
|
||||
if !strings.Contains(html, "Távoli mentési cél beállítása") {
|
||||
t.Fatal("the own-NAS setup button must remain")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBackupsRemote_NotHubEnabledEmptyState_KeepsTodaysCopy(t *testing.T) {
|
||||
html := renderBackupPage(t, "backups_remote", remoteEmptyStateData(false))
|
||||
if !strings.Contains(html, "igényelhető szolgáltatás") || !strings.Contains(html, "Még nincs beállítva távoli mentési cél") {
|
||||
t.Fatalf("non-hub-enabled empty state must keep today's copy:\n%s", html)
|
||||
}
|
||||
if strings.Contains(html, hubBannerText) {
|
||||
t.Fatal("the provisioning banner must not render without a hub-managed offsite")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBackupsRemote_OffboxConfigured_NoBanner(t *testing.T) {
|
||||
d := splitTestData() // configured target, escrowed
|
||||
d["OffsiteHubEnabled"] = true
|
||||
html := renderBackupPage(t, "backups_remote", d)
|
||||
if strings.Contains(html, hubBannerText) {
|
||||
t.Fatalf("configured target must render the status block, never the provisioning banner:\n%s", html)
|
||||
}
|
||||
}
|
||||
@@ -671,6 +671,11 @@ func (s *Server) backupsOffboxData(data map[string]interface{}) {
|
||||
offboxTgt := s.settings.GetOffboxTarget()
|
||||
data["Offbox"] = offboxTgt
|
||||
data["OffboxConfigured"] = s.backupMgr != nil && s.backupMgr.OffboxConfigured()
|
||||
// R-70 (v0.161.0): hub-managed offsite is enabled in controller.yaml — the descriptor exists
|
||||
// and the apply-bridge WILL configure the target automatically. The empty state must say so
|
||||
// instead of the bare "nincs beállítva" (a box stuck pre-apply looked identical to one that
|
||||
// was never provisioned — DIAG-f10: that ambiguity hid a burned credential for 2 days).
|
||||
data["OffsiteHubEnabled"] = s.cfg != nil && s.cfg.Offsite.Enabled
|
||||
offboxApps := s.buildOffboxApps()
|
||||
data["OffboxApps"] = offboxApps
|
||||
// Zero-toggle hint (take-two obs.): configured + escrowed but no app selected — nothing is
|
||||
|
||||
@@ -15,7 +15,11 @@
|
||||
<!-- Felhom-offsite status card (v0.124.0, decision 2): three honest states from LOCAL data only —
|
||||
display + opt-in pointers, NEVER a state change (no form, no button in this card). State 3
|
||||
(applied + apps toggled) is the existing status block below; the card renders nothing then. -->
|
||||
{{if not .OffboxConfigured}}
|
||||
{{if and (not .OffboxConfigured) .OffsiteHubEnabled}}
|
||||
<!-- R-70 (v0.161.0): hub-managed offsite is provisioned for this box — "igényelhető" would be a
|
||||
lie (it is already ordered) and the bare empty state hid the pre-apply window (DIAG-f10). -->
|
||||
<div class="alert alert-info" style="margin-bottom:1rem" id="felhom-offsite-card">Felhom offsite tárhely kiépítve — a beállítás automatikus, folyamatban. Ha egy napon belül nem áll be, jelezd az üzemeltetőnek.</div>
|
||||
{{else if not .OffboxConfigured}}
|
||||
<div class="alert alert-info" style="margin-bottom:1rem" id="felhom-offsite-card">Felhom offsite tárhely — igényelhető szolgáltatás. Titkosított, házon kívüli másolat a mentéseidről. Érdeklődj az üzemeltetőnél.</div>
|
||||
{{else if eq .OffboxToggledCount 0}}
|
||||
<div class="alert alert-info" style="margin-bottom:1rem" id="felhom-offsite-card">Aktív — nincs kijelölt alkalmazás</div>
|
||||
@@ -157,8 +161,12 @@
|
||||
{{else}}<p class="form-hint">Nincs telepített alkalmazás.</p>{{end}}
|
||||
{{end}}
|
||||
{{else}}
|
||||
{{if .OffsiteHubEnabled}}
|
||||
<p class="form-hint">Felhom offsite tárhely kiépítve — a beállítás automatikus, folyamatban. Ha egy napon belül nem áll be, jelezd az üzemeltetőnek.</p>
|
||||
{{else}}
|
||||
<p class="form-hint">Még nincs beállítva távoli mentési cél.</p>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
<details style="margin-top:1rem">
|
||||
<summary class="btn btn-xs btn-primary" style="cursor:pointer;display:inline-block">Távoli mentési cél beállítása</summary>
|
||||
|
||||
Reference in New Issue
Block a user