From a84c0ffd73276cdfc3cb409c4537fa822d3bcdb5 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 23 Apr 2025 19:13:27 +0100 Subject: [PATCH 1/5] Adds test case on pagination for users index page --- spec/system/admin/users_spec.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/spec/system/admin/users_spec.rb b/spec/system/admin/users_spec.rb index 6548dbc558..2d5e3ce081 100644 --- a/spec/system/admin/users_spec.rb +++ b/spec/system/admin/users_spec.rb @@ -128,6 +128,33 @@ RSpec.describe "Managing users" do }.to change { user.reload.show_api_key_view }.to(false) end end + + context "pagination" do + before do + # creates 8 users + 8.times { create(:user) } + visit spree.admin_users_path + end + it "displays pagination" do + # table displays 10 entries + within('tbody') do + expect(page).to have_css('tr', count: 10) + end + within ".pagination" do + expect(page).not_to have_content "Previous" + expect(page).to have_content "Next" + click_on "2" + end + # table displays 1 entry + within('tbody') do + expect(page).to have_css('tr', count: 1) + end + within ".pagination" do + expect(page).to have_content "Previous" + expect(page).not_to have_content "Next" + end + end + end end describe "creating a user" do From c8a91a9d445c977eb1d0fdc59586874cfe000890 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 23 Apr 2025 19:15:13 +0100 Subject: [PATCH 2/5] Fixes deprecation on trailing hashes for sort_link Running the spec was pointing to the following deprecation - Passing two trailing hashes to is deprecated, merge the trailing hashes into a single one. (called at /home/ffurtado/openfoodnetwork/app/views/spree/admin/users/index.html.haml:16) --- app/views/spree/admin/users/index.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/spree/admin/users/index.html.haml b/app/views/spree/admin/users/index.html.haml index 616000fbb3..54d7c80e2d 100644 --- a/app/views/spree/admin/users/index.html.haml +++ b/app/views/spree/admin/users/index.html.haml @@ -13,7 +13,7 @@ %col{ style: "width: 15%" } %thead %tr - %th= sort_link [:spree, @search], :email, t(".user"), {}, {title: "users_email_title"} + %th= sort_link [:spree, @search], :email, t(".user"), title: "users_email_title" %th= sort_link [:spree, @search], :enterprise_limit, t(".enterprise_limit") %th.actions %tbody From e3fff0869e0174210d7280527221d38facae140f Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 23 Apr 2025 19:30:46 +0100 Subject: [PATCH 3/5] Adds test case on pagination for zones index page --- spec/system/admin/configuration/zones_spec.rb | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/spec/system/admin/configuration/zones_spec.rb b/spec/system/admin/configuration/zones_spec.rb index f8d60bcf34..8a282459a1 100644 --- a/spec/system/admin/configuration/zones_spec.rb +++ b/spec/system/admin/configuration/zones_spec.rb @@ -66,4 +66,35 @@ RSpec.describe "Zones" do click_button "Update" expect(page).to have_content("successfully updated!") end + + context "pagination" do + before do + login_as_admin + # creates 16 zones + 16.times { create(:zone) } + visit spree.admin_zones_path + end + it "displays pagination" do + # table displays 15 entries + within('tbody') do + expect(page).to have_css('tr', count: 15) + end + + within ".pagination" do + expect(page).not_to have_content "Previous" + expect(page).to have_content "Next" + click_on "2" + end + + # table displays 1 entry + within('tbody') do + expect(page).to have_css('tr', count: 1) + end + + within ".pagination" do + expect(page).to have_content "Previous" + expect(page).not_to have_content "Next" + end + end + end end From 1d0d294a0914714787c5f7ba354dad02ee8cf903 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Thu, 24 Apr 2025 10:24:13 +0100 Subject: [PATCH 4/5] Adds coverage related to S1 regression #13002 --- spec/system/admin/orders_spec.rb | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index e672166a6c..1b335d1fb3 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -503,22 +503,41 @@ RSpec.describe ' context "pagination" do before do + # creates 15 orders additional to the 4 orders + 15.times { create(:order_ready_to_ship) } login_as_admin visit spree.admin_orders_path end it "displays pagination options" do - # displaying 4 orders (one order per table row) + # displaying 15 orders (one order per table row) within('tbody') do - expect(page).to have_css('tr', count: 4) + expect(page).to have_css('tr', count: 15) end - # pagination options also refer 4 order - expect(page).to have_content "4 Results found. Viewing 1 to 4." + # pagination options refers 19 orders + expect(page).to have_content "19 Results found. Viewing 1 to 15." page.find(".per-page-dropdown .ts-control .item").click # toggling the pagination dropdown expect(page).to have_content "15 per page" expect(page).to have_content "50 per page" expect(page).to have_content "100 per page" end + + it "changes pagination and displays entries" do + within ".pagination" do + expect(page).not_to have_css('button.page.prev') + expect(page).to have_css('button.page.next') + click_on "2" + end + # table displays 4 entries + within('tbody') do + expect(page).to have_css('tr', count: 4) + end + expect(page).to have_content "19 Results found. Viewing 16 to 19." + within ".pagination" do + expect(page).to have_css('button.page.prev') + expect(page).not_to have_css('button.page.next') + end + end end context "with a capturable order" do From 7ed5ca8e1c6715b1b5252ebb3d52aad8f753a876 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 28 Apr 2025 12:23:53 +1000 Subject: [PATCH 5/5] Clarify number of users expected --- spec/system/admin/users_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/system/admin/users_spec.rb b/spec/system/admin/users_spec.rb index 2d5e3ce081..4f228cb1d1 100644 --- a/spec/system/admin/users_spec.rb +++ b/spec/system/admin/users_spec.rb @@ -131,8 +131,9 @@ RSpec.describe "Managing users" do context "pagination" do before do - # creates 8 users + # creates 8 more users 8.times { create(:user) } + expect(Spree::User.count).to eq 11 visit spree.admin_users_path end it "displays pagination" do