From 5a033129618d3cf10576318c7e80dc5c4262d0f0 Mon Sep 17 00:00:00 2001 From: Adnaan Badr Date: Sat, 9 May 2026 09:54:43 +0000 Subject: [PATCH] test(live-preview): assert capabilities contains "change", not exact equality MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit livetemplate PR #395 (issue #252) extends the capabilities list with "progressive_enhancement", "validate", and "upload" — detected automatically based on controller methods and mountConfig. The TestWebSocketCapabilities equality assertion broke when run against that PR's core changes. Switch to a contains-style check: the test's intent is "this app's controller advertises change", not "this is the only capability the framework supports". The latter is brittle and breaks whenever the framework's auto-detected capability set grows. Co-Authored-By: Claude Opus 4.7 (1M context) --- live-preview/live_preview_test.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/live-preview/live_preview_test.go b/live-preview/live_preview_test.go index c3f73f0..74067f5 100644 --- a/live-preview/live_preview_test.go +++ b/live-preview/live_preview_test.go @@ -98,8 +98,11 @@ func dialWebSocket(t *testing.T, port int) *websocket.Conn { return conn } -// TestWebSocketCapabilities verifies the initial WebSocket render includes -// "change" in the capabilities metadata. +// TestWebSocketCapabilities verifies the initial WebSocket render advertises +// "change" in the capabilities metadata. Other capabilities (e.g., +// "progressive_enhancement", "validate", "upload") may also be present +// depending on controller methods and config (see livetemplate#252); the +// test asserts presence of "change" without requiring exact equality. func TestWebSocketCapabilities(t *testing.T) { port, _ := startServer(t) conn := dialWebSocket(t, port) @@ -128,8 +131,15 @@ func TestWebSocketCapabilities(t *testing.T) { t.Skip("capabilities not present in meta — requires livetemplate#253") } - if len(caps) != 1 || caps[0] != "change" { - t.Errorf("Expected capabilities=[\"change\"], got %v", caps) + hasChange := false + for _, c := range caps { + if c == "change" { + hasChange = true + break + } + } + if !hasChange { + t.Errorf("Expected capabilities to include \"change\", got %v", caps) } }