package web import ( "bytes" "io" "log" "path/filepath" "testing" "time" "gitea.dooplex.hu/admin/felhom-hub/internal/store" ) // Catches template SYNTAX errors (template.Must in New panics) and that the floor fields render on the // two edited pages. Field-level execution errors surface as a non-nil ExecuteTemplate error. func TestTemplates_FloorRender(t *testing.T) { st, err := store.New(filepath.Join(t.TempDir(), "t.db"), log.New(io.Discard, "", 0)) if err != nil { t.Fatalf("store.New: %v", err) } t.Cleanup(func() { st.Close() }) s := New(st, "", "", "test", time.Hour, log.New(io.Discard, "", 0)) // template.Must runs here // configs.html — the list page data shape used by handleConfigList. cfgData := struct { Customers []customerListEntry GlobalFloor string ActiveNav string Flash string CSRFToken string CSRFField string }{ Customers: []customerListEntry{{ CustomerID: "c", EffectiveFloor: "0.87.0", FloorOverride: "0.87.0", BelowFloor: true, ControllerVersion: "0.86.0", HasConfig: true, }}, GlobalFloor: "0.86.0", ActiveNav: "configs", } var buf bytes.Buffer if err := s.templates.ExecuteTemplate(&buf, "configs.html", cfgData); err != nil { t.Fatalf("render configs.html: %v", err) } if !bytes.Contains(buf.Bytes(), []byte("0.87.0")) || !bytes.Contains(buf.Bytes(), []byte("global floor")) { t.Errorf("configs.html missing floor content") } }