Sha256: 2a5a40896a866b36d83ee395650ce1d24db6efa6d78e12095c30b81064738a91

Contents?: true

Size: 558 Bytes

Versions: 194

Compression:

Stored size: 558 Bytes

Contents

# frozen_string_literal: true

module Primer
  # Module to allow components to deal with the `test_selector` argument.
  # It will only add the selector if env is not Production.
  #
  # test_selector: "foo" => data-test-selector="foo"
  module TestSelectorHelper
    TEST_SELECTOR_TAG = :test_selector

    def add_test_selector(args)
      if args.key?(TEST_SELECTOR_TAG) && !Rails.env.production?
        args[:data] ||= {}
        args[:data][TEST_SELECTOR_TAG] = args[TEST_SELECTOR_TAG]
      end

      args.except(TEST_SELECTOR_TAG)
    end
  end
end

Version data entries

194 entries across 194 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.33.0 app/lib/primer/test_selector_helper.rb
primer_view_components-0.25.1 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.32.1 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.32.0 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.29.1 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.29.0 app/lib/primer/test_selector_helper.rb
primer_view_components-0.23.0 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.28.1 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.28.0 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.27.0 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.26.0 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.25.1 app/lib/primer/test_selector_helper.rb
primer_view_components-0.22.0 app/lib/primer/test_selector_helper.rb
primer_view_components-0.21.1 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.25.0 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.24.0 app/lib/primer/test_selector_helper.rb
primer_view_components-0.21.0 app/lib/primer/test_selector_helper.rb
primer_view_components-0.20.1 app/lib/primer/test_selector_helper.rb
primer_view_components-0.20.0 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.23.0 app/lib/primer/test_selector_helper.rb