Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Try to fix another flickering test

Christophe Bliardd8d0a2be14b3
diff --git a/modules/team_planner/spec/features/query_handling_spec.rb b/modules/team_planner/spec/features/query_handling_spec.rb
index 4b7b88d7df0..812e9def0f3 100644
--- a/modules/team_planner/spec/features/query_handling_spec.rb
+++ b/modules/team_planner/spec/features/query_handling_spec.rb
@@ -32,7 +32,7 @@ require "spec_helper"
require_relative "../support/pages/team_planner"
require_relative "../../../../spec/features/views/shared_examples"
-RSpec.describe "Team planner query handling", :js, with_ee: %i[team_planner_view] do
+RSpec.describe "Team planner query handling", :js, :with_cuprite, with_ee: %i[team_planner_view] do
shared_let(:type_task) { create(:type_task) }
shared_let(:type_bug) { create(:type_bug) }
shared_let(:project) do
@@ -97,7 +97,7 @@ RSpec.describe "Team planner query handling", :js, with_ee: %i[team_planner_view
filters.open
filters.add_filter_by("Type", "is (OR)", [type_bug.name])
-
+ team_planner.clear_any_toasters
filters.expect_filter_count("2")
team_planner.within_lane(user) do
@@ -120,6 +120,7 @@ RSpec.describe "Team planner query handling", :js, with_ee: %i[team_planner_view
# Change filter
filters.open
filters.add_filter_by("Type", "is (OR)", [type_bug.name])
+ team_planner.clear_any_toasters
filters.expect_filter_count("2")
# Save current filters
diff --git a/spec/features/views/shared_examples.rb b/spec/features/views/shared_examples.rb
index c2740a6ca41..03d59feb526 100644
--- a/spec/features/views/shared_examples.rb
+++ b/spec/features/views/shared_examples.rb
@@ -37,6 +37,7 @@ RSpec.shared_examples "module specific query view management" do
# Change the query
filters.open
filters.add_filter_by "Subject", "contains", ["Test"]
+ module_page.clear_any_toasters
filters.expect_filter_count(initial_filter_count + 1)
# Save it
@@ -48,6 +49,7 @@ RSpec.shared_examples "module specific query view management" do
# Change the filter again
filters.add_filter_by "% Complete", "is", ["25"], "percentageDone"
+ module_page.clear_any_toasters
filters.expect_filter_count(initial_filter_count + 2)
# Save as another query
@@ -61,8 +63,7 @@ RSpec.shared_examples "module specific query view management" do
# Rename a query
settings_menu.open_and_choose "Rename view"
expect(page).to have_focus_on(".editable-toolbar-title--input")
- page.driver.browser.switch_to.active_element.send_keys("My second query (renamed)")
- page.driver.browser.switch_to.active_element.send_keys(:return)
+ find_field("Name of this view").send_keys("My second query (renamed)", :return)
module_page.expect_and_dismiss_toaster message: I18n.t("js.notice_successful_update")
query_title.expect_not_changed
diff --git a/spec/support/toasts/expectations.rb b/spec/support/toasts/expectations.rb
index 240bf5946d7..c53065fb4cc 100644
--- a/spec/support/toasts/expectations.rb
+++ b/spec/support/toasts/expectations.rb
@@ -23,6 +23,13 @@ module Toasts
page.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)
+ find_button(I18n.t("js.close_popup_title")).click
+ end
+ end
+
def expect_no_toaster(type: :success, message: nil, wait: 10)
if type.nil?
expect(page).to have_no_css(".op-toast", wait:)