package web import ( "strings" "testing" "gitea.dooplex.hu/admin/felhom-controller/internal/stacks" ) // R-1007 (decision 236) — the household sees the LOST files only (name and date taken), until it dismisses the note; // repaired previews never make a note. RED-PROOF: drop `|| rec.Dismissed` in lostFilesNote → the dismissed case // still shows → fails. RED-PROOF: drop the `.LostFiles` card from app_info.html → the render case fails. func TestLostFilesNote_OnlyTheLostOnesUntilDismissed(t *testing.T) { rec := &stacks.AfterUncleanBootRecord{BootAt: "2026-10-14T12:07:26Z", Found: 81, Repaired: 81, Lost: []stacks.LostFile{{Name: "IMG_0042.jpg", Taken: "2026-10-14 10:41"}}} lost, at := lostFilesNote(true, &stacks.AppConfig{AfterUncleanBoot: rec}) if len(lost) != 1 || lost[0].Name != "IMG_0042.jpg" || at != "2026-10-14 14:07" { t.Fatalf("lost=%v at=%q", lost, at) } repairedOnly := &stacks.AfterUncleanBootRecord{BootAt: rec.BootAt, Found: 81, Repaired: 81} if l, _ := lostFilesNote(true, &stacks.AppConfig{AfterUncleanBoot: repairedOnly}); len(l) != 0 { t.Fatal("repaired previews made a note") } dismissed := *rec dismissed.Dismissed = true if l, _ := lostFilesNote(true, &stacks.AppConfig{AfterUncleanBoot: &dismissed}); len(l) != 0 { t.Fatal("a dismissed note is still shown") } if l, _ := lostFilesNote(false, &stacks.AppConfig{AfterUncleanBoot: rec}); len(l) != 0 { t.Fatal("a removed app shows a note") } page := renderAppInfoWith(t, map[string]interface{}{"LostFiles": lost, "LostBootAt": at}) for _, want := range []string{`id="lost-files-card"`, "IMG_0042.jpg", "2026-10-14 10:41", "2026-10-14 14:07", "/apps/gapp/lost-files/dismiss", "toltsd fel", "function appPress"} { if !strings.Contains(asciiFold(page), asciiFold(want)) { t.Fatalf("the card lacks %q", want) } } if plain := renderAppInfoWith(t, nil); strings.Contains(plain, `id="lost-files-card"`) { t.Fatal("a card with nothing lost") } } // asciiFold drops the Hungarian accents so the test searches ASCII fragments (the project's rule for Hungarian text). func asciiFold(s string) string { return strings.NewReplacer("á", "a", "é", "e", "í", "i", "ó", "o", "ö", "o", "ő", "o", "ú", "u", "ü", "u", "ű", "u").Replace(s) }