Sha256: 0b146241f9b275d16b33c840ce6370d6db855de550cbe939dbcfdf451b917c34

Contents?: true

Size: 1021 Bytes

Versions: 8

Compression:

Stored size: 1021 Bytes

Contents

# frozen_string_literal: true

module Capybara
  module DataConsent
    # Update data consent
    def data_consent(categories = "all", options = {})
      visit decidim.root_path if options[:visit_root]

      dialog_present = begin
        find("#dc-dialog-wrapper")
      rescue Capybara::ElementNotFound => _e
        false
      end

      if dialog_present
        click_button "Settings"
      else
        within "footer" do
          click_link "Cookie settings"
        end
      end

      if [true, "all"].include?(categories)
        click_button "Accept all"
      elsif categories.is_a?(Array)
        categories.each do |category|
          within "[data-id='#{category}']" do
            find(".cookies__category-toggle").click
          end
        end
        click_button "Save settings"
      elsif [false, "essential"].include?(categories)
        click_button "Accept only essential"
      end
    end
  end
end

RSpec.configure do |config|
  config.include Capybara::DataConsent, type: :system
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
decidim-dev-0.28.5 lib/decidim/dev/test/rspec_support/data_consent.rb
decidim-dev-0.28.4 lib/decidim/dev/test/rspec_support/data_consent.rb
decidim-dev-0.28.3 lib/decidim/dev/test/rspec_support/data_consent.rb
decidim-dev-0.28.2 lib/decidim/dev/test/rspec_support/data_consent.rb
decidim-dev-0.28.1 lib/decidim/dev/test/rspec_support/data_consent.rb
decidim-dev-0.28.0 lib/decidim/dev/test/rspec_support/data_consent.rb
decidim-dev-0.28.0.rc5 lib/decidim/dev/test/rspec_support/data_consent.rb
decidim-dev-0.28.0.rc4 lib/decidim/dev/test/rspec_support/data_consent.rb