From 5085501f8975b44a9c14b483544e23ca61eb010b Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Tue, 27 Apr 2021 11:24:22 +0200 Subject: [PATCH] Add automated tests around pagination in product list for a shop - with two order cycles and go from one to the other --- .../consumer/shopping/shopping_spec.rb | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/features/consumer/shopping/shopping_spec.rb b/spec/features/consumer/shopping/shopping_spec.rb index 3be9aa346e..c0ec640554 100644 --- a/spec/features/consumer/shopping/shopping_spec.rb +++ b/spec/features/consumer/shopping/shopping_spec.rb @@ -159,6 +159,31 @@ feature "As a consumer I want to shop with a distributor", js: true do end end end + + describe "two order cycles and more than 20 products for each" do + before do + 20.times do + product = create(:simple_product, supplier: supplier) + add_variant_to_order_cycle(exchange1, product.variants.first) + add_variant_to_order_cycle(exchange2, product.variants.first) + end + end + + it "show the whole products list for each OC" do + visit shop_path + select "turtles", from: "order_cycle_id" + select "frogs", from: "order_cycle_id" + expect(page).to have_selector("product", count: 10) + scroll_to(page.find(".product-listing"), align: :bottom) + expect(page).to have_selector("product", count: 20) + + scroll_to(page.find("distributor")) + select "turtles", from: "order_cycle_id" + expect(page).to have_selector("product", count: 10) + scroll_to(page.find(".product-listing"), align: :bottom) + expect(page).to have_selector("product", count: 20) + end + end end end