gitlab-org--gitlab-foss/spec/support/helpers/drag_to_helper.rb

16 lines
629 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-01-06 16:52:18 +00:00
module DragTo
def drag_to(list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0, selector: '', scrollable: 'body', duration: 1000)
evaluate_script("simulateDrag({scrollable: $('#{scrollable}').get(0), duration: #{duration}, from: {el: $('#{selector}').eq(#{list_from_index}).get(0), index: #{from_index}}, to: {el: $('#{selector}').eq(#{list_to_index}).get(0), index: #{to_index}}});")
2017-01-06 16:52:18 +00:00
Timeout.timeout(Capybara.default_max_wait_time) do
2017-04-04 17:47:12 +00:00
loop while drag_active?
2017-01-06 16:52:18 +00:00
end
end
def drag_active?
2017-04-04 17:47:12 +00:00
page.evaluate_script('window.SIMULATE_DRAG_ACTIVE').nonzero?
2017-01-06 16:52:18 +00:00
end
end