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

36 lines
1.5 KiB
Go

package web
import (
"strings"
"testing"
"gitea.dooplex.hu/admin/felhom-controller/internal/stacks"
)
// Decision 28 on the page: an unhealthy stop offers START (its way back) and no Mentések; the badge
// does not say "restore needed". Render test per branch.
func TestD28_UnhealthyStopPageOffersStart(t *testing.T) {
st := ubStack(nil, map[string]string{"web": "nginx:1.27"}, "2026-07-18")
st.Name = "bookstack"
st.State = stacks.StateStopped
st.HoldReason = "STOPPED BY THE BOX"
st.HoldKind = "unhealthy_stop"
h := renderBackupPage(t, "stacks", ubStacksData(st))
if !strings.Contains(h, `data-unhealthy-stop="true"`) || !strings.Contains(h, `stackAction(event, 'bookstack', 'start')`) {
t.Fatal("the unhealthy stop must show its sentence and a Start button")
}
if strings.Contains(h, `data-held="true"`) || strings.Contains(h, "visszaállítás szükséges") {
t.Fatal("an unhealthy stop is not a restore case")
}
a := renderBackupPage(t, "app_info", appInfoData(st))
if !strings.Contains(a, `data-unhealthy-stop="true"`) || strings.Contains(a, `data-held="true"`) {
t.Fatal("app page: wrong branch for an unhealthy stop")
}
// positive control: an UPDATE hold keeps the restore branch
st.HoldKind = "update_failed"
h2 := renderBackupPage(t, "stacks", ubStacksData(st))
if !strings.Contains(h2, `data-held="true"`) || strings.Contains(h2, `stackAction(event, 'bookstack', 'start')`) {
t.Fatal("an update hold must keep its restore branch and offer no Start")
}
}