// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial // SPDX-FileCopyrightText: 2025-2026 Christian Galo package web import ( "log/slog" "net/http/httptest" "os" "strings" "testing" "git.coopcloud.tech/wiki-cafe/member-console/internal/server" ) // Scenario: the operator shell's landing branch references // operator_lookup_result.html, and html/template's escape analysis demands // every referenced template exist in the set even on branches this page // never takes — a handler that parses only operator.html + its own body // partial 500s on EVERY render ("no such template"). This regressed live // on /operator/fedwiki-sites (discourse-integration findings #8); guard // the template-set composition without needing a DB or auth session. func TestOperatorSitesPageRenders(t *testing.T) { h, err := NewFedWikiOperatorHandler(FedWikiOperatorHandlerConfig{ Logger: slog.Default(), TemplatesFS: os.DirFS("../templates"), }) if err != nil { t.Fatalf("construct handler: %v", err) } page := server.OperatorPageData{ IAPosition: "integration:fedwiki-sites", ActiveCapability: "fedwiki-sites", BodyTemplate: "fedwiki_operator_sites.html", BodyData: FedWikiSitesData{ Configured: true, Sites: []FedWikiSiteViewModel{{ ID: "site-1", Domain: "wiki.example.test", URL: "https://wiki.example.test", OwnerOrgName: "Test Org", CreatedAt: "Jan 2, 2026", Status: "active", }}, }, } rec := httptest.NewRecorder() h.Templates.Render(rec, "operator.html", page) if rec.Code != 200 { t.Fatalf("render = %d (template-set regression?), body: %s", rec.Code, rec.Body.String()) } out := rec.Body.String() for _, want := range []string{ "wiki.example.test", // a site row `

FedWiki sites

`, // titled by pageHeader `