diff --git a/app/views/admin/products_v3/_no_products.html.haml b/app/views/admin/products_v3/_no_products.html.haml index d73659dd5b..fb81197908 100644 --- a/app/views/admin/products_v3/_no_products.html.haml +++ b/app/views/admin/products_v3/_no_products.html.haml @@ -1,6 +1,6 @@ - if search_term.present? || producer_id.present? || category_id.present? = t('.no_products_found_for_search') - %a{ href: admin_products_path, class: "button disruptive relaxed" } + %a{ href: admin_products_path, class: "button disruptive relaxed", 'data-turbo-frame': "_self" } = t("admin.products_v3.sort.pagination.clear_search") - else = t('.no_products_found') diff --git a/spec/system/admin/products_v3/index_spec.rb b/spec/system/admin/products_v3/index_spec.rb index da9593ec9c..add203bcbc 100644 --- a/spec/system/admin/products_v3/index_spec.rb +++ b/spec/system/admin/products_v3/index_spec.rb @@ -269,6 +269,28 @@ RSpec.describe 'As an enterprise user, I can manage my products' do end end + context "product has no searchble term" do + it 'clears search input with no results and returns products list' do + create_products 2 + visit admin_products_url + expect(page).to have_field "search_term", with: "" + expect(page).to have_content "Showing 1 to 2" + + # returns no results, if the product does not exist + search_for "a product which does not exist" + + expect(page).to have_field "search_term", with: "a product which does not exist" + expect(page).to have_content "No products found for your search criteria" + expect_products_count_to_be 0 + + # clears search input and renders product list + click_link "Clear search" + expect(page).to have_content "2 products found for your search criteria. Showing 1 to 2." + expect(page).to have_field "search_term", with: "" + expect_products_count_to_be 2 + end + end + context "product has producer" do before { create_products 1 }