summaryrefslogtreecommitdiff
path: root/web/server_test.go
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-08-16 10:31:32 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-08-16 10:31:32 +0200
commit0c3507139795c3117bcdf82ca4b444e934bd3c74 (patch)
tree626f62c7dc15ded26bfeedbfa32a6638c07c3dfa /web/server_test.go
parentc720b572573774504cbbeda5ac1b5da2d1afeff6 (diff)
feat(web): improve ride detail climb profiles
Diffstat (limited to 'web/server_test.go')
-rw-r--r--web/server_test.go26
1 files changed, 22 insertions, 4 deletions
diff --git a/web/server_test.go b/web/server_test.go
index 9ecda80..6a0f9c3 100644
--- a/web/server_test.go
+++ b/web/server_test.go
@@ -131,7 +131,8 @@ func TestHandlerRendersRideDetailWithEmbeddedRoute(t *testing.T) {
assert.Contains(t, body, `id="ride-profile-chart"`)
assert.Contains(t, body, `id="ride-map"`)
assert.Contains(t, body, `class="ride-detail-grid"`)
- assert.Contains(t, body, `class="ride-detail-sidebar"`)
+ assert.Contains(t, body, `class="ride-detail-columns`)
+ assert.NotContains(t, body, "Climbs to match")
assert.Contains(t, body, `class="ride-detail-main"`)
assert.Contains(t, body, `<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" defer></script>`)
assert.Contains(t, body, `<script src="/static/ride-detail.js" defer></script>`)
@@ -152,6 +153,11 @@ 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")
@@ -181,6 +187,8 @@ func TestBuildRideProfileIncludesClimbsAndCrossings(t *testing.T) {
require.Len(t, profile.Climbs, 1)
assert.Equal(t, "Pas de Magnan", profile.Climbs[0].Name)
assert.Equal(t, 1.0, profile.Climbs[0].TopKm)
+ assert.Empty(t, profile.OfficialClimbs)
+ assert.Len(t, profile.UnmatchedClimbs, 1)
require.Len(t, profile.Crossings, 1)
assert.Equal(t, "Pas de Magnan", profile.Crossings[0].Name)
assert.Equal(t, 1.0, profile.Crossings[0].DistanceKm)
@@ -204,6 +212,8 @@ func TestBuildRideProfileIncludesOfficialClimbMatch(t *testing.T) {
assert.Equal(t, int64(42), profile.Climbs[0].OfficialClimbID)
assert.Equal(t, "Col de Test", profile.Climbs[0].OfficialName)
assert.Equal(t, "Col de Test", profile.Climbs[0].Name)
+ assert.Len(t, profile.OfficialClimbs, 1)
+ assert.Empty(t, profile.UnmatchedClimbs)
}
func TestBuildRideProfileUsesOfficialClimbBoundaries(t *testing.T) {
@@ -249,7 +259,7 @@ func TestHandlerCreatesOfficialClimbFromRoutePoints(t *testing.T) {
getResponse := httptest.NewRecorder()
server.Handler().ServeHTTP(getResponse, getRequest)
assert.Equal(t, http.StatusOK, getResponse.Code)
- assert.Contains(t, getResponse.Body.String(), "No official climb matched yet.")
+ assert.Contains(t, getResponse.Body.String(), "Waiting for an official climb match.")
assert.Contains(t, getResponse.Body.String(), "Select on profile")
assert.Contains(t, getResponse.Body.String(), "Select on map")
assert.Contains(t, getResponse.Body.String(), "Climb 1")
@@ -273,8 +283,16 @@ func TestHandlerCreatesOfficialClimbFromRoutePoints(t *testing.T) {
getRequest = httptest.NewRequest(http.MethodGet, fmt.Sprintf("/rides/%d?official_climb=created", item.ID), nil)
getResponse = httptest.NewRecorder()
server.Handler().ServeHTTP(getResponse, getRequest)
- assert.Contains(t, getResponse.Body.String(), "Official climb saved and matched to this ride by coordinates.")
- assert.Contains(t, getResponse.Body.String(), "Official climb matched: Col de Test")
+ body := getResponse.Body.String()
+ assert.Contains(t, body, "Official climb saved and matched to this ride by coordinates.")
+ assert.Contains(t, body, "data-official-climb-card")
+ assert.Contains(t, body, "Length")
+ assert.Contains(t, body, "Cotacol")
+ assert.Contains(t, body, "Avg slope")
+ assert.Contains(t, body, "data-official-profile")
+ assert.Contains(t, body, "0–3%")
+ assert.Contains(t, body, "12%+")
+ assert.NotContains(t, body, "Waiting for an official climb match.")
}
func TestHandlerRendersRideDetailWithoutRoute(t *testing.T) {