Sha256: 9625b6c5e8ceb14515b57370a28b017b294cb702ce43105bb8e29845ed0c81aa

Contents?: true

Size: 897 Bytes

Versions: 18

Compression:

Stored size: 897 Bytes

Contents

# frozen_string_literal: true

module FormHelpers
  def setup_form_tracking(driver)
    driver.execute_script <<~JS
      window.lastSubmittedForm = null;

      document.addEventListener('submit', (e) => {
        if (!e.target.hasAttribute('data-turbo-frame')) {
          e.preventDefault();
        }

        window.lastSubmittedForm = e.target.id;
      });
    JS
  end
end

RSpec.configure do |config|
  config.include FormHelpers, type: :feature
end

RSpec::Matchers.define :be_invalid do
  match do |element|
    element[:validity] == 'false' ||
      element.evaluate_script('!this.validity.valid')
  end
end

RSpec::Matchers.define :have_been_submitted do
  match do |form|
    page.evaluate_script('window.lastSubmittedForm') == form['id']
  end
end

RSpec::Matchers.define :have_invisible_textarea do
  match do |element|
    element.has_css?('textarea', visible: :hidden)
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/ckeditor5-1.24.9/spec/e2e/support/form_helpers.rb
ckeditor5-1.24.9 spec/e2e/support/form_helpers.rb
ckeditor5-1.24.8 spec/e2e/support/form_helpers.rb
ckeditor5-1.24.6 spec/e2e/support/form_helpers.rb
ckeditor5-1.24.5 spec/e2e/support/form_helpers.rb
ckeditor5-1.24.4 spec/e2e/support/form_helpers.rb
ckeditor5-1.24.3 spec/e2e/support/form_helpers.rb
ckeditor5-1.24.2 spec/e2e/support/form_helpers.rb
ckeditor5-1.24.1 spec/e2e/support/form_helpers.rb
ckeditor5-1.24.0 spec/e2e/support/form_helpers.rb
ckeditor5-1.23.5 spec/e2e/support/form_helpers.rb
ckeditor5-1.23.4 spec/e2e/support/form_helpers.rb
ckeditor5-1.23.3 spec/e2e/support/form_helpers.rb
ckeditor5-1.23.2 spec/e2e/support/form_helpers.rb
ckeditor5-1.23.1 spec/e2e/support/form_helpers.rb
ckeditor5-1.23.0 spec/e2e/support/form_helpers.rb
ckeditor5-1.22.0 spec/e2e/support/form_helpers.rb
ckeditor5-1.21.0 spec/e2e/support/form_helpers.rb