From 472faf05a502108deb105a3dae392704e798c3a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20G=C3=BCnther?= Date: Tue, 23 Jun 2026 11:24:55 +0200 Subject: [PATCH] Fix flaky spec on work_packages_table --- .../spec/features/my/work_package_table_spec.rb | 8 ++++---- spec/support/toasts/expectations.rb | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/modules/my_page/spec/features/my/work_package_table_spec.rb b/modules/my_page/spec/features/my/work_package_table_spec.rb index b61c932a5e76..3e1fbae4d0ea 100644 --- a/modules/my_page/spec/features/my/work_package_table_spec.rb +++ b/modules/my_page/spec/features/my/work_package_table_spec.rb @@ -87,15 +87,15 @@ assigned_to_me_area = Components::Grids::GridArea.new(".grid--area.-widgeted:nth-of-type(1)") expect(assigned_to_me_area.area) .to have_css(".subject", text: other_type_work_package.subject) - my_page.expect_and_dismiss_toaster message: I18n.t("js.notice_successful_update") + my_page.expect_and_dismiss_all_toasters message: I18n.t("js.notice_successful_update") my_page.add_widget(1, 3, :column, "Work packages table") - my_page.expect_and_dismiss_toaster message: I18n.t("js.notice_successful_update") + my_page.expect_and_dismiss_all_toasters message: I18n.t("js.notice_successful_update") created_by_me_area.remove - my_page.expect_and_dismiss_toaster message: I18n.t("js.notice_successful_update") + my_page.expect_and_dismiss_all_toasters message: I18n.t("js.notice_successful_update") assigned_to_me_area.remove - my_page.expect_and_dismiss_toaster message: I18n.t("js.notice_successful_update") + my_page.expect_and_dismiss_all_toasters message: I18n.t("js.notice_successful_update") filter_area = Components::Grids::GridArea.new(".grid--area.-widgeted:nth-of-type(1)") filter_area.expect_to_span(1, 1, 2, 2) diff --git a/spec/support/toasts/expectations.rb b/spec/support/toasts/expectations.rb index a2b7d407461f..772f24b34521 100644 --- a/spec/support/toasts/expectations.rb +++ b/spec/support/toasts/expectations.rb @@ -12,6 +12,20 @@ def expect_and_dismiss_toaster(message: nil, type: :success, wait: 20) expect_no_toaster(type:, message:, wait: 0.1) end + # Like #expect_and_dismiss_toaster, but tolerant of a single user action raising + # several identical toasts (e.g. a grid change that persists in multiple steps). + # Dismisses every matching toast, allowing late ones to still appear, before + # asserting that none remain. + def expect_and_dismiss_all_toasters(message: nil, type: :success, wait: 20) + expect_toast(type:, message:, wait:) + + while page.has_css?(".op-toast.-#{type}", wait: 1) + page.first(".op-toast.-#{type} .op-toast--close", wait: 1).click + end + + expect_no_toaster(type:, message:, wait: 2) + end + def dismiss_toaster! sleep 0.1 page.find(".op-toast--close").click