Skip to content

Commit 2ac292a

Browse files
committed
Hide Records column on imports table if no patients imported
The records count being 0 for imports in review can be misleading. Now that we have separate tabs for imported records and uplaoded files, it is better to hide the Records column entirely. MAV-2720
1 parent 50eb98f commit 2ac292a

2 files changed

Lines changed: 32 additions & 8 deletions

File tree

app/components/app_imports_table_component.html.erb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<% row.with_cell(text: "Imported on") %>
1212
<% row.with_cell(text: "Type") %>
1313
<% row.with_cell(text: "Status") %>
14-
<% row.with_cell(text: "Records", numeric: true) %>
14+
<% row.with_cell(text: "Records", numeric: true) unless @uploaded_files %>
1515
<% end %>
1616
<% end %>
1717

@@ -41,12 +41,10 @@
4141
<%= render AppImportStatusComponent.new(import: import,
4242
break_tag: true) %>
4343
<% end %>
44-
<% row.with_cell(numeric: true) do %>
45-
<span class="nhsuk-table-responsive__heading">Records</span>
46-
<% if import.pending_import? %>
47-
48-
<% else %>
49-
<%= import.record_count %>
44+
<% if import.processed? || import.partially_processed? %>
45+
<% row.with_cell(numeric: true) do %>
46+
<span class="nhsuk-table-responsive__heading">Records</span>
47+
<%= import.patients.count %>
5048
<% end %>
5149
<% end %>
5250
<% end %>

spec/components/app_imports_table_component_spec.rb

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
describe AppImportsTableComponent do
44
subject(:rendered) { render_inline(component) }
55

6-
let(:component) { described_class.new(team:, uploaded_files: false) }
6+
let(:component) { described_class.new(team:, uploaded_files:) }
77

88
let(:programmes) { [Programme.sample] }
99
let(:team) { create(:team, programmes:) }
1010
let(:school) { create(:school, team:, name: "Test School") }
1111
let(:session) { create(:session, programmes:, location: school) }
12+
let(:uploaded_files) { false }
1213

1314
before do
1415
cohort_imports =
@@ -94,4 +95,29 @@
9495
expect(rendered).to have_css(".nhsuk-table__cell", text: "1")
9596
expect(rendered).to have_content("Test School")
9697
end
98+
99+
context "when uploaded_files is false" do
100+
let(:uploaded_files) { true }
101+
102+
before do
103+
CohortImport.destroy_all
104+
ImmunisationImport.destroy_all
105+
ClassImport.destroy_all
106+
create(:cohort_import, status: "pending_import", team:)
107+
end
108+
109+
it "does not show the Records column header" do
110+
rendered =
111+
render_inline(described_class.new(team:, uploaded_files: false))
112+
expect(rendered).not_to have_css(".nhsuk-table__header", text: "Records")
113+
end
114+
115+
it "does not show record counts" do
116+
expect(rendered).to have_css(
117+
".nhsuk-table__body .nhsuk-table__row",
118+
count: 1
119+
)
120+
expect(rendered).not_to have_css(".nhsuk-table__cell", text: /^\d+$/)
121+
end
122+
end
97123
end

0 commit comments

Comments
 (0)