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

@@ -27,7 +27,7 @@ describe "Admin activity" do
end
end
scenario "Shows moderation activity from moderation screen" do
scenario "Shows moderation activity from moderation screen", :js do
proposal1 = create(:proposal)
proposal2 = create(:proposal)
proposal3 = create(:proposal)
@@ -42,7 +42,9 @@ describe "Admin activity" do
check "proposal_#{proposal3.id}_check"
end
click_on "Hide proposals"
accept_confirm { click_button "Hide proposals" }
expect(page).not_to have_content(proposal1.title)
visit admin_activity_path
@@ -51,15 +53,17 @@ describe "Admin activity" do
expect(page).to have_content(proposal3.title)
end
scenario "Shows admin restores" do
scenario "Shows admin restores", :js do
proposal = create(:proposal, :hidden)
visit admin_hidden_proposals_path
within("#proposal_#{proposal.id}") do
click_on "Restore"
accept_confirm { click_link "Restore" }
end
expect(page).to have_content "There are no hidden proposals"
visit admin_activity_path
within("#activity_#{Activity.last.id}") do
@@ -90,7 +94,7 @@ describe "Admin activity" do
end
end
scenario "Shows moderation activity from moderation screen" do
scenario "Shows moderation activity from moderation screen", :js do
debate1 = create(:debate)
debate2 = create(:debate)
debate3 = create(:debate)
@@ -105,7 +109,9 @@ describe "Admin activity" do
check "debate_#{debate3.id}_check"
end
click_on "Hide debates"
accept_confirm { click_button "Hide debates" }
expect(page).not_to have_content(debate1.title)
visit admin_activity_path
@@ -114,15 +120,17 @@ describe "Admin activity" do
expect(page).to have_content(debate3.title)
end
scenario "Shows admin restores" do
scenario "Shows admin restores", :js do
debate = create(:debate, :hidden)
visit admin_hidden_debates_path
within("#debate_#{debate.id}") do
click_on "Restore"
accept_confirm { click_link "Restore" }
end
expect(page).to have_content "There are no hidden debates"
visit admin_activity_path
within("#activity_#{Activity.last.id}") do
@@ -154,7 +162,7 @@ describe "Admin activity" do
end
end
scenario "Shows moderation activity from moderation screen" do
scenario "Shows moderation activity from moderation screen", :js do
comment1 = create(:comment, body: "SPAM")
comment2 = create(:comment)
comment3 = create(:comment, body: "Offensive!")
@@ -169,7 +177,9 @@ describe "Admin activity" do
check "comment_#{comment3.id}_check"
end
click_on "Hide comments"
accept_confirm { click_button "Hide comments" }
expect(page).not_to have_content(comment1.body)
visit admin_activity_path
@@ -178,15 +188,17 @@ describe "Admin activity" do
expect(page).to have_content(comment3.body)
end
scenario "Shows admin restores" do
scenario "Shows admin restores", :js do
comment = create(:comment, :hidden)
visit admin_hidden_comments_path
within("#comment_#{comment.id}") do
click_on "Restore"
accept_confirm { click_link "Restore" }
end
expect(page).to have_content "There are no hidden comments"
visit admin_activity_path
within("#activity_#{Activity.last.id}") do
@@ -198,13 +210,13 @@ describe "Admin activity" do
end
context "User" do
scenario "Shows moderation activity on users" do
scenario "Shows moderation activity on users", :js do
proposal = create(:proposal)
visit proposal_path(proposal)
within("#proposal_#{proposal.id}") do
click_link "Hide author"
accept_confirm { click_link "Hide author" }
expect(page).to have_current_path(debates_path)
end
@@ -238,7 +250,7 @@ describe "Admin activity" do
end
end
scenario "Shows moderation activity from proposals moderation screen" do
scenario "Shows moderation activity from proposals moderation screen", :js do
proposal1 = create(:proposal)
proposal2 = create(:proposal)
proposal3 = create(:proposal)
@@ -253,7 +265,9 @@ describe "Admin activity" do
check "proposal_#{proposal3.id}_check"
end
click_on "Block authors"
accept_confirm { click_button "Block authors" }
expect(page).not_to have_content(proposal1.author.username)
visit admin_activity_path
@@ -264,7 +278,7 @@ describe "Admin activity" do
expect(page).not_to have_content(proposal2.author.username)
end
scenario "Shows moderation activity from debates moderation screen" do
scenario "Shows moderation activity from debates moderation screen", :js do
debate1 = create(:debate)
debate2 = create(:debate)
debate3 = create(:debate)
@@ -279,7 +293,9 @@ describe "Admin activity" do
check "debate_#{debate3.id}_check"
end
click_on "Block authors"
accept_confirm { click_button "Block authors" }
expect(page).not_to have_content(debate1.author.username)
visit admin_activity_path
@@ -290,7 +306,7 @@ describe "Admin activity" do
expect(page).not_to have_content(debate2.author.username)
end
scenario "Shows moderation activity from comments moderation screen" do
scenario "Shows moderation activity from comments moderation screen", :js do
comment1 = create(:comment, body: "SPAM")
comment2 = create(:comment)
comment3 = create(:comment, body: "Offensive!")
@@ -305,7 +321,9 @@ describe "Admin activity" do
check "comment_#{comment3.id}_check"
end
click_on "Block authors"
accept_confirm { click_button "Block authors" }
expect(page).not_to have_content comment1.author.username
visit admin_activity_path
@@ -316,15 +334,17 @@ describe "Admin activity" do
expect(page).not_to have_content(comment2.author.username)
end
scenario "Shows admin restores" do
scenario "Shows admin restores", :js do
user = create(:user, :hidden)
visit admin_hidden_users_path
within("#user_#{user.id}") do
click_on "Restore"
accept_confirm { click_link "Restore" }
end
expect(page).to have_content "There are no hidden users"
visit admin_activity_path
within("#activity_#{Activity.last.id}") do

View File

@@ -113,12 +113,12 @@ describe "Admin Notifications", :admin do
end
context "Destroy" do
scenario "A draft notification can be destroyed" do
scenario "A draft notification can be destroyed", :js do
notification = create(:admin_notification)
visit admin_admin_notifications_path
within("#admin_notification_#{notification.id}") do
click_link "Delete"
accept_confirm { click_link "Delete" }
end
expect(page).to have_content "Notification deleted successfully"

View File

@@ -29,9 +29,9 @@ describe "Admin administrators" do
end
end
scenario "Delete Administrator" do
scenario "Delete Administrator", :js do
within "#administrator_#{user_administrator.id}" do
click_on "Delete"
accept_confirm { click_link "Delete" }
end
within("#administrators") do
@@ -39,9 +39,9 @@ describe "Admin administrators" do
end
end
scenario "Delete Administrator when its the current user" do
scenario "Delete Administrator when its the current user", :js do
within "#administrator_#{admin.id}" do
click_on "Delete"
accept_confirm { click_link "Delete" }
end
within("#error") do
@@ -101,11 +101,11 @@ describe "Admin administrators" do
expect(page).not_to have_content(administrator1.email)
end
scenario "Delete after searching" do
scenario "Delete after searching", :js do
fill_in "Search user by name or email", with: administrator2.email
click_button "Search"
click_link "Delete"
accept_confirm { click_link "Delete" }
expect(page).to have_content(administrator1.email)
expect(page).not_to have_content(administrator2.email)

View File

@@ -167,7 +167,7 @@ describe "Admin banners magement", :admin do
expect(page).not_to have_content "Wrong text"
end
scenario "Delete a banner" do
scenario "Delete a banner", :js do
create(:banner, title: "Ugly banner",
description: "Bad text",
target_url: "http://www.url.com",
@@ -176,15 +176,11 @@ describe "Admin banners magement", :admin do
background_color: "#FF0000",
font_color: "#FFFFFF")
visit admin_root_path
within("#side_menu") do
click_link "Manage banners"
end
visit admin_banners_path
expect(page).to have_content "Ugly banner"
click_link "Delete banner"
accept_confirm { click_link "Delete banner" }
visit admin_root_path
expect(page).not_to have_content "Ugly banner"

View File

@@ -55,22 +55,22 @@ describe "Admin budget groups", :admin do
end
end
scenario "Delete a group without headings" do
scenario "Delete a group without headings", :js do
group = create(:budget_group, budget: budget)
visit admin_budget_groups_path(budget)
within("#budget_group_#{group.id}") { click_link "Delete" }
within("#budget_group_#{group.id}") { accept_confirm { click_link "Delete" } }
expect(page).to have_content "Group deleted successfully"
expect(page).not_to have_selector "#budget_group_#{group.id}"
end
scenario "Try to delete a group with headings" do
scenario "Try to delete a group with headings", :js do
group = create(:budget_group, budget: budget)
create(:budget_heading, group: group)
visit admin_budget_groups_path(budget)
within("#budget_group_#{group.id}") { click_link "Delete" }
within("#budget_group_#{group.id}") { accept_confirm { click_link "Delete" } }
expect(page).to have_content "You cannot delete a Group that has associated headings"
expect(page).to have_selector "#budget_group_#{group.id}"

View File

@@ -60,22 +60,22 @@ describe "Admin budget headings", :admin do
end
end
scenario "Delete a heading without investments" do
scenario "Delete a heading without investments", :js do
heading = create(:budget_heading, group: group)
visit admin_budget_group_headings_path(budget, group)
within("#budget_heading_#{heading.id}") { click_link "Delete" }
within("#budget_heading_#{heading.id}") { accept_confirm { click_link "Delete" } }
expect(page).to have_content "Heading deleted successfully"
expect(page).not_to have_selector "#budget_heading_#{heading.id}"
end
scenario "Try to delete a heading with investments" do
scenario "Try to delete a heading with investments", :js do
heading = create(:budget_heading, group: group, name: "Atlantis")
create(:budget_investment, heading: heading)
visit admin_budget_group_headings_path(budget, group)
within(".heading", text: "Atlantis") { click_link "Delete" }
within(".heading", text: "Atlantis") { accept_confirm { click_link "Delete" } }
expect(page).to have_content "You cannot delete a Heading that has associated investments"
expect(page).to have_content "Atlantis"

View File

@@ -98,12 +98,12 @@ describe "Admin newsletter emails", :admin do
expect(page).to have_content "This is a body"
end
scenario "Destroy" do
scenario "Destroy", :js do
newsletter = create(:newsletter)
visit admin_newsletters_path
within("#newsletter_#{newsletter.id}") do
click_link "Delete"
accept_confirm { click_link "Delete" }
end
expect(page).to have_content "Newsletter deleted successfully"

View File

@@ -14,7 +14,7 @@ describe "Admin feature flags", :admin do
end
end
scenario "Disable a participatory process", :show_exceptions do
scenario "Disable a participatory process", :show_exceptions, :js do
setting = Setting.find_by(key: "process.budgets")
budget = create(:budget)
@@ -24,10 +24,11 @@ describe "Admin feature flags", :admin do
within("#edit_setting_#{setting.id}") do
expect(page).to have_button "Disable"
expect(page).not_to have_button "Enable"
click_button "Disable"
accept_confirm { click_button "Disable" }
end
visit admin_root_path
expect(page).to have_content "Value updated"
within("#side_menu") do
expect(page).not_to have_link "Participatory budgets"
@@ -43,7 +44,7 @@ describe "Admin feature flags", :admin do
expect(page).to have_content "Internal server error"
end
scenario "Enable a disabled participatory process" do
scenario "Enable a disabled participatory process", :js do
Setting["process.budgets"] = nil
setting = Setting.find_by(key: "process.budgets")
@@ -59,25 +60,28 @@ describe "Admin feature flags", :admin do
within("#edit_setting_#{setting.id}") do
expect(page).to have_button "Enable"
expect(page).not_to have_button "Disable"
click_button "Enable"
accept_confirm { click_button "Enable" }
end
visit admin_root_path
expect(page).to have_content "Value updated"
within("#side_menu") do
expect(page).to have_link "Participatory budgets"
end
end
scenario "Disable a feature" do
scenario "Disable a feature", :js do
setting = Setting.find_by(key: "feature.twitter_login")
visit admin_settings_path
click_link "Features"
within("#edit_setting_#{setting.id}") do
expect(page).to have_button "Disable"
expect(page).not_to have_button "Enable"
click_button "Disable"
accept_confirm { click_button "Disable" }
end
expect(page).to have_content "Value updated"
@@ -88,15 +92,17 @@ describe "Admin feature flags", :admin do
end
end
scenario "Enable a disabled feature" do
scenario "Enable a disabled feature", :js do
setting = Setting.find_by(key: "feature.map")
visit admin_settings_path
click_link "Features"
within("#edit_setting_#{setting.id}") do
expect(page).to have_button "Enable"
expect(page).not_to have_button "Disable"
click_button "Enable"
accept_confirm { click_button "Enable" }
end
expect(page).to have_content "Value updated"

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"

View File

@@ -13,12 +13,12 @@ describe "Admin hidden budget investments", :admin do
expect(page).to have_content(investment.description)
end
scenario "Restore" do
scenario "Restore", :js do
investment = create(:budget_investment, :hidden, heading: heading)
visit admin_hidden_budget_investments_path
click_link "Restore"
accept_confirm { click_link "Restore" }
expect(page).not_to have_content(investment.title)
@@ -78,13 +78,13 @@ describe "Admin hidden budget investments", :admin do
expect(page).to have_content("Confirmed investment")
end
scenario "Action links remember the pagination setting and the filter" do
scenario "Action links remember the pagination setting and the filter", :js do
allow(Budget::Investment).to receive(:default_per_page).and_return(2)
4.times { create(:budget_investment, :hidden, :with_confirmed_hide, heading: heading) }
visit admin_hidden_budget_investments_path(filter: "with_confirmed_hide", page: 2)
click_on("Restore", match: :first, exact: true)
accept_confirm { click_link "Restore", match: :first, exact: true }
expect(page).to have_current_path(/filter=with_confirmed_hide/)
expect(page).to have_current_path(/page=2/)

View File

@@ -1,7 +1,7 @@
require "rails_helper"
describe "Admin hidden comments", :admin do
scenario "Do not show comments from blocked users" do
scenario "Do not show comments from blocked users", :js do
comment = create(:comment, :hidden, body: "SPAM from SPAMMER")
proposal = create(:proposal, author: comment.author)
create(:comment, commentable: proposal, user: comment.author, body: "Good Proposal!")
@@ -11,11 +11,15 @@ describe "Admin hidden comments", :admin do
expect(page).not_to have_content("Good Proposal!")
visit proposal_path(proposal)
within("#proposal_#{proposal.id}") do
click_link "Hide author"
accept_confirm { click_link "Hide author" }
end
expect(page).to have_current_path debates_path
visit admin_hidden_comments_path
expect(page).not_to have_content("SPAM from SPAMMER")
expect(page).not_to have_content("Good Proposal!")
end
@@ -59,11 +63,11 @@ describe "Admin hidden comments", :admin do
expect(page).not_to have_link("This is SPAM comment on proposal")
end
scenario "Restore" do
scenario "Restore", :js do
comment = create(:comment, :hidden, body: "Not really SPAM")
visit admin_hidden_comments_path
click_link "Restore"
accept_confirm { click_link "Restore" }
expect(page).not_to have_content(comment.body)
@@ -119,13 +123,13 @@ describe "Admin hidden comments", :admin do
expect(page).to have_content("Confirmed comment")
end
scenario "Action links remember the pagination setting and the filter" do
scenario "Action links remember the pagination setting and the filter", :js do
allow(Comment).to receive(:default_per_page).and_return(2)
4.times { create(:comment, :hidden, :with_confirmed_hide) }
visit admin_hidden_comments_path(filter: "with_confirmed_hide", page: 2)
click_on("Restore", match: :first, exact: true)
accept_confirm { click_link "Restore", match: :first, exact: true }
expect(page).to have_current_path(/filter=with_confirmed_hide/)
expect(page).to have_current_path(/page=2/)

View File

@@ -1,11 +1,11 @@
require "rails_helper"
describe "Admin hidden debates", :admin do
describe "Admin hidden debates", :admin, :js do
scenario "Restore" do
debate = create(:debate, :hidden)
visit admin_hidden_debates_path
click_link "Restore"
accept_confirm { click_link "Restore" }
expect(page).not_to have_content(debate.title)
@@ -65,13 +65,13 @@ describe "Admin hidden debates", :admin do
expect(page).to have_content("Confirmed debate")
end
scenario "Action links remember the pagination setting and the filter" do
scenario "Action links remember the pagination setting and the filter", :js do
allow(Debate).to receive(:default_per_page).and_return(2)
4.times { create(:debate, :hidden, :with_confirmed_hide) }
visit admin_hidden_debates_path(filter: "with_confirmed_hide", page: 2)
click_on("Restore", match: :first, exact: true)
accept_confirm { click_link "Restore", match: :first, exact: true }
expect(page).to have_current_path(/filter=with_confirmed_hide/)
expect(page).to have_current_path(/page=2/)

View File

@@ -11,11 +11,11 @@ describe "Admin hidden proposals", :admin do
expect(page).to have_content(proposal.video_url)
end
scenario "Restore" do
scenario "Restore", :js do
proposal = create(:proposal, :hidden)
visit admin_hidden_proposals_path
click_link "Restore"
accept_confirm { click_link "Restore" }
expect(page).not_to have_content(proposal.title)
@@ -75,13 +75,13 @@ describe "Admin hidden proposals", :admin do
expect(page).to have_content("Confirmed proposal")
end
scenario "Action links remember the pagination setting and the filter" do
scenario "Action links remember the pagination setting and the filter", :js do
allow(Proposal).to receive(:default_per_page).and_return(2)
4.times { create(:proposal, :hidden, :with_confirmed_hide) }
visit admin_hidden_proposals_path(filter: "with_confirmed_hide", page: 2)
click_on("Restore", match: :first, exact: true)
accept_confirm { click_link "Restore", match: :first, exact: true }
expect(page).to have_current_path(/filter=with_confirmed_hide/)
expect(page).to have_current_path(/page=2/)

View File

@@ -17,11 +17,11 @@ describe "Admin hidden users", :admin do
expect(page).to have_content(comment2.body)
end
scenario "Restore" do
scenario "Restore", :js do
user = create(:user, :hidden)
visit admin_hidden_users_path
click_link "Restore"
accept_confirm { click_link "Restore" }
expect(page).not_to have_content(user.username)
@@ -76,13 +76,13 @@ describe "Admin hidden users", :admin do
expect(page).to have_content("Confirmed user")
end
scenario "Action links remember the pagination setting and the filter" do
scenario "Action links remember the pagination setting and the filter", :js do
allow(User).to receive(:default_per_page).and_return(2)
4.times { create(:user, :hidden, :with_confirmed_hide) }
visit admin_hidden_users_path(filter: "with_confirmed_hide", page: 2)
click_on("Restore", match: :first, exact: true)
accept_confirm { click_link "Restore", match: :first, exact: true }
expect(page).to have_current_path(/filter=with_confirmed_hide/)
expect(page).to have_current_path(/page=2/)

View File

@@ -134,11 +134,12 @@ describe "Admin local census records", :admin do
let!(:local_census_record) { create(:local_census_record) }
let!(:deleted_document_number) { local_census_record.document_number }
scenario "Should show successful destroy notice" do
scenario "Should show successful destroy notice", :js do
visit admin_local_census_records_path
expect(page).to have_content deleted_document_number
click_on "Delete"
accept_confirm { click_on "Delete" }
expect(page).to have_content "Local census record removed successfully!"
expect(page).not_to have_content deleted_document_number

View File

@@ -25,8 +25,8 @@ describe "Admin managers", :admin do
end
end
scenario "Delete Manager" do
click_link "Delete"
scenario "Delete Manager", :js do
accept_confirm { click_link "Delete" }
within("#managers") do
expect(page).not_to have_content manager.name
@@ -82,11 +82,11 @@ describe "Admin managers", :admin do
expect(page).not_to have_content(manager1.email)
end
scenario "Delete after searching" do
scenario "Delete after searching", :js do
fill_in "Search user by name or email", with: manager2.email
click_button "Search"
click_link "Delete"
accept_confirm { click_link "Delete" }
expect(page).to have_content(manager1.email)
expect(page).not_to have_content(manager2.email)

View File

@@ -72,13 +72,13 @@ describe "Admin milestone statuses", :admin do
end
context "Delete" do
scenario "Hides status" do
scenario "Hides status", :js do
status = create(:milestone_status)
visit admin_milestone_statuses_path
within("#milestone_status_#{status.id}") do
click_link "Delete"
accept_confirm { click_link "Delete" }
end
expect(page).not_to have_content status.name

View File

@@ -25,8 +25,8 @@ describe "Admin moderators", :admin do
end
end
scenario "Delete Moderator" do
click_link "Delete"
scenario "Delete Moderator", :js do
accept_confirm { click_link "Delete" }
within("#moderators") do
expect(page).not_to have_content moderator.name
@@ -82,11 +82,11 @@ describe "Admin moderators", :admin do
expect(page).not_to have_content(moderator1.email)
end
scenario "Delete after searching" do
scenario "Delete after searching", :js do
fill_in "Search user by name or email", with: moderator2.email
click_button "Search"
click_link "Delete"
accept_confirm { click_link "Delete" }
expect(page).to have_content(moderator1.email)
expect(page).not_to have_content(moderator2.email)

View File

@@ -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

View File

@@ -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)

View File

@@ -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"

View File

@@ -9,11 +9,11 @@ describe "Admin proposal notifications", :admin do
expect(page).to have_content(proposal_notification.body)
end
scenario "Restore" do
scenario "Restore", :js do
proposal_notification = create(:proposal_notification, :hidden, created_at: Date.current - 5.days)
visit admin_hidden_proposal_notifications_path
click_link "Restore"
accept_confirm { click_link "Restore" }
expect(page).not_to have_content(proposal_notification.title)
@@ -74,13 +74,13 @@ describe "Admin proposal notifications", :admin do
expect(page).to have_content("Confirmed notification")
end
scenario "Action links remember the pagination setting and the filter" do
scenario "Action links remember the pagination setting and the filter", :js do
allow(ProposalNotification).to receive(:default_per_page).and_return(2)
4.times { create(:proposal_notification, :hidden, :with_confirmed_hide) }
visit admin_hidden_proposal_notifications_path(filter: "with_confirmed_hide", page: 2)
click_on("Restore", match: :first, exact: true)
accept_confirm { click_link "Restore", match: :first, exact: true }
expect(page).to have_current_path(/filter=with_confirmed_hide/)
expect(page).to have_current_path(/page=2/)

View File

@@ -81,14 +81,14 @@ describe "Admin custom content blocks", :admin do
end
context "Delete" do
scenario "From index page" do
scenario "From index page", :js do
block = create(:site_customization_content_block)
visit admin_site_customization_content_blocks_path
expect(page).to have_content("#{block.name} (#{block.locale})")
expect(page).to have_content(block.body)
click_link "Delete block"
accept_confirm { click_link "Delete block" }
expect(page).not_to have_content("#{block.name} (#{block.locale})")
expect(page).not_to have_content(block.body)

View File

@@ -29,7 +29,7 @@ describe "Admin tags", :admin do
expect(page).to have_content "important issues"
end
scenario "Delete" do
scenario "Delete", :js do
tag2 = create(:tag, :category, name: "bad tag")
create(:debate, tag_list: "bad tag")
@@ -39,15 +39,14 @@ describe "Admin tags", :admin do
expect(page).to have_content "bad tag"
within("#tag_#{tag2.id}") do
click_link "Delete topic"
accept_confirm { click_link "Delete topic" }
end
visit admin_tags_path
expect(page).to have_content "Existence"
expect(page).not_to have_content "bad tag"
expect(page).to have_content "Existence"
end
scenario "Delete tag with hidden taggables" do
scenario "Delete tag with hidden taggables", :js do
tag2 = create(:tag, :category, name: "bad tag")
debate = create(:debate, tag_list: "bad tag")
debate.hide
@@ -58,12 +57,11 @@ describe "Admin tags", :admin do
expect(page).to have_content "bad tag"
within("#tag_#{tag2.id}") do
click_link "Delete topic"
accept_confirm { click_link "Delete topic" }
end
visit admin_tags_path
expect(page).to have_content "Existence"
expect(page).not_to have_content "bad tag"
expect(page).to have_content "Existence"
end
context "Manage only tags of kind category" do

View File

@@ -63,11 +63,11 @@ describe "Valuator groups", :admin do
expect(page).to have_content "Health and Sports"
end
scenario "Delete" do
scenario "Delete", :js do
create(:valuator_group)
visit admin_valuator_groups_path
click_link "Delete"
accept_confirm { click_link "Delete" }
expect(page).to have_content "Valuator group deleted successfully"
expect(page).to have_content "There are no valuator groups"

View File

@@ -50,8 +50,8 @@ describe "Admin valuators", :admin do
expect(page).not_to have_content "Can edit dossier"
end
scenario "Destroy" do
click_link "Delete"
scenario "Destroy", :js do
accept_confirm { click_link "Delete" }
within("#valuators") do
expect(page).not_to have_content(valuator.name)