From a39201e40828e5acda800dec962ceddce402a94e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Wed, 12 Mar 2025 21:26:39 +0100 Subject: [PATCH] Add missing expectations in mappable tests After clicking the "Save changes" button, we were sometimes checking expectations that were already true before clicking the button, so it was possible that the request generated by that button didn't finish before the test did. So now we're checking that the button is no longer present, which is only true after the request has finished. --- spec/shared/system/mappable.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/spec/shared/system/mappable.rb b/spec/shared/system/mappable.rb index d687d5768..9412652e3 100644 --- a/spec/shared/system/mappable.rb +++ b/spec/shared/system/mappable.rb @@ -198,6 +198,8 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, visit send(mappable_edit_path, id: mappable.id) find(".map-location").click click_button "Save changes" + + expect(page).not_to have_button "Save changes" mappable.reload expect(page).to have_css(".map-location") @@ -211,6 +213,8 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, visit send(mappable_edit_path, id: mappable.id) fill_in "#{mappable_factory_name.camelize} title", with: "New title" click_button "Save changes" + + expect(page).not_to have_button "Save changes" mappable.reload expect(page).to have_css(".map-location") @@ -225,7 +229,8 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, click_button "Remove map marker" click_button "Save changes" - expect(page).not_to have_css(".map-location") + expect(page).not_to have_button "Save changes" + expect(page).not_to have_css ".map-location" end scenario "Can not display map on #{mappable_factory_name} edit when feature.map is disabled" do @@ -236,7 +241,8 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, fill_in "#{mappable_factory_name.camelize} title", with: "New title" click_button "Save changes" - expect(page).not_to have_css(".map-location") + expect(page).not_to have_button "Save changes" + expect(page).not_to have_css ".map-location" end scenario "No need to skip map on update" do @@ -246,6 +252,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, click_button "Remove map marker" click_button "Save changes" + expect(page).not_to have_button "Save changes" expect(page).not_to have_content "Map location can't be blank" end end