package web import ( "testing" "time" "gitea.dooplex.hu/admin/felhom-hub/internal/sysfacts" ) // R-840: the "Root files" cell — amber behind, red from the alarm's wait, amber on drift, unknown never coloured as a fact. func TestBundleCell(t *testing.T) { now := time.Date(2026, 10, 4, 20, 0, 0, 0, time.UTC) sys := func(rep string) sysfacts.System { return sysfacts.Parse(rep) } cur := sys(`{"system":{"config_bundle":{"version":"0.143.0","bundle_sha256":"new"}}}`) old := sys(`{"system":{"config_bundle":{"version":"none"}}}`) drift := sys(`{"system":{"config_bundle":{"version":"0.143.0","bundle_sha256":"new"},"facts":{"host":{"config_bundle":{"version":"0.143.0","drift":["/usr/local/sbin/felhom-pbs-apply"]}}}}}`) if c := bundleCell(cur, "0.143.0", "new", time.Time{}, 7*24*time.Hour, now); c.Class != "" || c.Text != "0.143.0" { t.Fatalf("current: %+v", c) } if c := bundleCell(old, "0.143.0", "new", now.Add(-time.Hour), 7*24*time.Hour, now); c.Class != "warn" || c.Text != "none" { t.Fatalf("behind 1 h: %+v", c) } if c := bundleCell(old, "0.143.0", "new", now.Add(-8*24*time.Hour), 7*24*time.Hour, now); c.Class != "bad" { t.Fatalf("behind 8 days: %+v", c) } if c := bundleCell(drift, "0.143.0", "new", time.Time{}, 7*24*time.Hour, now); c.Class != "warn" || c.Title == "" { t.Fatalf("drift: %+v", c) } if c := bundleCell(sys(`{}`), "0.143.0", "new", time.Time{}, 7*24*time.Hour, now); c.Text != "unknown" { t.Fatalf("no stanza: %+v", c) } }