package web import ( "path/filepath" "strings" "testing" "time" ) // ── R-550 — an interrupted restore is SHOWN on the restore page ───────────────────────────────── // // Chaos night round 10: a restore interrupted by a hard reset left the page blank. The record now // survives (internal/backup/restore_record.go); these drive the REAL page through ServeHTTP, so they // bite on the wiring — a record that exists but that no page renders is the inert-seam shape. const interruptedCardFragment = "Megszakadt vissza" // ASCII fragment of the card heading // RED-PROOF: drop `data["InterruptedRestores"]` from backupsRestoreHandler → the card never renders → // "the restore page does not show the interrupted restore". func TestR550_RestorePageShowsInterruptedRestore(t *testing.T) { s := newDashboardServer(t, time.Time{}) if s.backupMgr == nil { t.Fatal("fixture invalid: no backup manager, so nothing here measures the restore page") } s.backupMgr.SetRestoreRecordPath(filepath.Join(t.TempDir(), "restore-status.json")) s.backupMgr.BeginRestoreOp("restore", "gokapi") // the box stops here … if s.backupMgr.LoadRestoreRecord() == nil { // … and this is the next start t.Fatal("fixture invalid: the record did not convert to an interrupted restore") } rec := getPage(t, s, "/backups/restore") if rec.Code != 200 { t.Fatalf("GET /backups/restore = %d: %s", rec.Code, rec.Body.String()) } body := rec.Body.String() if !strings.Contains(body, interruptedCardFragment) || !strings.Contains(body, "megszakadt") { t.Fatalf("the restore page does not show the interrupted restore — the household is left not knowing, which is R-550") } if !strings.Contains(body, "gokapi") { t.Fatalf("the interrupted card does not name the app") } if strings.Contains(body, "zzzz-not-present") { t.Fatal("negative control matched — the fragment search is broken") } } // The other branch: a box with no interrupted restore shows no such card. func TestR550_NoInterruptedRestoreNoCard(t *testing.T) { s := newDashboardServer(t, time.Time{}) rec := getPage(t, s, "/backups/restore") if rec.Code != 200 { t.Fatalf("GET /backups/restore = %d", rec.Code) } if strings.Contains(rec.Body.String(), interruptedCardFragment) { t.Fatalf("a box with no interrupted restore shows the interrupted card") } }