diff --git a/app/components/bulk_upload_error_summary_table_component.html.erb b/app/components/bulk_upload_error_summary_table_component.html.erb index 2f9643271..ab5254c0f 100644 --- a/app/components/bulk_upload_error_summary_table_component.html.erb +++ b/app/components/bulk_upload_error_summary_table_component.html.erb @@ -1,3 +1,7 @@ +

+ <%= intro %> +

+ <% sorted_errors.each do |error| %> <%= govuk_table do |table| %> <% table.head do |head| %> diff --git a/app/components/bulk_upload_error_summary_table_component.rb b/app/components/bulk_upload_error_summary_table_component.rb index 95f656cae..7b483077f 100644 --- a/app/components/bulk_upload_error_summary_table_component.rb +++ b/app/components/bulk_upload_error_summary_table_component.rb @@ -24,6 +24,14 @@ class BulkUploadErrorSummaryTableComponent < ViewComponent::Base sorted_errors.present? end + def intro + if setup_errors.present? + "This summary shows important questions that have errors. See full error report for more details." + else + "This summary shows questions that have more than #{BulkUploadErrorSummaryTableComponent::DISPLAY_THRESHOLD - 1} errors. See full error report for more details." + end + end + private def setup_errors @@ -31,7 +39,6 @@ private .bulk_upload_errors .where(category: "setup") .group(:col, :field, :error) - .having("count(*) >= ?", display_threshold) .count .sort_by { |el| el[0][0].rjust(3, "0") } end diff --git a/app/mailers/bulk_upload_mailer.rb b/app/mailers/bulk_upload_mailer.rb index 1a1d0848d..b6388213a 100644 --- a/app/mailers/bulk_upload_mailer.rb +++ b/app/mailers/bulk_upload_mailer.rb @@ -72,25 +72,12 @@ class BulkUploadMailer < NotifyMailer end def send_bulk_upload_failed_file_setup_error_mail(bulk_upload:) - bulk_upload_link = if bulk_upload.lettings? - start_bulk_upload_lettings_logs_url + bulk_upload_link = if BulkUploadErrorSummaryTableComponent.new(bulk_upload:).errors? + summary_bulk_upload_lettings_result_url(bulk_upload) else - start_bulk_upload_sales_logs_url + bulk_upload_lettings_result_url(bulk_upload) end - row_parser_class = bulk_upload.prefix_namespace::RowParser - - errors = bulk_upload - .bulk_upload_errors - .where(category: "setup") - .group(:col, :field) - .count - .keys - .sort_by { |_col, field| field } - .map do |col, field| - "- #{row_parser_class.question_for_field(field.to_sym)} (Column #{col})" - end - send_email( bulk_upload.user.email, FAILED_FILE_SETUP_ERROR_TEMPLATE_ID, @@ -99,7 +86,6 @@ class BulkUploadMailer < NotifyMailer upload_timestamp: bulk_upload.created_at.to_fs(:govuk_date_and_time), lettings_or_sales: bulk_upload.log_type, year_combo: bulk_upload.year_combo, - errors_list: errors.join("\n"), bulk_upload_link:, }, ) diff --git a/app/views/bulk_upload_lettings_results/summary.html.erb b/app/views/bulk_upload_lettings_results/summary.html.erb index a4adbc5cb..533e2af05 100644 --- a/app/views/bulk_upload_lettings_results/summary.html.erb +++ b/app/views/bulk_upload_lettings_results/summary.html.erb @@ -16,10 +16,6 @@
<%= govuk_tabs(title: "Error reports") do |c| %> <% c.with_tab(label: "Summary") do %> -

- This summary shows questions that have more than <%= BulkUploadErrorSummaryTableComponent::DISPLAY_THRESHOLD - 1 %> errors. See full error report for more details. -

- <%= render BulkUploadErrorSummaryTableComponent.new(bulk_upload: @bulk_upload) %> <% end %> diff --git a/spec/components/bulk_upload_error_summary_table_component_spec.rb b/spec/components/bulk_upload_error_summary_table_component_spec.rb index 73bfa908b..79be32901 100644 --- a/spec/components/bulk_upload_error_summary_table_component_spec.rb +++ b/spec/components/bulk_upload_error_summary_table_component_spec.rb @@ -41,6 +41,12 @@ RSpec.describe BulkUploadErrorSummaryTableComponent, type: :component do result = render_inline(component) expect(result).to have_selector("table", count: 1) end + + it "renders intro with threshold" do + result = render_inline(component) + + expect(result).to have_content("This summary shows questions that have more than 0 errors. See full error report for more details.") + end end context "when there are 2 independent errors" do @@ -112,6 +118,8 @@ RSpec.describe BulkUploadErrorSummaryTableComponent, type: :component do before do create(:bulk_upload_error, bulk_upload:, col: "B", row: 2, category: nil) + + stub_const("BulkUploadErrorSummaryTableComponent::DISPLAY_THRESHOLD", 16) end it "only returns the setup errors" do @@ -130,6 +138,12 @@ RSpec.describe BulkUploadErrorSummaryTableComponent, type: :component do "1 error", ]) end + + it "renders intro with setup errors" do + result = render_inline(component) + + expect(result).to have_content("This summary shows important questions that have errors. See full error report for more details.") + end end end