fix: delete map from dashboard confirm was not active
This commit is contained in:
parent
ef06ca46b3
commit
92cc014c2e
2 changed files with 10 additions and 2 deletions
|
@ -123,7 +123,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<script>
|
<script>
|
||||||
!(function () {
|
!(function () {
|
||||||
for (const deleteForm of document.querySelectorAll('table.maps form.map-delete')) {
|
for (const deleteForm of document.querySelectorAll('form.map-delete')) {
|
||||||
deleteForm.addEventListener('submit', (event) => {
|
deleteForm.addEventListener('submit', (event) => {
|
||||||
if (!confirm(L._('Are you sure you want to delete this map?'))) {
|
if (!confirm(L._('Are you sure you want to delete this map?'))) {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
|
@ -7,11 +7,19 @@ pytestmark = pytest.mark.django_db
|
||||||
|
|
||||||
|
|
||||||
def test_owner_can_delete_map_after_confirmation(map, live_server, login):
|
def test_owner_can_delete_map_after_confirmation(map, live_server, login):
|
||||||
|
dialog_shown = False
|
||||||
|
|
||||||
|
def handle_dialog(dialog):
|
||||||
|
dialog.accept()
|
||||||
|
nonlocal dialog_shown
|
||||||
|
dialog_shown = True
|
||||||
|
|
||||||
page = login(map.owner)
|
page = login(map.owner)
|
||||||
page.goto(f"{live_server.url}/en/me")
|
page.goto(f"{live_server.url}/en/me")
|
||||||
delete_button = page.get_by_title("Delete")
|
delete_button = page.get_by_title("Delete")
|
||||||
expect(delete_button).to_be_visible()
|
expect(delete_button).to_be_visible()
|
||||||
page.on("dialog", lambda dialog: dialog.accept())
|
page.on("dialog", handle_dialog)
|
||||||
with page.expect_navigation():
|
with page.expect_navigation():
|
||||||
delete_button.click()
|
delete_button.click()
|
||||||
|
assert dialog_shown
|
||||||
assert Map.objects.all().count() == 0
|
assert Map.objects.all().count() == 0
|
||||||
|
|
Loading…
Reference in a new issue