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:
@@ -25,8 +25,8 @@ describe "Admin poll officers", :admin do
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Delete" do
|
||||
click_link "Delete position"
|
||||
scenario "Delete", :js do
|
||||
accept_confirm { click_link "Delete position" }
|
||||
|
||||
expect(page).not_to have_css "#officers"
|
||||
end
|
||||
|
||||
@@ -134,7 +134,7 @@ describe "Admin poll questions", :admin do
|
||||
expect(page).not_to have_content(old_title)
|
||||
end
|
||||
|
||||
scenario "Destroy" do
|
||||
scenario "Destroy", :js do
|
||||
poll = create(:poll)
|
||||
question1 = create(:poll_question, poll: poll)
|
||||
question2 = create(:poll_question, poll: poll)
|
||||
@@ -142,7 +142,7 @@ describe "Admin poll questions", :admin do
|
||||
visit admin_poll_path(poll)
|
||||
|
||||
within("#poll_question_#{question1.id}") do
|
||||
click_link "Delete"
|
||||
accept_confirm { click_link "Delete" }
|
||||
end
|
||||
|
||||
expect(page).not_to have_content(question1.title)
|
||||
|
||||
@@ -159,7 +159,7 @@ describe "Admin shifts", :admin do
|
||||
expect(page).to have_content "A date must be selected"
|
||||
end
|
||||
|
||||
scenario "Destroy" do
|
||||
scenario "Destroy", :js do
|
||||
poll = create(:poll, :current)
|
||||
booth = create(:poll_booth, polls: [poll])
|
||||
officer = create(:poll_officer)
|
||||
@@ -174,14 +174,14 @@ describe "Admin shifts", :admin do
|
||||
|
||||
expect(page).to have_css(".shift", count: 1)
|
||||
within("#shift_#{shift.id}") do
|
||||
click_link "Remove"
|
||||
accept_confirm { click_link "Remove" }
|
||||
end
|
||||
|
||||
expect(page).to have_content "Shift removed"
|
||||
expect(page).to have_css(".shift", count: 0)
|
||||
end
|
||||
|
||||
scenario "Try to destroy with associated recount" do
|
||||
scenario "Try to destroy with associated recount", :js do
|
||||
assignment = create(:poll_booth_assignment)
|
||||
officer_assignment = create(:poll_officer_assignment, booth_assignment: assignment)
|
||||
create(:poll_recount, booth_assignment: assignment, officer_assignment: officer_assignment)
|
||||
@@ -198,7 +198,7 @@ describe "Admin shifts", :admin do
|
||||
|
||||
expect(page).to have_css(".shift", count: 1)
|
||||
within("#shift_#{shift.id}") do
|
||||
click_link "Remove"
|
||||
accept_confirm { click_link "Remove" }
|
||||
end
|
||||
|
||||
expect(page).not_to have_content "Shift removed"
|
||||
@@ -206,7 +206,7 @@ describe "Admin shifts", :admin do
|
||||
expect(page).to have_css(".shift", count: 1)
|
||||
end
|
||||
|
||||
scenario "try to destroy with associated partial results" do
|
||||
scenario "try to destroy with associated partial results", :js do
|
||||
assignment = create(:poll_booth_assignment)
|
||||
officer_assignment = create(:poll_officer_assignment, booth_assignment: assignment)
|
||||
create(:poll_partial_result,
|
||||
@@ -225,7 +225,7 @@ describe "Admin shifts", :admin do
|
||||
|
||||
expect(page).to have_css(".shift", count: 1)
|
||||
within("#shift_#{shift.id}") do
|
||||
click_link "Remove"
|
||||
accept_confirm { click_link "Remove" }
|
||||
end
|
||||
|
||||
expect(page).not_to have_content "Shift removed"
|
||||
|
||||
Reference in New Issue
Block a user