From 4c224fccbc61378333f7931e61facaad30179c7f Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 16 Feb 2024 11:41:28 +0100 Subject: [PATCH] fix: send edit link was using old post method --- umap/static/umap/js/umap.js | 6 ++---- .../integration/test_anonymous_owned_map.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index 4d2b3707..4390b854 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -1129,7 +1129,7 @@ U.Map = L.Map.extend({ } }, - sendEditLink: function () { + sendEditLink: async function () { const input = this.ui._alert.querySelector('input') const email = input.value @@ -1137,9 +1137,7 @@ U.Map = L.Map.extend({ formData.append('email', email) const url = this.urls.get('map_send_edit_link', { map_id: this.options.umap_id }) - this.post(url, { - data: formData, - }) + await this.server.post(url, {}, formData) }, star: function () { diff --git a/umap/tests/integration/test_anonymous_owned_map.py b/umap/tests/integration/test_anonymous_owned_map.py index ca0c4b66..24cc46a7 100644 --- a/umap/tests/integration/test_anonymous_owned_map.py +++ b/umap/tests/integration/test_anonymous_owned_map.py @@ -150,3 +150,22 @@ def test_can_change_perms_after_create(tilelayer, live_server, page): ".datalayer-permissions select[name='edit_status'] option:checked" ) expect(option).to_have_text("Inherit") + + +def test_alert_message_after_create(tilelayer, live_server, page): + page.goto(f"{live_server.url}/en/map/new") + save = page.get_by_role("button", name="Save") + expect(save).to_be_visible() + alert = page.locator(".umap-alert") + expect(alert).to_be_hidden() + with page.expect_response(re.compile(r".*/map/create/")): + save.click() + expect(alert).to_be_visible() + expect( + alert.get_by_text( + "Your map has been created! As you are not logged in, here is your secret " + "link to edit the map, please keep it safe:" + ) + ).to_be_visible() + expect(alert.get_by_role("button", name="Copy")).to_be_visible() + expect(alert.get_by_role("button", name="Send me the link")).to_be_visible()