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

Fixing flaky spec

Dombi Attilae1ab8638ee2d
diff --git a/modules/overviews/spec/features/managing_overview_page_spec.rb b/modules/overviews/spec/features/managing_overview_page_spec.rb
index ef6c0e839fd..5daddcfd2f2 100644
--- a/modules/overviews/spec/features/managing_overview_page_spec.rb
+++ b/modules/overviews/spec/features/managing_overview_page_spec.rb
@@ -96,11 +96,14 @@ RSpec.describe "Overview page managing", :js do
# within top-left area, add an additional widget
overview_page.add_widget(1, 1, :row, "Work packages table")
-
# Actually there are two success messages displayed currently. One for the grid getting updated and one
# for the query assigned to the new widget being created. A user will not notice it but the automated
- # browser can get confused. Therefore we wait.
- sleep(1)
+ # browser can get confused. Therefore we dismiss it twice.
+ overview_page.expect_and_dismiss_toaster message: I18n.t("js.notice_successful_update")
+
+ # Fixing flaky spec: for some reason, the second request to load the table is not executed until
+ # some activity happens on the page. Sending an enter key to trigger the second request.
+ page.find("body").send_keys(:enter)
overview_page.expect_and_dismiss_toaster message: I18n.t("js.notice_successful_update")
diff --git a/spec/support/components/grids/grid_area.rb b/spec/support/components/grids/grid_area.rb
index cbdaaaa9b1b..97ce5f8e314 100644
--- a/spec/support/components/grids/grid_area.rb
+++ b/spec/support/components/grids/grid_area.rb
@@ -75,6 +75,7 @@ module Components
end
def expect_to_span(startRow, startColumn, endRow, endColumn)
+ expect_to_exist
[["grid-row-start", startRow * 2],
["grid-column-start", startColumn * 2],
["grid-row-end", (endRow * 2) - 1],