Use JavaScript in tests opening modal dialogs

This way we reproduce the user experience in the tests, and we can make
sure modal dialogs open when we expect it.
This commit is contained in:
Javi Martín
2021-03-29 13:28:41 +02:00
parent fbc78984dc
commit b2bc4d19f5
38 changed files with 221 additions and 178 deletions

View File

@@ -66,25 +66,25 @@ describe "Admin geozones", :admin do
end
end
scenario "Delete geozone with no associated elements" do
scenario "Delete geozone with no associated elements", :js do
geozone = create(:geozone, name: "Delete me!")
visit admin_geozones_path
within("#geozone_#{geozone.id}") { click_link "Delete" }
within("#geozone_#{geozone.id}") { accept_confirm { click_link "Delete" } }
expect(page).to have_content "Geozone successfully deleted"
expect(page).not_to have_content("Delete me!")
expect(Geozone.where(id: geozone.id)).to be_empty
end
scenario "Delete geozone with associated element" do
scenario "Delete geozone with associated element", :js do
geozone = create(:geozone, name: "Delete me!")
create(:proposal, geozone: geozone)
visit admin_geozones_path
within("#geozone_#{geozone.id}") { click_link "Delete" }
within("#geozone_#{geozone.id}") { accept_confirm { click_link "Delete" } }
expect(page).to have_content "This geozone can't be deleted since there are elements attached to it"