mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
Fix flaky spec
failing spec: `modules/boards/spec/features/action_boards/status_type_moving_board_spec.rb:112` failing job: https://github.com/opf/openproject/actions/runs/17290621432/job/49076891042?pr=20077 It fails because it moves the wrong card to the "Open" column. It tries to locate the card by its text, and when it decides to move it, the card order changes (no idea why) and both cards are swapped, resulting on the wrong card being moved. Then the spec fails as it expects the card to be in the other column but actually it did not move. Sometimes, the spec passes because the card order has not changed yet when the cards are located and moved, or the card order has already changed before the cards are located and moved. Who knows. Fix is to wait for the lists to properly reload after a save and moving cards, and in the case of moving cards, it waits a little 2 secs more just in case the order changes. It may not be reliable.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user