Files
member-console/internal/server/operator_enrollment_revoke_render_test.go
T
cgalo5758 88db730fcc Add dual licensing and SPDX headers
Introduce a commercial license option alongside AGPL-3.0-only, require a
CLA for contributors, and document the terms in COMMERCIAL.md and
NOTICE. Add a script to stamp SPDX headers on Go files and apply it
across the tree.
2026-09-06 02:29:42 -05:00

34 lines
1.2 KiB
Go

// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Commercial
// SPDX-FileCopyrightText: 2025-2026 Christian Galo
package server
import (
"strings"
"testing"
)
// TestOrgEnrollmentRevokeConfirm_NamesTargetOrFallsBack covers the
// empty-ProductName confirm body (hardening-polish): a live grant whose
// product lookup produced no name must fall back to a whole phrase, never
// render "Revoke for this organization" with a dangling gap.
func TestOrgEnrollmentRevokeConfirm_NamesTargetOrFallsBack(t *testing.T) {
data := onePoolFixture()
data.Grants = []GrantViewModel{
{GrantID: "g-named", ProductName: "Standard Plan", GrantReason: "purchase", DeliveryState: "live"},
{GrantID: "g-unnamed", ProductName: "", GrantReason: "purchase", DeliveryState: "live"},
}
body := renderOrgEnrollment(t, data)
if !strings.Contains(body, "Revoke Standard Plan for this organization?") {
t.Errorf("named grant should interpolate the product name into the confirm body")
}
if !strings.Contains(body, "Revoke this grant for this organization?") {
t.Errorf("unnamed grant should fall back to the generic confirm phrase")
}
if strings.Contains(body, "Revoke for this organization") {
t.Errorf("confirm body rendered the dangling empty-name phrase")
}
}