From 9dd4a9ac8f359f8d25b1c89fccc9e098f7b124ca Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Sun, 16 Aug 2026 10:44:21 +0200 Subject: refactor(web): split official climb profile script --- web/server_test.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'web/server_test.go') diff --git a/web/server_test.go b/web/server_test.go index 6a0f9c3..d04f1d6 100644 --- a/web/server_test.go +++ b/web/server_test.go @@ -135,6 +135,7 @@ func TestHandlerRendersRideDetailWithEmbeddedRoute(t *testing.T) { assert.NotContains(t, body, "Climbs to match") assert.Contains(t, body, `class="ride-detail-main"`) assert.Contains(t, body, ``) + assert.Contains(t, body, ``) assert.Contains(t, body, ``) assert.NotContains(t, body, "pointermove") @@ -153,17 +154,25 @@ func TestHandlerRendersRideDetailWithEmbeddedRoute(t *testing.T) { assert.Contains(t, script, "zoomToClimb") assert.Contains(t, script, "Cotacol") assert.Contains(t, script, "cotacolForClimb") - assert.Contains(t, script, "officialProfileSections") - assert.Contains(t, script, "profileStepSizesM = [100, 200, 500, 1000]") - assert.Contains(t, script, "displayStepForLength") - assert.Contains(t, script, "profileBandForSlope") - assert.Contains(t, script, "section.slopePercent.toFixed(1)") assert.Contains(t, script, "const labelY = plot.top - 6") assert.Contains(t, body, "leaflet@1.9.4/dist/leaflet.js") 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]`) + + profileStaticRequest := httptest.NewRequest(http.MethodGet, "/static/official-climb-profile.js", nil) + profileStaticResponse := httptest.NewRecorder() + server.Handler().ServeHTTP(profileStaticResponse, profileStaticRequest) + + profileScript := profileStaticResponse.Body.String() + assert.Equal(t, http.StatusOK, profileStaticResponse.Code) + assert.Equal(t, "text/javascript; charset=utf-8", profileStaticResponse.Header().Get("Content-Type")) + assert.Contains(t, profileScript, "officialProfileSections") + assert.Contains(t, profileScript, "profileStepSizesM = [100, 200, 500, 1000]") + assert.Contains(t, profileScript, "displayStepForLength") + assert.Contains(t, profileScript, "profileBandForSlope") + assert.Contains(t, profileScript, "section.slopePercent.toFixed(1)") } func TestBuildRideProfileIncludesClimbsAndCrossings(t *testing.T) { -- cgit v1.2.3