Skip to content

Commit 8ca346f

Browse files
authored
Merge pull request #6480 from NHSDigital/add-pagination-summary-to-vaccination-record-imports
Include a pagination summary in vaccination records imports
2 parents fb9502c + 2cd8724 commit 8ca346f

4 files changed

Lines changed: 50 additions & 3 deletions

app/components/app_patient_table_component.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<%= render AppDetailsComponent.new(expander: true, sticky: true, open: @pagy.page > 1) do |c| %>
22
<% c.with_summary do %>
33
<%= pluralize(@pagy.count, "imported record") %>
4+
<% if @pagy.count > @pagy.limit %>
5+
(showing <b><%= @pagy.from %></b> to <b><%= @pagy.to %></b>)
6+
<% end %>
47
<% end %>
58
<%= govuk_table(html_attributes: { class: "nhsuk-table-responsive", id: anchor }) do |table| %>
69
<% table.with_head do |head| %>

app/components/app_vaccination_record_table_component.html.erb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
<%= render AppDetailsComponent.new(expander: true, sticky: true, open: @pagy.page > 1) do |c| %>
33
<% c.with_summary do %>
44
<%= pluralize(@pagy.count, "imported record") %>
5+
<% if @pagy.count > @pagy.limit %>
6+
(showing <b><%= @pagy.from %></b> to <b><%= @pagy.to %></b>)
7+
<% end %>
58
<% end %>
69
<div class="nhsuk-details__text">
710
<%= govuk_table(html_attributes: { class: "nhsuk-table-responsive" }) do |table| %>

spec/components/app_patient_table_component_spec.rb

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
date_of_birth: Date.new(2000, 5, 28),
2727
address_postcode: "SW1B 1AA"
2828
)
29-
] + create_list(:patient, 8)
29+
] + create_list(:patient, count - 2)
3030
end
3131

3232
let(:pagination_result) { pagy_array(all_patients, page: 1) }
@@ -100,6 +100,26 @@
100100
expect(rendered).not_to have_text("SW1B 1AA")
101101
end
102102

103+
it "does not render pagination summary text" do
104+
expect(rendered).not_to have_content("showing 1 to 10")
105+
end
106+
107+
context "with paginated results" do
108+
let(:count) { 55 }
109+
110+
it "renders 50 rows of data" do
111+
expect(rendered).to have_css(
112+
".nhsuk-table__body .nhsuk-table__row",
113+
count: 50,
114+
visible: :hidden
115+
)
116+
end
117+
118+
it "renders pagination summary text" do
119+
expect(rendered).to have_content("showing 1 to 50")
120+
end
121+
end
122+
103123
context "with a patient not in the cohort" do
104124
it "doesn't render a link" do
105125
expect(rendered).not_to have_link("SMITH, John")

spec/components/app_vaccination_record_table_component_spec.rb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
create(:session, programmes: [programme], date: Date.new(2020, 9, 1))
3030
)
3131
] + create_list(:vaccination_record, 4, programme:) +
32-
create_list(:vaccination_record, 5, :not_administered, programme:)
32+
create_list(:vaccination_record, count - 5, :not_administered, programme:)
3333
end
34+
let(:count) { 10 }
3435

3536
let(:pagination_result) { pagy_array(all_vaccination_records, page: 1) }
3637
let(:vaccination_records) { pagination_result[1] }
@@ -71,7 +72,7 @@
7172
it "renders the rows" do
7273
expect(rendered).to have_css(
7374
".nhsuk-table__body .nhsuk-table__row",
74-
count: 10,
75+
count: count,
7576
visible: :hidden
7677
)
7778
expect(rendered).to have_css(
@@ -97,6 +98,26 @@
9798
)
9899
end
99100

101+
it "does not render pagination summary text" do
102+
expect(rendered).not_to have_content("showing 1 to 10")
103+
end
104+
105+
context "with paginated results" do
106+
let(:count) { 55 }
107+
108+
it "renders 50 rows of data" do
109+
expect(rendered).to have_css(
110+
".nhsuk-table__body .nhsuk-table__row",
111+
count: 50,
112+
visible: :hidden
113+
)
114+
end
115+
116+
it "renders pagination summary text" do
117+
expect(rendered).to have_content("showing 1 to 50")
118+
end
119+
end
120+
100121
context "with a vaccination record not performed by the team" do
101122
before do
102123
vaccination_records.first.patient.patient_locations.destroy_all

0 commit comments

Comments
 (0)