- Add shared ui_*.html parts (pageHeader, sectionHeader, statusBadge, emptyState) parsed into every template set - Add anatomy lint rules with a shrinking allowlist and screen-coverage check - Add make screens capture harness with contact sheets and baseline diff - Compose member and FedWiki regions server-side so pages arrive complete - Rebuild Domains and Integrations on the parts as pilots
91 lines
3.4 KiB
Go
91 lines
3.4 KiB
Go
package server
|
|
|
|
import (
|
|
"bytes"
|
|
"html/template"
|
|
"io/fs"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.coopcloud.tech/wiki-cafe/member-console/internal/embeds"
|
|
"git.coopcloud.tech/wiki-cafe/member-console/internal/web"
|
|
)
|
|
|
|
func renderOrganizationsPageBody(t *testing.T, data OrganizationsData) string {
|
|
t.Helper()
|
|
partialsSub, err := fs.Sub(embeds.Templates, "templates/partials")
|
|
if err != nil {
|
|
t.Fatalf("fs.Sub partials: %v", err)
|
|
}
|
|
tmpl := template.New("operator").Funcs(template.FuncMap{
|
|
"renderBody": func(string, any) (template.HTML, error) { return "", nil },
|
|
"routeURL": web.RouteURL,
|
|
"fieldErr": func(activeForm, expectedForm, activeScope, expectedScope string, errs web.FieldErrors, field string) string {
|
|
return ""
|
|
},
|
|
"stripeEntityURL": func(string, string) string { return "" },
|
|
})
|
|
tmpl, err = web.ParseUIPartials(template.Must(tmpl.ParseFS(partialsSub, "operator_*.html")))
|
|
if err != nil {
|
|
t.Fatalf("ParseFS: %v", err)
|
|
}
|
|
var buf bytes.Buffer
|
|
if err := tmpl.ExecuteTemplate(&buf, "operator_organizations.html", data); err != nil {
|
|
t.Fatalf("ExecuteTemplate: %v", err)
|
|
}
|
|
return buf.String()
|
|
}
|
|
|
|
// TestOrganizationsListShowsOwnerAndNeutralStatus covers UX-16
|
|
// (ux-honest-surfaces 5.5): every organization row must show its owner so
|
|
// no row reads as unowned, and the unread status column must not render as
|
|
// a colored state badge.
|
|
func TestOrganizationsListShowsOwnerAndNeutralStatus(t *testing.T) {
|
|
body := renderOrganizationsPageBody(t, OrganizationsData{
|
|
Organizations: []OrganizationViewModel{
|
|
{OrgID: "org-1", Name: "Acme Co-op", OrgType: "team", Status: "active", MemberCount: 3, OwnerName: "Jamie Rivera"},
|
|
},
|
|
})
|
|
|
|
if !strings.Contains(body, "Jamie Rivera") {
|
|
t.Errorf("expected the organization row to show its owner, got: %s", body)
|
|
}
|
|
if strings.Contains(body, `class="badge bg-success">active`) || strings.Contains(body, `class="badge bg-secondary">active`) {
|
|
t.Errorf("status must not render as a colored badge, got: %s", body)
|
|
}
|
|
}
|
|
|
|
// TestOrganizationsListRendersNoDerivedIdentifier covers entity-keys: no
|
|
// organization's derived identifier renders anywhere in the body. The
|
|
// column header itself is covered by the embeds vocabulary guard, which
|
|
// scans every template source for the retired word.
|
|
func TestOrganizationsListRendersNoDerivedIdentifier(t *testing.T) {
|
|
body := renderOrganizationsPageBody(t, OrganizationsData{
|
|
Organizations: []OrganizationViewModel{
|
|
{OrgID: "org-1", Name: "Acme Co-op", OrgType: "team", Status: "active", MemberCount: 3, OwnerName: "Jamie Rivera"},
|
|
},
|
|
})
|
|
|
|
if strings.Contains(body, "acme-co-op") {
|
|
t.Errorf("expected no derived organization identifier in the body, got: %s", body)
|
|
}
|
|
}
|
|
|
|
// TestOrganizationsListMarksSystemTenant covers UX-16: the reserved System
|
|
// organization must carry a visible synthetic marker and must not offer the
|
|
// ordinary Enrollment action other rows get.
|
|
func TestOrganizationsListMarksSystemTenant(t *testing.T) {
|
|
body := renderOrganizationsPageBody(t, OrganizationsData{
|
|
Organizations: []OrganizationViewModel{
|
|
{OrgID: "org-sys", Name: "System", OrgType: "system", Status: "active", OwnerName: "System", IsSystemOrg: true},
|
|
},
|
|
})
|
|
|
|
if !strings.Contains(body, "System tenant") {
|
|
t.Errorf("expected a visible system-tenant marker, got: %s", body)
|
|
}
|
|
if strings.Contains(body, "Enrollment") {
|
|
t.Errorf("the system tenant row must not offer the ordinary Enrollment action, got: %s", body)
|
|
}
|
|
}
|