package web import ( "os" "strings" "testing" "gitea.dooplex.hu/admin/felhom-controller/internal/backup" "gitea.dooplex.hu/admin/felhom-controller/internal/config" ) // R-487 — a removed app whose unit was kept renders on the backups page with the restore that brings // it back; a page without such rows carries none of it (the negative control). func TestR487_BackupsPageListsARemovedAppWithItsRestore(t *testing.T) { data := splitTestData() data["AppBackupRows"] = []AppBackupRow{ {StackName: "calibre-web", DisplayName: "Calibre-Web"}, {StackName: "gone-app", DisplayName: "Gone", Removed: true, RemovedUnitTime: "2026-09-13T00:30:00Z", StorageLabel: "HDD"}, } html := renderBackupPage(t, "backups_apps", data) for _, want := range []string{ `name="stack_name" value="gone-app"`, `name="snapshot_id" value="helyi"`, `action="/backup/restore"`, `class="layer-badge">Megtartva<`, } { if !strings.Contains(html, want) { t.Errorf("removed row must render %q", want) } } if strings.Count(html, `class="layer-badge">Megtartva<`) != 1 { t.Error("the kept badge must render for the removed row only") } control := renderBackupPage(t, "backups_apps", splitTestData()) if strings.Contains(control, "Megtartva") || strings.Contains(control, `value="helyi"`) { t.Error("negative control: a page with no removed app must not offer the restore") } } // R-487 — the restore picker lists removed apps in their own group. func TestR487_RestorePickerListsRemovedApps(t *testing.T) { data := splitTestData() data["RemovedApps"] = []backup.RemovedAppUnit{{StackName: "gone-app", DisplayName: "Gone"}} html := renderBackupPage(t, "backups_restore", data) if !strings.Contains(html, `