Files
member-console/internal/server/operator_plan_ladder_edit_render_test.go
T
cgalo5758 23ecf2ba87 Implement drag-and-drop plan ladder reordering
- Add SortableJS drag-to-reorder for ladder columns on the topology
  overview page
- Remove the manual "Sort order" input from the ladder edit form
- Add SetPlanLadderSortOrder SQL query and remove sort_order from
  UpdatePlanLadder
- Update templates, CSS, specs, and tests to support the new flow
2026-06-30 02:23:45 -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-topology") {
t.Error("expected a pointer to the topology overview for reordering")
}
}