Add missing expectations in users tests

One of these tests has failed in our CI with the following message:

```
1) Users Public activity user can hide public page

   Failure/Error: expect(page).to have_content("activity list private")
     expected to find text "activity list private" in "Language: \n
     \nEnglish\nDeutsch\nEspañol\nFrançais\nNederlands\nPortuguês
     brasileiro\n中文\n       Notifications\nYou are in\nMy content\nMy
     account\nSign out\nDebates\nProposals\nVoting\nCollaborative
     legislation\nParticipatory budgeting\nSDG\nHelp\nM\nManuela124\nUser has
     no public activity\nOpen government\nThis portal uses the CONSUL
     DEMOCRACY application which is open-source
     software.\nParticipation\nDecide how to shape the city you want to live
     in.\nCONSUL DEMOCRACY, 2024 Privacy Policy Terms and conditions of use
     Accessibility"
```

Note how the text "User has no public activity" is present, which is a
message that appears when the user's activity is public.

A possible explanation is that we didn't check that the request done by
the "Save changes" button had finished before continuing with the tests.
Back when we wrote this test, submitting a form in a test would always
wait for the request to be finished before continuing, but a lot has
changed since then.

So we're adding an expectation to make sure the the changes have been
saved before making a new request.

We're also rearraging the blank lines in these tests and removing the
parenthesis in `have_content` expectations to be consistent with the
expectations we're adding.
This commit is contained in:
Javi Martín
2024-10-25 20:56:24 +02:00
parent fbcba3afdb
commit df716c3de6

View File

@@ -159,10 +159,12 @@ describe "Users" do
uncheck "account_public_activity"
click_button "Save changes"
logout
expect(page).to have_content "Changes saved"
logout
visit user_path(user)
expect(page).to have_content("activity list private")
expect(page).to have_content "activity list private"
end
scenario "is always visible for the owner" do
@@ -183,11 +185,13 @@ describe "Users" do
uncheck "account_public_activity"
click_button "Save changes"
logout
expect(page).to have_content "Changes saved"
logout
login_as(create(:administrator).user)
visit user_path(user)
expect(page).not_to have_content("activity list private")
expect(page).not_to have_content "activity list private"
end
scenario "is always visible for moderators" do
@@ -197,11 +201,13 @@ describe "Users" do
uncheck "account_public_activity"
click_button "Save changes"
logout
expect(page).to have_content "Changes saved"
logout
login_as(create(:moderator).user)
visit user_path(user)
expect(page).not_to have_content("activity list private")
expect(page).not_to have_content "activity list private"
end
describe "User email" do
@@ -461,8 +467,9 @@ describe "Users" do
check "account_public_interests"
click_button "Save changes"
logout
expect(page).to have_content "Changes saved"
logout
visit user_path(user, filter: "follows")
expect(page).to have_css "#public_interests"
@@ -479,10 +486,12 @@ describe "Users" do
check "account_public_interests"
click_button "Save changes"
logout
expect(page).to have_content "Changes saved"
logout
visit user_path(user)
expect(page).not_to have_content("Sport")
expect(page).not_to have_content "Sport"
end
end
end