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

Fix flaky spec

Christophe Bliard7c7ebb645870
diff --git a/modules/boards/spec/features/action_boards/status_type_moving_board_spec.rb b/modules/boards/spec/features/action_boards/status_type_moving_board_spec.rb
index e4271110be1..a94c2eb12ea 100644
--- a/modules/boards/spec/features/action_boards/status_type_moving_board_spec.rb
+++ b/modules/boards/spec/features/action_boards/status_type_moving_board_spec.rb
@@ -128,7 +128,7 @@ RSpec.describe "Status action board",
filters.expect_filter_by("Type", "is (OR)", [type_task.name, type_bug.name])
# Wait a bit before saving the page to ensure both values are processed
- sleep 2
+ board_page.wait_for_lists_reload
board_page.expect_changed
board_page.save
@@ -142,12 +142,8 @@ RSpec.describe "Status action board",
board_page.card_for(task_wp).expect_type "Task"
board_page.card_for(bug_wp).expect_type "Bug"
- # Wait a bit before moving the items too fast
- sleep 2
-
# Move bug to open
board_page.move_card_by_name("Closed bug item", from: "Closed", to: "Open")
- board_page.wait_for_lists_reload
board_page.expect_card("Closed", "Closed bug item", present: false)
board_page.expect_card("Open", "Closed bug item", present: true)
@@ -156,8 +152,6 @@ RSpec.describe "Status action board",
board_page.card_for(task_wp).expect_type "Task"
board_page.card_for(bug_wp).expect_type "Bug"
- sleep 2
-
task_wp.reload
bug_wp.reload
diff --git a/modules/boards/spec/features/support/board_page.rb b/modules/boards/spec/features/support/board_page.rb
index d742452f088..af3cbd515b2 100644
--- a/modules/boards/spec/features/support/board_page.rb
+++ b/modules/boards/spec/features/support/board_page.rb
@@ -175,6 +175,11 @@ module Pages
target = page.find list_selector(to)
drag_n_drop_element(from: source, to: target)
+ wait_for_lists_reload
+
+ # Wait a little more because the cards sorting order can still be changing
+ # after moving them
+ sleep 2
end
def move_card_by_name(text, from:, to:)
@@ -182,14 +187,20 @@ module Pages
target = page.find list_selector(to)
drag_n_drop_element(from: source, to: target)
+ wait_for_lists_reload
+
+ # Wait a little more because the cards sorting order can still be changing
+ # after moving them
+ sleep 2
end
def wait_for_lists_reload
# wait for reload of lists to start and finish
# Not sure if that's the most reliable way to do it, but there is nothing visible
# about the PATCH request being sent and executed successfully after moving a card.
- expect(page).to have_css(".op-loading-indicator", wait: 5)
- expect(page).to have_no_css(".op-loading-indicator")
+ # Use has_css? to not fail if no loading indicator is present at all
+ has_css?(".op-loading-indicator", wait: 2)
+ expect(page).to have_no_css(".op-loading-indicator", wait: 5)
end
def add_list(option: nil, query: option)
@@ -217,8 +228,8 @@ module Pages
def save
page.find(".editable-toolbar-title--save").click
- wait_for_lists_reload
expect_and_dismiss_toaster message: "Successful update."
+ wait_for_lists_reload
end
def expect_changed