chore: fix tests

This commit is contained in:
David Larlet 2024-06-13 14:13:42 -04:00
parent 802d5d9d6c
commit b863beaec9
No known key found for this signature in database
GPG key ID: 3E2953A359E7E7BD
5 changed files with 8 additions and 8 deletions

View file

@ -36,7 +36,7 @@
<p>{% translate "You can also receive that URL by email:" %}</p> <p>{% translate "You can also receive that URL by email:" %}</p>
<form> <form>
<fieldset role="group"> <fieldset role="group">
<input type="email" name="email" required> <input type="email" name="email" placeholder="{% translate "Email" %}" required>
<input type="submit" value="{% translate "Send me the link" %}" class="umap-action"> <input type="submit" value="{% translate "Send me the link" %}" class="umap-action">
</fieldset> </fieldset>
</form> </form>

View file

@ -9,7 +9,7 @@ from playwright.sync_api import expect
@pytest.fixture(scope="session") @pytest.fixture(scope="session")
def browser_context_args(browser_context_args): def browser_context_args(browser_context_args):
return {**browser_context_args, "locale": "en-GB"} return {**browser_context_args, "locale": "en-GB", "timezone_id": "Europe/Paris"}
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)

View file

@ -164,7 +164,7 @@ def test_alert_message_after_create(
page.goto(f"{live_server.url}/en/map/new") page.goto(f"{live_server.url}/en/map/new")
save = page.get_by_role("button", name="Save") save = page.get_by_role("button", name="Save")
expect(save).to_be_visible() expect(save).to_be_visible()
alert = page.locator("#umap-alert-container") alert = page.locator('umap-alert-creation div[role="dialog"]')
expect(alert).to_be_hidden() expect(alert).to_be_hidden()
with page.expect_response(re.compile(r".*/map/create/")): with page.expect_response(re.compile(r".*/map/create/")):
save.click() save.click()
@ -194,13 +194,13 @@ def test_alert_message_after_create(
def test_email_sending_error_are_catched(tilelayer, page, live_server): def test_email_sending_error_are_catched(tilelayer, page, live_server):
page.goto(f"{live_server.url}/en/map/new") page.goto(f"{live_server.url}/en/map/new")
alert = page.locator("#umap-alert-container") alert = page.locator('umap-alert-creation div[role="dialog"]')
with page.expect_response(re.compile(r".*/map/create/")): with page.expect_response(re.compile(r".*/map/create/")):
page.get_by_role("button", name="Save").click() page.get_by_role("button", name="Save").click()
alert.get_by_placeholder("Email").fill("foo@bar.com") alert.get_by_placeholder("Email").fill("foo@bar.com")
with patch("umap.views.send_mail", side_effect=SMTPException) as patched: with patch("umap.views.send_mail", side_effect=SMTPException) as patched:
with page.expect_response(re.compile("/en/map/.*/send-edit-link/")): with page.expect_response(re.compile("/en/map/.*/send-edit-link/")):
alert.get_by_role("button", name="Send me the link").click() alert.get_by_role("input", name="Send me the link").click()
assert patched.called assert patched.called
expect(alert.get_by_text("Can't send email to foo@bar.com")).to_be_visible() expect(alert.get_by_text("Can't send email to foo@bar.com")).to_be_visible()
@ -214,7 +214,7 @@ def test_alert_message_after_create_show_link_even_without_mail(
page.goto(f"{live_server.url}/en/map/new") page.goto(f"{live_server.url}/en/map/new")
with page.expect_response(re.compile(r".*/map/create/")): with page.expect_response(re.compile(r".*/map/create/")):
page.get_by_role("button", name="Save").click() page.get_by_role("button", name="Save").click()
alert = page.locator("#umap-alert-container") alert = page.locator('umap-alert-creation div[role="dialog"]')
expect(alert).to_be_visible() expect(alert).to_be_visible()
expect( expect(
alert.get_by_text( alert.get_by_text(

View file

@ -266,7 +266,7 @@ def test_facets_search_are_persistent_when_closing_panel(live_server, page, map)
# Close panel # Close panel
expect(panel.locator("summary")).to_have_attribute("data-badge", " ") expect(panel.locator("summary")).to_have_attribute("data-badge", " ")
expect(page.locator(".umap-control-browse")).to_have_attribute("data-badge", " ") expect(page.locator(".umap-control-browse")).to_have_attribute("data-badge", " ")
page.get_by_role("listitem", name="Close").click() panel.get_by_role("button", name="Close").click()
page.get_by_role("button", name="See layers").click() page.get_by_role("button", name="See layers").click()
expect(panel.get_by_label("Min")).to_have_value("13") expect(panel.get_by_label("Min")).to_have_value("13")
expect(panel.get_by_label("Min")).to_have_attribute("data-modified", "true") expect(panel.get_by_label("Min")).to_have_attribute("data-modified", "true")

View file

@ -448,4 +448,4 @@ def test_import_csv_without_valid_latlon_headers(tilelayer, live_server, page):
# FIXME do not create a layer # FIXME do not create a layer
expect(layers).to_have_count(1) expect(layers).to_have_count(1)
expect(markers).to_have_count(0) expect(markers).to_have_count(0)
expect(page.locator("#umap-alert-container")).to_be_visible() expect(page.locator('umap-alert div[data-level="error"]')).to_be_visible()