diff options
Diffstat (limited to 'web/server_test.go')
| -rw-r--r-- | web/server_test.go | 26 |
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) { |