Skip choice for unique postcode matches

This commit is contained in:
Edward Betts 2026-08-15 12:09:24 +01:00
parent 71e1b57164
commit 7da704d837
4 changed files with 36 additions and 1 deletions

View file

@ -191,6 +191,31 @@ def test_coordinate_url_and_search_input(chromium_browser: Any, flask_url: str)
page.close()
def test_single_postcode_match_opens_directly(chromium_browser: Any, flask_url: str) -> None:
"""A unique UK postcode result skips the location-choice panel."""
page = chromium_browser.new_page(viewport={"width": 1280, "height": 800})
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": [],
}))
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).to_have_url(re.compile(r"\?lat=51.501&lon=-0.142$"))
playwright_api.expect(page.locator("#stop-count")).to_have_text("0 found")
playwright_api.expect(page.locator("#geocode-panel")).to_be_hidden()
page.close()
def test_mobile_layout_opens_results_sheet(chromium_browser: Any, flask_url: str) -> None:
"""The finder exposes its search panel as an open mobile bottom sheet."""
page = chromium_browser.new_page(viewport={"width": 390, "height": 844})