From c8a20458c82811b4a329c1f310c08c0ce467b396 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Thu, 22 Aug 2019 18:54:32 +0200 Subject: Reformat script in DragTo helper --- spec/support/helpers/drag_to_helper.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/spec/support/helpers/drag_to_helper.rb b/spec/support/helpers/drag_to_helper.rb index 6099f87323f..6883f8afe8b 100644 --- a/spec/support/helpers/drag_to_helper.rb +++ b/spec/support/helpers/drag_to_helper.rb @@ -2,7 +2,21 @@ 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}}});") + js = <<~JS + 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} + } + }); + JS + evaluate_script(js) Timeout.timeout(Capybara.default_max_wait_time) do loop while drag_active? -- cgit v1.2.1