Browse Source

Maintenance: Fix test instability in ticket search

Bola Ahmed Buari 2 years ago
parent
commit
ec4ad0cb60
1 changed files with 14 additions and 8 deletions
  1. 14 8
      spec/support/capybara/browser_test_helper.rb

+ 14 - 8
spec/support/capybara/browser_test_helper.rb

@@ -155,14 +155,20 @@ module BrowserTestHelper
   # display_macro_batches(Ticket.first)
   #
   def display_macro_batches(ticket)
-    # get DOM element
-    element = page.find(:table_row, ticket.id).native
-    # get element moving
-    click_and_hold(element)
-    # move element to y -ticket.location.y
-    move_mouse_by(0, -element.location.y + 5)
-    # move a bit to the left to display macro batches
-    move_mouse_by(-250, 0)
+    10.times do
+      # get DOM element
+      element = page.find(:table_row, ticket.id).native
+      # get element moving
+      click_and_hold(element)
+      # move element to y -ticket.location.y
+      move_mouse_by(0, -element.location.y + 5)
+      # move a bit to the left to display macro batches
+      move_mouse_by(-250, 0)
+
+      break if page.find_all('.batch-overlay-macro-entry', allow_reload: true).any?
+
+      sleep 0.2
+    end
   end
 
   # Releases the depressed left mouse button at the current mouse location.