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 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 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 diff --git a/spec/system/admin/users_spec.rb b/spec/system/admin/users_spec.rb index 6548dbc558..4f228cb1d1 100644 --- a/spec/system/admin/users_spec.rb +++ b/spec/system/admin/users_spec.rb @@ -128,6 +128,34 @@ RSpec.describe "Managing users" do }.to change { user.reload.show_api_key_view }.to(false) end end + + context "pagination" do + before do + # 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 + # 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