Files
member-console/internal/server/operator_plan_ladder_edit_render_test.go
T
cgalo5758 9b96e9c9e9 Rework operator IA and unify UI vocabulary
- Restructure operator sidebar into a flat task list with indented
  children; fold plan topology into plan ladders
- Expand member catalog non-plan section to all published non-tier
  products; require recurring Stripe-mapped prices for purchase
- Add operator domains placements and terminal-claims ledger; redirect
  /domains to the FedWiki Sites Domains anchor
- Apply canonical vocabulary and chrome/form conventions; migrate seeded
  FedWiki Sites display name
2026-08-23 17:12:42 -05:00

50 lines
1.7 KiB
Go

package server_test
import (
"net/http/httptest"
"strings"
"testing"
"git.coopcloud.tech/wiki-cafe/member-console/internal/server"
)
// TestOperatorPlanLadderEditOmitsSortOrder renders the actual ladder edit
// template against the actual view model and asserts the raw "Sort order" field
// is gone: ladder display order is now adjusted via the move-left/move-right
// controls on the topology overview, never as an absolute integer on this form.
// Rendering the real template also guards the template/view-model contract —
// html/template field-reference errors are runtime, so a stray .Ladder.SortOrder
// reference would 500 here rather than slip past build.
func TestOperatorPlanLadderEditOmitsSortOrder(t *testing.T) {
h, err := server.NewOperatorPartialsHandler(server.OperatorPartialsConfig{Logger: discardLogger()})
if err != nil {
t.Fatalf("new operator handler: %v", err)
}
rec := httptest.NewRecorder()
h.Templates.Render(rec, "operator_plan_ladder_edit.html", server.PlanLadderEditData{
Ladder: server.PlanLadderViewModel{
PlanLadderID: "lad-1",
LadderKey: "hosting",
Name: "Hosting",
IsActive: true,
},
})
if rec.Code != 200 {
t.Fatalf("expected 200, got %d: %s", rec.Code, rec.Body.String())
}
body := rec.Body.String()
if strings.Contains(body, `name="sort_order"`) {
t.Error("edit form should no longer present a raw sort_order input")
}
// The form still binds the editable fields, and points operators at the
// topology overview for ordering.
if !strings.Contains(body, `name="name"`) {
t.Error("expected the display-name input to remain")
}
if !strings.Contains(body, "/operator/plan-ladders") {
t.Error("expected a pointer to the topology overview for reordering")
}
}