- Add deployment-name branding to titles, mastheads, and OG tags - Share one grant delivery-state query with lineage across grants surfaces - Show pool status/usage, org owners, and config readiness - Make billing views projection-aware with recency and sync vocabulary - Guard FedWiki creation without domains and render route-aware 404s
60 lines
2.2 KiB
Go
60 lines
2.2 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 renderPersonDetailBody(t *testing.T, data PersonDetailData) 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 = tmpl.ParseFS(partialsSub, "operator_*.html")
|
|
if err != nil {
|
|
t.Fatalf("ParseFS: %v", err)
|
|
}
|
|
var buf bytes.Buffer
|
|
if err := tmpl.ExecuteTemplate(&buf, "operator_person_detail.html", data); err != nil {
|
|
t.Fatalf("ExecuteTemplate: %v", err)
|
|
}
|
|
return buf.String()
|
|
}
|
|
|
|
// TestPersonDetailDropsConstantActiveBadgeAndCaptionsRole covers UX-16
|
|
// (ux-honest-surfaces 5.5): the person page must not badge account-enablement
|
|
// knowledge the console does not evaluate (persons.status is written once at
|
|
// creation and never updated -- see internal/identity/queries/persons.sql),
|
|
// and the membership role badge must be captioned as an organizational fact
|
|
// rather than left to imply console authorization.
|
|
func TestPersonDetailDropsConstantActiveBadgeAndCaptionsRole(t *testing.T) {
|
|
body := renderPersonDetailBody(t, PersonDetailData{
|
|
Person: PersonViewModel{PersonID: "p-1", DisplayName: "Jamie Rivera", Email: "jamie@example.com", Status: "active"},
|
|
Memberships: []PersonMembershipViewModel{
|
|
{OrgID: "org-1", OrgName: "Acme Co-op", OrgSlug: "acme", RoleName: "owner", JoinedAt: "Jan 2, 2026"},
|
|
},
|
|
})
|
|
|
|
if strings.Contains(body, `class="badge bg-success">active`) {
|
|
t.Errorf("person page must not badge the constant persons.status column, got: %s", body)
|
|
}
|
|
if !strings.Contains(body, "not a console permission") {
|
|
t.Errorf("expected the role badge to be captioned as an organizational fact, got: %s", body)
|
|
}
|
|
}
|