Files
felhom-controller/controller/internal/web/backups_remote_hubenabled_test.go
T

66 lines
2.7 KiB
Go

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)
}
}