Use refresh instead of visiting the current page

This way it's more obvious what's going on.

Note that, in this case, the expectations were **not** true before
visiting the page, so we aren't fixing a flaky test.
This commit is contained in:
Javi Martín
2025-03-14 22:24:44 +01:00
parent 1593a150e7
commit 533d2198ee
17 changed files with 26 additions and 26 deletions

View File

@@ -34,7 +34,7 @@ shared_examples "flaggable" do |factory_name, admin: false|
expect(page).not_to have_link "Flag as inappropriate", visible: :all expect(page).not_to have_link "Flag as inappropriate", visible: :all
end end
visit path refresh
within "##{dom_id(flaggable)} .flag-content" do within "##{dom_id(flaggable)} .flag-content" do
expect(page).to have_link "Unflag", visible: :hidden expect(page).to have_link "Unflag", visible: :hidden

View File

@@ -41,7 +41,7 @@ describe "Account" do
expect(page).to have_content "Changes saved" expect(page).to have_content "Changes saved"
visit account_path refresh
expect(page).to have_css "input[value='Larry Bird']" expect(page).to have_css "input[value='Larry Bird']"
expect(find("#account_email_on_comment")).to be_checked expect(find("#account_email_on_comment")).to be_checked
@@ -96,7 +96,7 @@ describe "Account" do
expect(page).to have_content "Changes saved" expect(page).to have_content "Changes saved"
visit account_path refresh
expect(page).to have_css "input[value='Google']" expect(page).to have_css "input[value='Google']"
expect(find("#account_email_on_comment")).to be_checked expect(find("#account_email_on_comment")).to be_checked
@@ -130,7 +130,7 @@ describe "Account" do
click_button "Save changes" click_button "Save changes"
expect(page).to have_content "Changes saved" expect(page).to have_content "Changes saved"
visit account_path refresh
expect(find("#account_official_position_badge")).to be_checked expect(find("#account_official_position_badge")).to be_checked
end end
@@ -144,7 +144,7 @@ describe "Account" do
expect(page).not_to have_css "#account_official_position_badge" expect(page).not_to have_css "#account_official_position_badge"
login_as(official_user3) login_as(official_user3)
visit account_path refresh
expect(page).not_to have_css "#account_official_position_badge" expect(page).not_to have_css "#account_official_position_badge"
end end

View File

@@ -72,7 +72,7 @@ describe "Admin budget investments", :admin do
end end
budget_investment3.update!(administrator_id: admin.id) budget_investment3.update!(administrator_id: admin.id)
visit admin_budget_budget_investments_path(budget_id: budget.id) refresh
within("#budget_investment_#{budget_investment3.id}") do within("#budget_investment_#{budget_investment3.id}") do
expect(page).to have_content("Gema") expect(page).to have_content("Gema")
@@ -1814,7 +1814,7 @@ describe "Admin budget investments", :admin do
expect(cookie_value).to eq("id,supports,admin,geozone,feasibility,valuation_finished," \ expect(cookie_value).to eq("id,supports,admin,geozone,feasibility,valuation_finished," \
"visible_to_valuators,selected,incompatible,author") "visible_to_valuators,selected,incompatible,author")
visit admin_budget_budget_investments_path(budget) refresh
cookie_value = cookie_by_name("investments-columns")[:value] cookie_value = cookie_by_name("investments-columns")[:value]

View File

@@ -112,7 +112,7 @@ describe "Admin legislation questions", :admin do
expect(page).not_to have_css "#error_explanation" expect(page).not_to have_css "#error_explanation"
visit edit_question_url refresh
expect(page).to have_field(field_en[:id], with: "Changed") expect(page).to have_field(field_en[:id], with: "Changed")
end end
@@ -134,7 +134,7 @@ describe "Admin legislation questions", :admin do
expect(page).to have_content "Question updated successfully" expect(page).to have_content "Question updated successfully"
visit edit_question_url refresh
expect(page).not_to have_field fields_for(:en).first[:id], with: "Yes" expect(page).not_to have_field fields_for(:en).first[:id], with: "Yes"
expect(page).to have_field fields_for(:en).last[:id], with: "No" expect(page).to have_field fields_for(:en).last[:id], with: "No"

View File

@@ -68,7 +68,7 @@ describe "Admin booths", :admin do
expect(page).to have_content "Booth created successfully" expect(page).to have_content "Booth created successfully"
visit admin_booths_path refresh
expect(page).to have_content "Upcoming booth" expect(page).to have_content "Upcoming booth"
expect(page).to have_content "39th Street, number 2, ground floor" expect(page).to have_content "39th Street, number 2, ground floor"
end end

View File

@@ -64,7 +64,7 @@ describe "Poll question options", :admin do
expect(page).to have_content "Changes saved" expect(page).to have_content "Changes saved"
expect(page).to have_content "New title" expect(page).to have_content "New title"
visit admin_question_path(question) refresh
expect(page).not_to have_content "Answer title" expect(page).not_to have_content "Answer title"

View File

@@ -74,7 +74,7 @@ describe "Admin custom information texts", :admin do
expect(page).to have_content "Translation updated successfully" expect(page).to have_content "Translation updated successfully"
visit admin_site_customization_information_texts_path refresh
select "Français", from: "Current language" select "Français", from: "Current language"
expect(page).to have_content "Aide personalise sur les débats" expect(page).to have_content "Aide personalise sur les débats"

View File

@@ -333,7 +333,7 @@ describe "System Emails" do
expect(page).not_to have_content("Proposal A Title") expect(page).not_to have_content("Proposal A Title")
visit admin_system_email_preview_pending_path("proposal_notification_digest") refresh
expect(page).to have_content("Proposal B") expect(page).to have_content("Proposal B")
expect(page).not_to have_content("Proposal A Title") expect(page).not_to have_content("Proposal A Title")

View File

@@ -26,7 +26,7 @@ describe "Admin tags", :admin do
within("table") { expect(page).to have_content "important issues" } within("table") { expect(page).to have_content "important issues" }
visit admin_tags_path refresh
expect(page).to have_content "important issues" expect(page).to have_content "important issues"
end end

View File

@@ -18,7 +18,7 @@ describe "Budget Poll Officing" do
create(:poll_shift, officer: officer, booth: booth, date: Date.current, task: :recount_scrutiny) create(:poll_shift, officer: officer, booth: booth, date: Date.current, task: :recount_scrutiny)
create(:poll_officer_assignment, booth_assignment: booth_assignment, officer: officer) create(:poll_officer_assignment, booth_assignment: booth_assignment, officer: officer)
visit officing_root_path refresh
expect(page).not_to have_content("You don't have officing shifts today") expect(page).not_to have_content("You don't have officing shifts today")
expect(page).to have_content("Validate document") expect(page).to have_content("Validate document")

View File

@@ -110,7 +110,7 @@ describe "BudgetPolls", :with_frozen_time do
expect(page).to have_content "Remove" expect(page).to have_content "Remove"
end end
visit budget_investment_path(budget, investment) refresh
within("#budget_investment_#{investment.id}") do within("#budget_investment_#{investment.id}") do
expect(page).to have_content "Remove vote" expect(page).to have_content "Remove vote"

View File

@@ -331,7 +331,7 @@ describe "Budget Investments" do
order = all(".budget-investment h3").map(&:text) order = all(".budget-investment h3").map(&:text)
expect(order).not_to be_empty expect(order).not_to be_empty
visit budget_investments_path(budget, heading_id: heading.id) refresh
new_order = all(".budget-investment h3").map(&:text) new_order = all(".budget-investment h3").map(&:text)
expect(order).to eq(new_order) expect(order).to eq(new_order)
@@ -522,7 +522,7 @@ describe "Budget Investments" do
order = all(".budget-investment h3").map(&:text) order = all(".budget-investment h3").map(&:text)
expect(order).not_to be_empty expect(order).not_to be_empty
visit budget_investments_path(budget, heading_id: heading.id) refresh
new_order = all(".budget-investment h3").map(&:text) new_order = all(".budget-investment h3").map(&:text)
expect(order).to eq(new_order) expect(order).to eq(new_order)
@@ -1167,7 +1167,7 @@ describe "Budget Investments" do
expect(page).to have_content "Investment project deleted successfully" expect(page).to have_content "Investment project deleted successfully"
visit user_path(user, tab: :budget_investments) refresh
expect(page).to have_content "User has no public activity" expect(page).to have_content "User has no public activity"
expect(page).not_to have_content investment1.title expect(page).not_to have_content investment1.title

View File

@@ -209,7 +209,7 @@ describe "Legislation Draft Versions" do
first(:css, ".annotator-hl").click first(:css, ".annotator-hl").click
expect(page).to have_content "this is my annotation" expect(page).to have_content "this is my annotation"
visit legislation_process_draft_version_path(draft_version.process, draft_version) refresh
expect(page).to have_css ".annotator-hl" expect(page).to have_css ".annotator-hl"
first(:css, ".annotator-hl").click first(:css, ".annotator-hl").click

View File

@@ -113,7 +113,7 @@ describe "Legislation" do
expect(page).to have_content("published") expect(page).to have_content("published")
login_as(administrator) login_as(administrator)
visit legislation_processes_path refresh
expect(page).not_to have_content("not published") expect(page).not_to have_content("not published")
expect(page).to have_content("published") expect(page).to have_content("published")
end end
@@ -124,7 +124,7 @@ describe "Legislation" do
expect(page).to have_content("past published") expect(page).to have_content("past published")
login_as(administrator) login_as(administrator)
visit legislation_processes_path(filter: "past") refresh
expect(page).not_to have_content("not published") expect(page).not_to have_content("not published")
expect(page).to have_content("past published") expect(page).to have_content("past published")
end end

View File

@@ -86,7 +86,7 @@ describe "Users" do
expect(page).to have_content "User account deleted." expect(page).to have_content "User account deleted."
visit management_document_verifications_path refresh
fill_in "document_verification_document_number", with: "12345678Z" fill_in "document_verification_document_number", with: "12345678Z"
click_button "Check document" click_button "Check document"

View File

@@ -16,7 +16,7 @@ describe "Moderate comments" do
end end
login_as(citizen) login_as(citizen)
visit debate_path(comment.commentable) refresh
expect(page).to have_css(".comment", count: 1) expect(page).to have_css(".comment", count: 1)
expect(page).not_to have_content("This comment has been deleted") expect(page).not_to have_content("This comment has been deleted")

View File

@@ -27,7 +27,7 @@ describe "Voter" do
expect(page).not_to have_button("Vote Yes") expect(page).not_to have_button("Vote Yes")
end end
visit poll_path(poll) refresh
expect(page).to have_content("You have already participated in this poll.") expect(page).to have_content("You have already participated in this poll.")
expect(page).to have_content("If you vote again it will be overwritten") expect(page).to have_content("If you vote again it will be overwritten")
@@ -51,7 +51,7 @@ describe "Voter" do
expect(page).to have_button("Vote No") expect(page).to have_button("Vote No")
end end
visit poll_path(poll) refresh
expect(page).not_to have_content("You have already participated in this poll.") expect(page).not_to have_content("You have already participated in this poll.")
expect(page).not_to have_content("If you vote again it will be overwritten") expect(page).not_to have_content("If you vote again it will be overwritten")