From 991ab2f179b2d84e8b0ce6d0634b4033f20e4b86 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Tue, 11 Aug 2026 22:19:22 +0200 Subject: refactor(web): extract ride detail script --- web/server_test.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'web/server_test.go') diff --git a/web/server_test.go b/web/server_test.go index 8e4c568..23270ed 100644 --- a/web/server_test.go +++ b/web/server_test.go @@ -161,12 +161,23 @@ func TestHandlerRendersRideDetailWithEmbeddedRoute(t *testing.T) { assert.Contains(t, body, `id="ride-profile"`) assert.Contains(t, body, `id="ride-profile-chart"`) assert.Contains(t, body, `id="ride-map"`) - assert.Contains(t, body, "pointermove") - assert.Contains(t, body, "circleMarker") - assert.Contains(t, body, "crossing.passElevationM") - assert.Contains(t, body, "const labelY = plot.top - 6") + assert.Contains(t, body, ``) + assert.Contains(t, body, ``) + assert.NotContains(t, body, "pointermove") + + staticRequest := httptest.NewRequest(http.MethodGet, "/static/ride-detail.js", nil) + staticResponse := httptest.NewRecorder() + server.Handler().ServeHTTP(staticResponse, staticRequest) + + script := staticResponse.Body.String() + assert.Equal(t, http.StatusOK, staticResponse.Code) + assert.Equal(t, "text/javascript; charset=utf-8", staticResponse.Header().Get("Content-Type")) + assert.Contains(t, script, "pointermove") + assert.Contains(t, script, "circleMarker") + assert.Contains(t, script, "crossing.passElevationM") + assert.Contains(t, script, "const labelY = plot.top - 6") assert.Contains(t, body, "leaflet@1.9.4/dist/leaflet.js") - assert.Contains(t, body, "tile.openstreetmap.org/{z}/{x}/{y}.png") + assert.Contains(t, script, "tile.openstreetmap.org/{z}/{x}/{y}.png") assert.Contains(t, body, `"type":"FeatureCollection"`) assert.Contains(t, body, `"type":"LineString"`) assert.Contains(t, body, `"coordinates":[[5,43]`) -- cgit v1.2.3