From 3a9263f6e648579d60ef0424e9fa0ab2b96eb688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Mon, 10 Mar 2025 23:33:30 +0100 Subject: [PATCH] Check flash messages in some system tests This way it's more clear what the user experience is during the process. Note this did not result in flaky tests, since the tests continue by clicking links, that are only present after the request has finished. However, we're adding expectations so we don't have to think whether the tests could be flaky and because this way we're also testing the user experience; it would be strange for a user if they were redirected to a page without a flash message. --- spec/system/admin/budgets_wizard/groups_spec.rb | 2 ++ spec/system/sdg_management/relations_spec.rb | 9 +++++++++ spec/system/verification/sms_spec.rb | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/spec/system/admin/budgets_wizard/groups_spec.rb b/spec/system/admin/budgets_wizard/groups_spec.rb index 7611ba2b4..13d04105e 100644 --- a/spec/system/admin/budgets_wizard/groups_spec.rb +++ b/spec/system/admin/budgets_wizard/groups_spec.rb @@ -103,6 +103,8 @@ describe "Budgets wizard, groups step", :admin do fill_in "Group name", with: "Group wiht typo" click_button "Continue to headings" + expect(page).to have_content "Group created successfully" + click_link "Go back to edit group" expect(page).to have_field "Group name", with: "Group wiht typo" diff --git a/spec/system/sdg_management/relations_spec.rb b/spec/system/sdg_management/relations_spec.rb index e69461293..e8c4de8b5 100644 --- a/spec/system/sdg_management/relations_spec.rb +++ b/spec/system/sdg_management/relations_spec.rb @@ -373,6 +373,9 @@ describe "SDG Relations" do within(".amsify-suggestags-input-area") { expect(page).to have_content "1.1.1" } click_button "Update Process" + + expect(page).to have_content "Process updated successfully and marked as reviewed" + click_link "Marked as reviewed" within("tr", text: "SDG process") do @@ -397,6 +400,9 @@ describe "SDG Relations" do visit sdg_management_edit_legislation_process_path(process) click_sdg_goal(1) click_button "Update Process" + + expect(page).to have_content "Process updated successfully and marked as reviewed" + click_link "Marked as reviewed" within("tr", text: "SDG process") do @@ -411,6 +417,9 @@ describe "SDG Relations" do visit sdg_management_edit_legislation_process_path(process) click_sdg_goal(1) click_button "Update Process" + + expect(page).to have_content "Process updated successfully and marked as reviewed" + click_link "Marked as reviewed" within("tr", text: "SDG process") do diff --git a/spec/system/verification/sms_spec.rb b/spec/system/verification/sms_spec.rb index 035f36321..707abc6e3 100644 --- a/spec/system/verification/sms_spec.rb +++ b/spec/system/verification/sms_spec.rb @@ -65,7 +65,12 @@ describe "SMS Verification" do 5.times do fill_in "sms_phone", with: "611111111" click_button "Send" + + expect(page).to have_content "Enter the confirmation code sent to you by text message" + click_link "Click here to send it again" + + expect(page).not_to have_content "Enter the confirmation code sent to you by text message" end expect(page).to have_content "You have reached the maximum number of attempts. Please try again later."