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
primer_view_components-0.30.0 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.39.1 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.39.0 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.38.0 app/lib/primer/test_selector_helper.rb
primer_view_components-0.29.0 app/lib/primer/test_selector_helper.rb
primer_view_components-0.28.0 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.37.1 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.37.0 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.36.2 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.36.1 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.36.0 app/lib/primer/test_selector_helper.rb
primer_view_components-0.27.0 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.35.2 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.35.1 app/lib/primer/test_selector_helper.rb
primer_view_components-0.26.1 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.35.0 app/lib/primer/test_selector_helper.rb
primer_view_components-0.26.0 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.34.0 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.33.2 app/lib/primer/test_selector_helper.rb
openproject-primer_view_components-0.33.1 app/lib/primer/test_selector_helper.rb