Initial commit
This commit is contained in:
18
spec/support/dropzone_helper.rb
Normal file
18
spec/support/dropzone_helper.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
module DropzoneHelper
|
||||
def drop_file(file_path, type:)
|
||||
page.execute_script <<-JS
|
||||
fakeFileInput = window.$('<input/>').attr(
|
||||
{id: 'fakeFileInput', type:'file'}
|
||||
).appendTo('body');
|
||||
JS
|
||||
attach_file("fakeFileInput", file_path)
|
||||
page.execute_script <<-JS
|
||||
var e = jQuery.Event('drop', { dataTransfer : { files : [fakeFileInput.get(0).files[0]] } });
|
||||
$("[data-behavior=#{type}]")[0].dropzone.listeners[0].events.drop(e);
|
||||
JS
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.include DropzoneHelper
|
||||
end
|
||||
Reference in New Issue
Block a user