Files
paliad/internal/branding/firm_test.go
m 495e519475 feat(t-paliad-065): firm-agnostic branding via single FIRM_NAME constant
Paliad ships firm-agnostic per CLAUDE.md ("survives firm renames") but
landing copy, email templates, page titles, and form placeholders still
hard-coded "Hogan Lovells" / "HL Patents". Replaces every user-facing
firm reference with a single source of truth: internal/branding.Name on
the server and frontend/src/branding.ts in the bundle, both reading
FIRM_NAME at startup/build time and defaulting to "HLC".

Server: branding package + boot log; auth, invite, admin_users error
strings; courts/offices/models comments; mail templates thread
{{.Firm}} via injected payload default. Files handler keeps the
upstream "HL Patents Style.dotm" path (must match mWorkRepo's blob
name) but renders the user-visible DownloadName from branding.Name.

Frontend: branding.ts read via Bun.build define so process.env.FIRM_NAME
is statically substituted into client bundles (no runtime process
reference); index/login/downloads/kostenrechner/Sidebar/ProjectFormFields
and every i18n.ts string templated against ${FIRM}.

ALLOWED_EMAIL_DOMAINS whitelist intentionally untouched — email
domains and display name rotate independently.

Verified: go build/vet/test clean; bun run build clean; FIRM_NAME=Acme
override produces "Acme" in HTML and JS bundles end-to-end.
2026-04-28 22:44:06 +02:00

33 lines
738 B
Go

package branding
import (
"testing"
)
func TestResolveName(t *testing.T) {
cases := []struct {
name string
env string
envSet bool
expected string
}{
{"unset → default HLC", "", false, "HLC"},
{"empty string → default HLC", "", true, "HLC"},
{"whitespace only → default HLC", " ", true, "HLC"},
{"override applied", "Acme Patents", true, "Acme Patents"},
{"override trimmed", " Acme ", true, "Acme"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
if tc.envSet {
t.Setenv("FIRM_NAME", tc.env)
} else {
t.Setenv("FIRM_NAME", "")
}
if got := resolveName(); got != tc.expected {
t.Errorf("resolveName() = %q, want %q", got, tc.expected)
}
})
}
}