mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge pull request #13276 from filipefurtad0/pagy_pagination_spec
Adds coverage to pagination (pagy bump)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user