Fit mobile searches above results sheet

This commit is contained in:
Edward Betts 2026-08-15 13:09:33 +01:00
parent 98b5951cbb
commit ae5ad9fabc
2 changed files with 71 additions and 11 deletions

View file

@ -278,3 +278,40 @@ def test_mobile_selected_stop_stays_above_detail_sheet(
}""")
assert 0 < position["markerY"] < position["visibleBottom"]
page.close()
def test_mobile_postcode_is_fitted_above_results_sheet(
chromium_browser: Any, flask_url: str
) -> None:
"""A unique postcode marker is fitted inside the unobscured mobile map area."""
page = chromium_browser.new_page(viewport={"width": 390, "height": 844})
page.route("**/api/search?*", lambda route: route.fulfill(json={
"kind": "geocode", "query": "SW1A 1AA",
"locations": [{
"lat": 51.501, "lon": -0.142, "label": "Westminster, London",
"type": "postcode",
}],
}))
page.route("**/api/stops?*", lambda route: route.fulfill(json={
"kind": "location",
"location": {"lat": 51.501, "lon": -0.142, "label": "Westminster, London"},
"stops": [{
"type": "node", "id": 999, "lat": 51.502, "lon": -0.141,
"name": "Nearby Stop", "atco_code": "490000001", "indicator": None,
"bearing": "N", "transport_type": "Bus stop",
"tags": {"highway": "bus_stop"},
}],
}))
page.goto(flask_url, wait_until="networkidle")
page.get_by_label("Location or ATCO code").fill("SW1A 1AA")
page.get_by_role("button", name="Search").click()
playwright_api.expect(page.locator("#stop-count")).to_have_text("1 found")
page.wait_for_timeout(400)
position = page.evaluate("""() => {
const point = map.latLngToContainerPoint(searchMarker.getLatLng());
const mapRect = document.getElementById('map').getBoundingClientRect();
const sheetRect = document.getElementById('sidebar').getBoundingClientRect();
return {markerY: point.y, visibleBottom: sheetRect.top - mapRect.top};
}""")
assert 0 < position["markerY"] < position["visibleBottom"]
page.close()