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 flakiness when checking progress field focus state

Christophe Bliardb676e4b3c6e9
diff --git a/spec/support/edit_fields/progress_edit_field.rb b/spec/support/edit_fields/progress_edit_field.rb
index 6b1693227a5..be72681ed16 100644
--- a/spec/support/edit_fields/progress_edit_field.rb
+++ b/spec/support/edit_fields/progress_edit_field.rb
@@ -184,7 +184,12 @@ class ProgressEditField < EditField
# If they are the same, it means the modal field is in focus.
# @return [Boolean] true if the modal field is in focus, false otherwise.
def expect_modal_field_in_focus
- expect(focused?).to be(true)
+ # Use capybara `synchronize` helper to wait until the modal field is in focus
+ page.document.synchronize do
+ unless focused?
+ raise Capybara::ExpectationNotMet, "Input #{input_element} does not have focus"
+ end
+ end
end
def focused?