diff --git a/spec/system/admin/activity_spec.rb b/spec/system/admin/activity_spec.rb index 6161fb5f5..7ee48afe0 100644 --- a/spec/system/admin/activity_spec.rb +++ b/spec/system/admin/activity_spec.rb @@ -20,7 +20,7 @@ describe "Admin activity" do visit admin_activity_path - within("#activity_#{Activity.last.id}") do + within first("tbody tr") do expect(page).to have_content(proposal.title) expect(page).to have_content("Hidden") expect(page).to have_content(admin.user.username) @@ -66,7 +66,7 @@ describe "Admin activity" do visit admin_activity_path - within("#activity_#{Activity.last.id}") do + within first("tbody tr") do expect(page).to have_content(proposal.title) expect(page).to have_content("Restored") expect(page).to have_content(admin.user.username) @@ -87,7 +87,7 @@ describe "Admin activity" do visit admin_activity_path - within("#activity_#{Activity.last.id}") do + within first("tbody tr") do expect(page).to have_content(debate.title) expect(page).to have_content("Hidden") expect(page).to have_content(admin.user.username) @@ -133,7 +133,7 @@ describe "Admin activity" do visit admin_activity_path - within("#activity_#{Activity.last.id}") do + within first("tbody tr") do expect(page).to have_content(debate.title) expect(page).to have_content("Restored") expect(page).to have_content(admin.user.username) @@ -155,7 +155,7 @@ describe "Admin activity" do visit admin_activity_path - within("#activity_#{Activity.last.id}") do + within first("tbody tr") do expect(page).to have_content(comment.body) expect(page).to have_content("Hidden") expect(page).to have_content(admin.user.username) @@ -201,7 +201,7 @@ describe "Admin activity" do visit admin_activity_path - within("#activity_#{Activity.last.id}") do + within first("tbody tr") do expect(page).to have_content(comment.body) expect(page).to have_content("Restored") expect(page).to have_content(admin.user.username) @@ -223,7 +223,7 @@ describe "Admin activity" do visit admin_activity_path - within("#activity_#{Activity.last.id}") do + within first("tbody tr") do expect(page).to have_content("Blocked") expect(page).to have_content(proposal.author.username) expect(page).to have_content(proposal.author.email) @@ -243,7 +243,7 @@ describe "Admin activity" do visit admin_activity_path - within("#activity_#{Activity.last.id}") do + within first("tbody tr") do expect(page).to have_content(user.username) expect(page).to have_content(user.email) expect(page).to have_content(admin.user.username) @@ -347,7 +347,7 @@ describe "Admin activity" do visit admin_activity_path - within("#activity_#{Activity.last.id}") do + within first("tbody tr") do expect(page).to have_content(user.username) expect(page).to have_content(user.email) expect(page).to have_content("Restored") @@ -366,7 +366,7 @@ describe "Admin activity" do visit admin_activity_path - within("#activity_#{Activity.last.id}") do + within first("tbody tr") do expect(page).to have_content(proposal_notification.title) expect(page).to have_content("Hidden") expect(page).to have_content(admin.user.username) diff --git a/spec/system/admin/budget_groups_spec.rb b/spec/system/admin/budget_groups_spec.rb index 139a6c103..c74b82177 100644 --- a/spec/system/admin/budget_groups_spec.rb +++ b/spec/system/admin/budget_groups_spec.rb @@ -97,7 +97,14 @@ describe "Admin budget groups", :admin do click_button "Create new group" expect(page).to have_content "Group created successfully!" - expect(Budget::Group.first.max_votable_headings).to be 1 + + within all("thead th")[1] do + expect(page).to have_content("Maximum number of headings in which a user can select projects") + end + + within "tbody tr" do + within all("td")[1] { expect(page.text).to eq "1" } + end end scenario "Group name is mandatory" do diff --git a/spec/system/admin/organizations_spec.rb b/spec/system/admin/organizations_spec.rb index 3980b6377..f0e9deb99 100644 --- a/spec/system/admin/organizations_spec.rb +++ b/spec/system/admin/organizations_spec.rb @@ -94,9 +94,12 @@ describe "Admin::Organizations" do click_on "Verify" end expect(page).to have_current_path(admin_organizations_path, ignore_query: true) - expect(page).to have_content "Verified" - expect(organization.reload.verified?).to eq(true) + click_link "Verified" + + within "tr", text: organization.name do + expect(page).to have_content "Verified" + end end scenario "Verified organizations have link to reject" do @@ -117,10 +120,10 @@ describe "Admin::Organizations" do expect(page).not_to have_content organization.name click_on "Rejected" - expect(page).to have_content "Rejected" - expect(page).to have_content organization.name - expect(organization.reload.rejected?).to eq(true) + within "tr", text: organization.name do + expect(page).to have_content "Rejected" + end end scenario "Rejected organizations have link to verify" do @@ -139,9 +142,9 @@ describe "Admin::Organizations" do expect(page).not_to have_content organization.name click_on("Verified") - expect(page).to have_content organization.name - - expect(organization.reload.verified?).to eq(true) + within "tr", text: organization.name do + expect(page).to have_content "Verified" + end end scenario "Current filter is properly highlighted" do diff --git a/spec/system/admin/system_emails_spec.rb b/spec/system/admin/system_emails_spec.rb index ea688440d..d96525f51 100644 --- a/spec/system/admin/system_emails_spec.rb +++ b/spec/system/admin/system_emails_spec.rb @@ -303,9 +303,16 @@ describe "System Emails" do visit admin_system_email_preview_pending_path("proposal_notification_digest") - expect(Notification.count).to equal(1) - expect(Activity.last.actionable_type).to eq("ProposalNotification") + expect(page).to have_content("Proposal B") expect(page).not_to have_content("Proposal A Title") + + visit admin_activity_path + + within first("tbody tr") do + expect(page).to have_content "Proposal notification" + expect(page).to have_content "Proposal A Title" + expect(page).to have_content admin.user.username + end end scenario "#send_pending" do diff --git a/spec/system/admin/widgets/cards_spec.rb b/spec/system/admin/widgets/cards_spec.rb index 1acba7873..e58868979 100644 --- a/spec/system/admin/widgets/cards_spec.rb +++ b/spec/system/admin/widgets/cards_spec.rb @@ -18,14 +18,15 @@ describe "Cards", :admin do expect(page).to have_content "Card created successfully!" expect(page).to have_css(".homepage-card", count: 1) - card = Widget::Card.last - within("#widget_card_#{card.id}") do - expect(page).to have_content "Card label" - expect(page).to have_content "Card text" - expect(page).to have_content "Card description" - expect(page).to have_content "Link text" - expect(page).to have_content "consul.dev" - expect(page).to have_link("Show image", href: card.image_url(:large)) + within "#cards" do + within all("tbody tr").last do + expect(page).to have_content "Card label" + expect(page).to have_content "Card text" + expect(page).to have_content "Card description" + expect(page).to have_content "Link text" + expect(page).to have_content "consul.dev" + expect(page).to have_link "Show image", href: Widget::Card.last.image_url(:large) + end end end @@ -91,12 +92,15 @@ describe "Cards", :admin do expect(page).to have_content "Card updated successfully" expect(page).to have_css(".homepage-card", count: 1) - within("#widget_card_#{Widget::Card.last.id}") do - expect(page).to have_content "Card label updated" - expect(page).to have_content "Card text updated" - expect(page).to have_content "Card description updated" - expect(page).to have_content "Link text updated" - expect(page).to have_content "consul.dev updated" + + within "#cards" do + within all("tbody tr").last do + expect(page).to have_content "Card label updated" + expect(page).to have_content "Card text updated" + expect(page).to have_content "Card description updated" + expect(page).to have_content "Link text updated" + expect(page).to have_content "consul.dev updated" + end end end diff --git a/spec/system/budget_polls/ballot_sheets_spec.rb b/spec/system/budget_polls/ballot_sheets_spec.rb index eb2874f63..3526b4adc 100644 --- a/spec/system/budget_polls/ballot_sheets_spec.rb +++ b/spec/system/budget_polls/ballot_sheets_spec.rb @@ -107,11 +107,13 @@ describe "Poll budget ballot sheets" do fill_in "data", with: "1234;5678" click_button "Save" - expect(Poll::BallotSheet.count).to be 1 - - expect(page).to have_content("Ballot sheet #{Poll::BallotSheet.last.id}") + expect(page).to have_content(/Ballot sheet \d+/) expect(page).to have_content(poll_officer.user.name) expect(page).to have_content("1234;5678") + + visit officing_poll_ballot_sheets_path(poll) + + expect(page).to have_css "tbody tr", count: 1 end scenario "Ballot sheet is not saved" do @@ -120,9 +122,11 @@ describe "Poll budget ballot sheets" do select "#{booth.name}", from: "officer_assignment_id" click_button "Save" - expect(Poll::BallotSheet.count).to be 0 - expect(page).to have_content("CSV data can't be blank") + + visit officing_poll_ballot_sheets_path(poll) + + expect(page).not_to have_css "tbody tr" end scenario "Shift booth has to be selected" do diff --git a/spec/system/budget_polls/voter_spec.rb b/spec/system/budget_polls/voter_spec.rb index 95034b4fd..243fe1b10 100644 --- a/spec/system/budget_polls/voter_spec.rb +++ b/spec/system/budget_polls/voter_spec.rb @@ -41,7 +41,7 @@ describe "BudgetPolls", :with_frozen_time do expect(page).to have_content "1" end - within("#poll_booth_assignment_#{Poll::BoothAssignment.find_by(poll: poll, booth: booth).id}_recounts") do + within "tr", text: booth.name do expect(page).to have_content "1" end end diff --git a/spec/system/officing/results_spec.rb b/spec/system/officing/results_spec.rb index 77c81cea8..33c248063 100644 --- a/spec/system/officing/results_spec.rb +++ b/spec/system/officing/results_spec.rb @@ -73,7 +73,7 @@ describe "Officing Results", :with_frozen_time do expect(page).to have_content("Your results") - within("#results_#{poll_officer.officer_assignments.first.booth_assignment_id}_#{Date.current.strftime("%Y%m%d")}") do + within "tbody tr" do expect(page).to have_content(I18n.l(Date.current, format: :long)) expect(page).to have_content(booth.name) end diff --git a/spec/system/polls/voter_spec.rb b/spec/system/polls/voter_spec.rb index 879a7e38d..cac36b494 100644 --- a/spec/system/polls/voter_spec.rb +++ b/spec/system/polls/voter_spec.rb @@ -72,7 +72,7 @@ describe "Voter" do expect(page).to have_content "1" end - within("#poll_booth_assignment_#{Poll::BoothAssignment.find_by(poll: poll, booth: booth).id}_recounts") do + within "tr", text: booth.name do expect(page).to have_content "1" end end @@ -159,7 +159,7 @@ describe "Voter" do expect(page).to have_content "1" end - within("#poll_booth_assignment_#{Poll::BoothAssignment.find_by(poll: poll, booth: booth).id}_recounts") do + within "tr", text: booth.name do expect(page).to have_content "1" end end @@ -224,7 +224,7 @@ describe "Voter" do expect(page).to have_content "1" end - within("#poll_booth_assignment_#{Poll::BoothAssignment.find_by(poll: poll, booth: booth).id}_recounts") do + within "tr", text: booth.name do expect(page).to have_content "1" end end