Browse Source

Maintenance - Stabilize macro batches drag action in Capybara tests.

Dusan Vuckovic 2 years ago
parent
commit
833659d7d7
2 changed files with 16 additions and 7 deletions
  1. 14 7
      spec/support/capybara/browser_test_helper.rb
  2. 2 0
      spec/system/search_spec.rb

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

@@ -155,14 +155,21 @@ module BrowserTestHelper
   # display_macro_batches(Ticket.first)
   #
   def display_macro_batches(ticket)
-    # get DOM element
+
+    # Get the ticket row 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 + 3)
-    # move a bit to the left to display macro batches
-    move_mouse_by(-element.location.x + 3, 0)
+
+    # Drag the element to the top of the screen, in order to display macro batches.
+    #  First, move the mouse to the middle left part of the element to avoid popups interfering with the action.
+    #  Then, click and hold the left mouse button.
+    #  Next, move the mouse vertically, just below the top edge of the browser.
+    #  Finally, move the mouse slightly horizontally to simulate a non-linear drag.
+    page.driver.browser.action
+      .move_to_location(element.location.x + 50, element.location.y + 10)
+      .click_and_hold
+      .move_by(0, -element.location.y + 3)
+      .move_by(3, 0)
+      .perform
   end
 
   # Releases the depressed left mouse button at the current mouse location.

+ 2 - 0
spec/system/search_spec.rb

@@ -163,6 +163,8 @@ RSpec.describe 'Search', type: :system, authenticated: true, searchindex: true d
       click_on 'Show Search Details'
 
       find('[data-tab-content=Ticket]').click
+
+      await_empty_ajax_queue
     end
 
     describe 'group-dependent macros' do