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
