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.
This commit is contained in:
@@ -198,6 +198,8 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
|||||||
visit send(mappable_edit_path, id: mappable.id)
|
visit send(mappable_edit_path, id: mappable.id)
|
||||||
find(".map-location").click
|
find(".map-location").click
|
||||||
click_button "Save changes"
|
click_button "Save changes"
|
||||||
|
|
||||||
|
expect(page).not_to have_button "Save changes"
|
||||||
mappable.reload
|
mappable.reload
|
||||||
|
|
||||||
expect(page).to have_css(".map-location")
|
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)
|
visit send(mappable_edit_path, id: mappable.id)
|
||||||
fill_in "#{mappable_factory_name.camelize} title", with: "New title"
|
fill_in "#{mappable_factory_name.camelize} title", with: "New title"
|
||||||
click_button "Save changes"
|
click_button "Save changes"
|
||||||
|
|
||||||
|
expect(page).not_to have_button "Save changes"
|
||||||
mappable.reload
|
mappable.reload
|
||||||
|
|
||||||
expect(page).to have_css(".map-location")
|
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 "Remove map marker"
|
||||||
click_button "Save changes"
|
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
|
end
|
||||||
|
|
||||||
scenario "Can not display map on #{mappable_factory_name} edit when feature.map is disabled" do
|
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"
|
fill_in "#{mappable_factory_name.camelize} title", with: "New title"
|
||||||
click_button "Save changes"
|
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
|
end
|
||||||
|
|
||||||
scenario "No need to skip map on update" do
|
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 "Remove map marker"
|
||||||
click_button "Save changes"
|
click_button "Save changes"
|
||||||
|
|
||||||
|
expect(page).not_to have_button "Save changes"
|
||||||
expect(page).not_to have_content "Map location can't be blank"
|
expect(page).not_to have_content "Map location can't be blank"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user