From 6c055f2713f0cfe58b8e61907d2a649cf2011022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 10 Mar 2025 17:36:38 +0100 Subject: [PATCH] Add missing expectations in common actions We weren't checking that the request caused by clicking on the "Send instructions" button had finished before continuing with the test. Perhaps that's why this test has recently failed on our CI: ``` 3) Emails Reset password Failure/Error: email = open_last_email RuntimeError: No email has been sent! ``` We're also adding an expectation to the `login_as_manager` method and the methods to submit proposal and investment forms to make sure that, when these method finish, the request finishes as well. --- spec/support/common_actions/maps.rb | 4 ++++ spec/support/common_actions/users.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/spec/support/common_actions/maps.rb b/spec/support/common_actions/maps.rb index 1cc8ce233..bde0f93c6 100644 --- a/spec/support/common_actions/maps.rb +++ b/spec/support/common_actions/maps.rb @@ -7,9 +7,12 @@ module Maps def submit_proposal_form check :proposal_terms_of_service click_button "Create proposal" + expect(page).to have_content "Proposal created successfully." if page.has_content?("Not now, go to my proposal") click_link "Not now, go to my proposal" + + expect(page).not_to have_link "Not now, go to my proposal" end end @@ -22,6 +25,7 @@ module Maps def submit_budget_investment_form check :budget_investment_terms_of_service click_button "Create Investment" + expect(page).to have_content "Budget Investment created successfully" end def set_arguments(arguments, mappable, mappable_path_arguments) diff --git a/spec/support/common_actions/users.rb b/spec/support/common_actions/users.rb index b6dd6a4f2..e94a7fcc3 100644 --- a/spec/support/common_actions/users.rb +++ b/spec/support/common_actions/users.rb @@ -49,6 +49,8 @@ module Users def login_as_manager(manager = create(:manager)) login_as(manager.user) visit management_sign_in_path + + expect(page).to have_content "Management" end def login_managed_user(user) @@ -74,6 +76,9 @@ module Users fill_in "user_email", with: "manuela@consul.dev" click_button "Send instructions" + + expect(page).to have_content "If your email address is in our database, in a few minutes " \ + "you will receive a link to use to reset your password." end def expect_to_be_signed_in