summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorblackst0ne <blackst0ne.ru@gmail.com>2017-07-12 23:45:42 +1100
committerblackst0ne <blackst0ne.ru@gmail.com>2017-07-12 23:45:42 +1100
commit2c8700c01ee31efd49d8bd54e97e4649e84be7f8 (patch)
tree72cc2219bdb4aea5d1c6ba88862373458a9f5ee2 /spec/support
parent2b827d05786a2175281b8f3319570a839b66a627 (diff)
downloadgitlab-ce-2c8700c01ee31efd49d8bd54e97e4649e84be7f8.tar.gz
Replace 'browse_files.feature' spinach test with an rspec analog
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/dropzone_helper.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/support/dropzone_helper.rb b/spec/support/dropzone_helper.rb
index 02fdeb08afe..fe72d320fcf 100644
--- a/spec/support/dropzone_helper.rb
+++ b/spec/support/dropzone_helper.rb
@@ -54,4 +54,23 @@ module DropzoneHelper
loop until page.evaluate_script('window._dropzoneComplete === true')
end
end
+
+ def drop_in_dropzone(file_path)
+ # Generate a fake input selector
+ page.execute_script <<-JS
+ var fakeFileInput = window.$('<input/>').attr(
+ {id: 'fakeFileInput', type: 'file'}
+ ).appendTo('body');
+ JS
+
+ # Attach the file to the fake input selector with Capybara
+ attach_file('fakeFileInput', file_path)
+
+ # Add the file to a fileList array and trigger the fake drop event
+ page.execute_script <<-JS
+ var fileList = [$('#fakeFileInput')[0].files[0]];
+ var e = jQuery.Event('drop', { dataTransfer : { files : fileList } });
+ $('.dropzone')[0].dropzone.listeners[0].events.drop(e);
+ JS
+ end
end