Skip to content

Commit 2e9559d

Browse files
tuxpiperclaude
andauthored
Fix: Stop hardcoding exact Nominatim geocoding coordinates in e2e tests (#1619)
verify_the_map_coordinates and fill_required_form_fields both asserted an exact lat/lng string for a "Nairobi County" geocoder search. That value is returned by the live Nominatim/OSM API, not fixed test data, and its centroid for large administrative areas drifts as OSM boundary data gets edited over time (confirmed by querying the API directly: it currently returns -1.302398 for this query, not the hardcoded -1.3026148499999999). Assert the result lands within Nairobi instead of matching an exact string, so the test survives normal upstream geocoding data changes. Claude-Session: https://claude.ai/code/session_0142M19Se37Y1pxoNy8HvTKV Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
1 parent ad1e1b6 commit 2e9559d

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

e2e-testing/cypress/functions/GeneralSettingsFunctions.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,15 @@ class GeneralSettingsFunctions {
7373
.eq(0)
7474
.click();
7575
cy.wait(1000);
76-
cy.get(GeneralSettingsLocator.defaultLatitudeField).should('have.value', '-1.3026148499999999');
77-
cy.get(GeneralSettingsLocator.defaultLongitudeField).should('have.value', '36.82884201813725');
76+
// The geocoder (Nominatim/OSM) can return a slightly different centroid for a large
77+
// administrative area like "Nairobi County" as the underlying OSM boundary data is
78+
// edited over time, so assert the result lands within Nairobi rather than an exact value.
79+
cy.get(GeneralSettingsLocator.defaultLatitudeField).should(($el) => {
80+
expect(parseFloat($el.val())).to.be.closeTo(-1.3, 0.15);
81+
});
82+
cy.get(GeneralSettingsLocator.defaultLongitudeField).should(($el) => {
83+
expect(parseFloat($el.val())).to.be.closeTo(36.83, 0.15);
84+
});
7885
}
7986

8087
steps_to_generate_new_api_key() {

e2e-testing/cypress/functions/PostsFunctions/PostFunctions.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ class PostFunctions {
3131

3232
//type in nairobi county in full. this gets one result and picks it automatically, populating lat and long fields
3333
cy.get(PostLocators.locationSearchField).type('nairobi county');
34-
//verify values in lat and long fields
35-
cy.get(PostLocators.locationLatField).should('have.value', '-1.3026148499999999');
36-
cy.get(PostLocators.locationLongField).should('have.value', '36.82884201813725');
34+
//verify values in lat and long fields land within Nairobi. Not an exact match because the
35+
//geocoder (Nominatim/OSM) can return a slightly different centroid over time as the
36+
//underlying OSM boundary data is edited.
37+
cy.get(PostLocators.locationLatField).should(($el) => {
38+
expect(parseFloat($el.val())).to.be.closeTo(-1.3, 0.15);
39+
});
40+
cy.get(PostLocators.locationLongField).should(($el) => {
41+
expect(parseFloat($el.val())).to.be.closeTo(36.83, 0.15);
42+
});
3743

3844
// click on date field to open pop up
3945
// cy.get(PostLocators.dateField).click(); //the first click opens the date picker

0 commit comments

Comments
 (0)