Zoom to searches before stops load
This commit is contained in:
parent
ae5ad9fabc
commit
7823349f8f
2 changed files with 24 additions and 5 deletions
|
|
@ -197,6 +197,7 @@ def test_coordinate_url_and_search_input(chromium_browser: Any, flask_url: str)
|
|||
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})
|
||||
pending_stop_requests: list[Any] = []
|
||||
page.route("**/api/search?*", lambda route: route.fulfill(json={
|
||||
"kind": "geocode",
|
||||
"query": "SW1A 1AA",
|
||||
|
|
@ -205,15 +206,19 @@ def test_single_postcode_match_opens_directly(chromium_browser: Any, flask_url:
|
|||
"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.route("**/api/stops?*", lambda route: pending_stop_requests.append(route))
|
||||
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(".leaflet-interactive")).to_have_count(1)
|
||||
assert page.evaluate("map.getZoom()") == 16
|
||||
assert len(pending_stop_requests) == 1
|
||||
pending_stop_requests[0].fulfill(json={
|
||||
"kind": "location",
|
||||
"location": {"lat": 51.501, "lon": -0.142, "label": "Westminster, London"},
|
||||
"stops": [],
|
||||
})
|
||||
playwright_api.expect(page.locator("#stop-count")).to_have_text("0 found")
|
||||
playwright_api.expect(page.locator("#geocode-panel")).to_be_hidden()
|
||||
page.close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue