Skip to content

Commit

Permalink
Try to fix another flickering test
Browse files Browse the repository at this point in the history
modules/team_planner/spec/features/query_handling_spec.rb sometimes
misses the dropdown, because it does not wait long enough after adding a
filter, and once the filter is applied, the page state is reset and the
dropdown is closed, which leads to the error.
  • Loading branch information
cbliard committed Sep 6, 2024
1 parent 50dbd4e commit d8d0a2b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions modules/team_planner/spec/features/query_handling_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
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
Expand Down Expand Up @@ -97,7 +97,7 @@
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
Expand All @@ -120,6 +120,7 @@
# 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
Expand Down
5 changes: 3 additions & 2 deletions spec/features/views/shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# 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
Expand All @@ -48,6 +49,7 @@

# 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
Expand All @@ -61,8 +63,7 @@
# 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
Expand Down
7 changes: 7 additions & 0 deletions spec/support/toasts/expectations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ def dismiss_toaster!
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:)
Expand Down

0 comments on commit d8d0a2b

Please sign in to comment.