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

@@ -772,33 +772,31 @@ describe "Debates" do
end
end
scenario "Mark/Unmark a debate as featured", :admin do
scenario "Mark/Unmark a debate as featured", :admin, :js do
debate = create(:debate)
visit debates_path
within("#debates") do
expect(page).not_to have_content "Featured"
expect(page).not_to have_content "FEATURED"
end
click_link debate.title
click_link "Featured"
visit debates_path
accept_confirm { click_link "Featured" }
within("#debates") do
expect(page).to have_content "Featured"
expect(page).to have_content "FEATURED"
end
within("#featured-debates") do
expect(page).to have_content debate.title
click_link debate.title
end
visit debate_path(debate)
click_link "Unmark featured"
accept_confirm { click_link "Unmark featured" }
within("#debates") do
expect(page).not_to have_content "Featured"
expect(page).not_to have_content "FEATURED"
end
end