Skip to content

Commit

Permalink
Merge pull request #1987 from umap-project/fix-fromtozoom-tests
Browse files Browse the repository at this point in the history
try to fix toZoom and fromZoom randomly failing tests
  • Loading branch information
yohanboniface authored Jul 11, 2024
2 parents dc1a27b + ec7b546 commit bf08536
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
7 changes: 7 additions & 0 deletions umap/tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ def mock_osm_tiles(page):
page.route("*/**/osmfr/**", lambda route: route.fulfill())


@pytest.fixture
def page(context):
page = context.new_page()
page.on("console", lambda msg: print(msg.text) if msg.type != "warning" else None)
return page


@pytest.fixture
def login(context, settings, live_server):
def do_login(user):
Expand Down
13 changes: 9 additions & 4 deletions umap/tests/integration/test_datalayer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import re

import pytest
from django.core.files.base import ContentFile
Expand Down Expand Up @@ -41,13 +42,15 @@ def test_should_honour_fromZoom(live_server, map, datalayer, page):
markers = page.locator(".leaflet-marker-icon")
expect(markers).to_be_hidden()
page.goto(f"{live_server.url}{map.get_absolute_url()}#6/48.55/14.68")
page.wait_for_timeout(500)
expect(page).to_have_url(re.compile(r".*#6/48\..+/14\..+"))
expect(markers).to_be_visible()
page.get_by_label("Zoom out").click()
expect(markers).to_be_hidden()
page.get_by_label("Zoom in").click()
expect(page).to_have_url(re.compile(r".*#6/48\..+/14\..+"))
expect(markers).to_be_visible()
page.get_by_label("Zoom in").click()
expect(page).to_have_url(re.compile(r".*#7/48\..+/14\..+"))
expect(markers).to_be_visible()


Expand All @@ -57,15 +60,17 @@ def test_should_honour_toZoom(live_server, map, datalayer, page):
markers = page.locator(".leaflet-marker-icon")
expect(markers).to_be_hidden()
page.goto(f"{live_server.url}{map.get_absolute_url()}#6/48.55/14.68")
expect(page).to_have_url(re.compile(r".*#6/48\..+/14\..+"))
expect(markers).to_be_visible()
page.get_by_label("Zoom out").click()
expect(page).to_have_url(re.compile(r".*#5/48\..+/14\..+"))
expect(markers).to_be_visible()
page.get_by_label("Zoom in").click()
expect(page).to_have_url(re.compile(r".*#6/48\..+/14\..+"))
expect(markers).to_be_visible()
page.get_by_label("Zoom in").click()
# FIXME does not work (but works when using PWDEBUG=1), not sure why
# may be a race condition related to css transition
# expect(markers).to_be_hidden()
expect(page).to_have_url(re.compile(r".*#7/48\..+/14\..+"))
expect(markers).to_be_hidden()


def test_should_honour_color_variable(live_server, map, page):
Expand Down

0 comments on commit bf08536

Please sign in to comment.