Sha256: 846888ceae3627cf51b207336c32a56303f765e6e00ea623671ae04c6ff5a7aa

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

require 'test_helper'

module Workarea
  module Storefront
    class SearchAutocompleteIntegrationTest < Workarea::IntegrationTest
      def test_autocomplete
        test_one = create_product(name: 'Test One')
        test_two = create_product(name: 'Test Two')
        create_search_by_week(query_string: 'test one', searches: 5, total_results: 5)
        create_search_by_week(query_string: 'test two', searches: 10, total_results: 5)

        get storefront.autocomplete_search_path(q: '')
        assert(response.ok?)

        get storefront.autocomplete_search_path(q: 'tes')
        assert(response.ok?)
        assert_match(/test two.*test one/m, response.body)
        assert_includes(response.body, storefront.product_path(test_two))
        refute_includes(response.body, storefront.product_path(test_one))

        get storefront.autocomplete_search_path(q: 'TeS')
        assert(response.ok?)
        assert_match(/test two.*test one/m, response.body)
        assert_includes(response.body, storefront.product_path(test_two))
        refute_includes(response.body, storefront.product_path(test_one))
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-search_autocomplete-1.0.2 test/integration/workarea/storefront/search_autocomplete_integration_test.rb
workarea-search_autocomplete-1.0.1 test/integration/workarea/storefront/search_autocomplete_integration_test.rb
workarea-search_autocomplete-1.0.0 test/integration/workarea/storefront/search_autocomplete_integration_test.rb