Files
grecia/spec/system/site_customization/information_texts_spec.rb
Javi Martín f63be041c1 Add missing expectations to confirm the page has changed
After a `visit`, we were checking for content or filling in fields that
were already there before the `visit`, so we weren't 100% sure that the
request had finished before the test continued.

In the case of the verification tests, we were clicking the submit
buttons over and over without and then checking or interacting with
elements that were already there. Even though the button was disabled
between requests, meaning there wouldn't be simultaneous requests, it
was possible to interact with a form field before waiting for the
request to finish.

Some of these tests have recently failed on our CI, and it might be
because of that:

```
1) Admin budgets Edit Changing name for current locale will update the
   slug if budget is in draft phase
   Failure/Error: raise ex, cause: cause

   Selenium::WebDriver::Error::UnknownError:
     unknown error: unhandled inspector error: {"code":-32000,
     "message":"Node with given id does not belong to the document"}
       (Session info: chrome=134.0.6998.35)

1) Budgets creation wizard Creation of a multiple-headings budget by
   steps
   Failure/Error: expect(page).to have_content "Heading created
   successfully!"

   Selenium::WebDriver::Error::UnknownError:
     unknown error: unhandled inspector error: {"code":-32000,
     "message":"Node with given id does not belong to the document"}
       (Session info: chrome=134.0.6998.35)

1) Custom information texts Show custom texts instead of default ones
   Failure/Error: raise ex, cause: cause

   Selenium::WebDriver::Error::UnknownError:
     unknown error: unhandled inspector error: {"code":-32000,
     "message":"Node with given id does not belong to the document"}
       (Session info: chrome=134.0.6998.35)

1) Users Regular authentication Sign in Avoid username-email collisions
   Failure/Error: raise ex, cause: cause

   Selenium::WebDriver::Error::UnknownError:
     unknown error: unhandled inspector error: {"code":-32000,
     "message":"Node with given id does not belong to the document"}
       (Session info: chrome=134.0.6998.35)

2) Verify Letter Code verification 6 tries allowed
   Failure/Error: raise ex, cause: cause

   Selenium::WebDriver::Error::UnknownError:
     unknown error: unhandled inspector error: {"code":-32000,
     "message":"Node with given id does not belong to the document"}
       (Session info: chrome=134.0.6998.35)

2) Valuation budget investments Valuate Finish valuation
   Failure/Error: raise ex, cause: cause

   Selenium::WebDriver::Error::UnknownError:
     unknown error: unhandled inspector error: {"code":-32000,
     "message":"Node with given id does not belong to the document"}
       (Session info: chrome=134.0.6998.35)

1) Users Delete a level 2 user account from document verification page
   Failure/Error: raise ex, cause: cause

   Selenium::WebDriver::Error::UnknownError:
     unknown error: unhandled inspector error: {"code":-32000,
     "message":"Node with given id does not belong to the document"}
       (Session info: chrome=134.0.6998.35)
```
2025-03-26 16:27:08 +01:00

60 lines
1.9 KiB
Ruby

require "rails_helper"
describe "Custom information texts", :admin do
scenario "Show custom texts instead of default ones" do
debate_key = "debates.index.section_footer.title"
proposal_key = "proposals.index.section_footer.title"
visit admin_site_customization_information_texts_path(tab: "debates")
fill_in "contents[content_#{debate_key}]values[value_en]", with: "Custom help with debates"
click_button "Save"
expect(page).to have_content "Translation updated successfully"
visit admin_site_customization_information_texts_path(tab: "proposals")
expect(page).not_to have_content "Translation updated successfully"
fill_in "contents[content_#{proposal_key}]values[value_en]", with: "Custom help with proposals"
click_button "Save"
expect(page).to have_content "Translation updated successfully"
visit debates_path
within("#section_help") do
expect(page).to have_content "Custom help with debates"
expect(page).not_to have_content "Help with debates"
end
visit proposals_path
within("#section_help") do
expect(page).to have_content "Custom help with proposals"
expect(page).not_to have_content "Help with proposals"
end
end
scenario "Show custom text with options" do
user = create(:user, username: "Rachel")
create(:budget_investment, author_id: user.id)
intro_key = "mailers.budget_investment_created.intro"
create(:i18n_content, key: intro_key, value_en: "Hi %{author}")
visit admin_site_customization_information_texts_path(tab: "mailers")
expect(page).to have_content "Hi %{author}"
fill_in "contents[content_#{intro_key}]values[value_en]", with: "Custom hi to %{author}"
click_button "Save"
expect(page).to have_content "Translation updated successfully"
visit admin_system_email_view_path("budget_investment_created")
expect(page).to have_content "Custom hi to Rachel"
expect(page).not_to have_content "%{author}"
end
end