Add a helper to dismiss a specific toast message

This commit is contained in:
Klaus Zanders
2026-03-20 13:41:35 +01:00
parent 974a0ec0f4
commit 5d47821e79
2 changed files with 6 additions and 1 deletions
@@ -114,7 +114,7 @@ RSpec.describe "Dashboard page managing", :js do
# We cannot use expect_and_dismiss_toaster for the first toast because its internal
# expect_no_toaster check races with the second toast appearing immediately after dismiss.
dashboard_page.expect_toast message: I18n.t("js.notice_successful_update")
dashboard_page.dismiss_toaster!
dashboard_page.dismiss_specific_toaster!(message: I18n.t("js.notice_successful_update"))
# Fixing flaky spec: for some reason, the second request to load the table is not executed until
# some activity happens on the page. Sending an enter key to trigger the second request.
+5
View File
@@ -17,6 +17,11 @@ module Toasts
page.find(".op-toast--close").click
end
def dismiss_specific_toaster!(message:, type: :success)
sleep 0.1
page.find(".op-toast.-#{type}", text: message).find(".op-toast--close").click
end
# Clears a toaster if there is one waiting 1 second max, but do not fail if there is none
def clear_any_toasters
if has_button?(I18n.t("js.close_popup_title"), wait: 1)