Module: Decidim::FrontEndDataTestHelpers

Defined in:
lib/decidim/dev/test/rspec_support/helpers.rb

Instance Method Summary collapse

Instance Method Details

#paste_content(content, target_selector) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/decidim/dev/test/rspec_support/helpers.rb', line 76

def paste_content(content, target_selector)
  page.execute_script(
    <<~JS
      var dt = new DataTransfer();
      dt.setData("text/html", #{content.to_json});
      dt.setData("text/plain", #{content.to_json});

      var element = document.querySelector("#{target_selector}");
      element.dispatchEvent(new ClipboardEvent("paste", { clipboardData: dt }));
    JS
  )
end