Add missing expectations after refreshing the page

This way we know for sure the page has finished refreshing.

Note that, for now, we aren't adding a check after every call to the
`refresh` method because sometimes the page remains identical after
refreshing. Not sure what we should do in these cases.
This commit is contained in:
Javi Martín
2025-03-24 16:49:32 +01:00
parent f63be041c1
commit 1dcfc38e41
7 changed files with 23 additions and 2 deletions

View File

@@ -43,6 +43,7 @@ describe "Account" do
refresh refresh
expect(page).not_to have_content "Changes saved"
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
expect(find("#account_email_on_comment_reply")).to be_checked expect(find("#account_email_on_comment_reply")).to be_checked
@@ -98,6 +99,7 @@ describe "Account" do
refresh refresh
expect(page).not_to have_content "Changes saved"
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
expect(find("#account_email_on_comment_reply")).to be_checked expect(find("#account_email_on_comment_reply")).to be_checked
@@ -131,21 +133,25 @@ describe "Account" do
expect(page).to have_content "Changes saved" expect(page).to have_content "Changes saved"
refresh refresh
expect(page).not_to have_content "Changes saved"
expect(find("#account_official_position_badge")).to be_checked expect(find("#account_official_position_badge")).to be_checked
end end
scenario "Users with official position of level 2 and above" do scenario "Users with official position of level 2 and above" do
official_user2 = create(:user, official_level: 2) official_user2 = create(:user, official_level: 2, username: "Official 2")
official_user3 = create(:user, official_level: 3) official_user3 = create(:user, official_level: 3, username: "Official 3")
login_as(official_user2) login_as(official_user2)
visit account_path visit account_path
expect(page).to have_field "Username", with: "Official 2"
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)
refresh refresh
expect(page).to have_field "Username", with: "Official 3"
expect(page).not_to have_css "#account_official_position_badge" expect(page).not_to have_css "#account_official_position_badge"
end end
end end

View File

@@ -1802,6 +1802,8 @@ describe "Admin budget investments", :admin do
click_button "Columns" click_button "Columns"
expect(page).to have_css "button[aria-expanded=true]", exact_text: "Columns"
within("#js-columns-selector-wrapper") do within("#js-columns-selector-wrapper") do
uncheck "Title" uncheck "Title"
uncheck "Price" uncheck "Price"
@@ -1816,6 +1818,8 @@ describe "Admin budget investments", :admin do
refresh refresh
expect(page).to have_css "button[aria-expanded=false]", exact_text: "Columns"
cookie_value = cookie_by_name("investments-columns")[:value] cookie_value = cookie_by_name("investments-columns")[:value]
expect(cookie_value).to eq("id,supports,admin,geozone,feasibility,valuation_finished," \ expect(cookie_value).to eq("id,supports,admin,geozone,feasibility,valuation_finished," \

View File

@@ -110,9 +110,12 @@ describe "Admin legislation questions", :admin do
find("#nested_question_options input").set("Changed") find("#nested_question_options input").set("Changed")
click_button "Save changes" click_button "Save changes"
expect(page).to have_content "Question updated successfully"
expect(page).not_to have_css "#error_explanation" expect(page).not_to have_css "#error_explanation"
refresh refresh
expect(page).not_to have_content "Question updated successfully"
expect(page).to have_field(field_en[:id], with: "Changed") expect(page).to have_field(field_en[:id], with: "Changed")
end end
@@ -136,6 +139,7 @@ describe "Admin legislation questions", :admin do
refresh refresh
expect(page).not_to have_content "Question updated successfully"
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"
end end

View File

@@ -69,6 +69,8 @@ describe "Admin booths", :admin do
expect(page).to have_content "Booth created successfully" expect(page).to have_content "Booth created successfully"
refresh refresh
expect(page).not_to have_content "Booth created successfully"
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

@@ -66,6 +66,7 @@ describe "Poll question options", :admin do
refresh refresh
expect(page).not_to have_content "Changes saved"
expect(page).not_to have_content "Answer title" expect(page).not_to have_content "Answer title"
expect("Another title").to appear_before("New title") expect("Another title").to appear_before("New title")

View File

@@ -75,6 +75,9 @@ describe "Admin custom information texts", :admin do
expect(page).to have_content "Translation updated successfully" expect(page).to have_content "Translation updated successfully"
refresh refresh
expect(page).not_to have_content "Translation updated successfully"
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

@@ -1169,6 +1169,7 @@ describe "Budget Investments" do
refresh refresh
expect(page).not_to have_content "Investment project deleted successfully"
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
end end