diff --git a/app/jobs/report_job.rb b/app/jobs/report_job.rb index efa09420ba..c9ea5353fd 100644 --- a/app/jobs/report_job.rb +++ b/app/jobs/report_job.rb @@ -47,10 +47,14 @@ class ReportJob < ApplicationJob end def broadcast_error(channel) - cable_ready[channel].inner_html( - selector: "#report-table", - html: I18n.t("report_job.report_failed") - ).broadcast + cable_ready[channel] + .inner_html( + selector: "#report-go", + html: Spree::Admin::BaseController.helpers.button(I18n.t(:go), "report__submit-btn") + ).inner_html( + selector: "#report-table", + html: I18n.t("report_job.report_failed") + ).broadcast end def actioncable_content(format, blob) diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index 2d689ff7a0..7a451de56e 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -347,6 +347,31 @@ RSpec.describe ' variant3.update!(sku: "") end + it "shows report error at the bottom of page" do + login_as_admin + visit admin_reports_path + + click_link 'All products' + report = Reporting::Reports::ProductsAndInventory::AllProducts + + click_on "Go" + + allow(report).to receive(:new).and_raise(StandardError, 'Provoked error for testing') + perform_enqueued_jobs(only: ReportJob) + + expect(page).not_to have_selector ".loading" + expect(page).to have_button "Go", disabled: false + expect(page).to have_content 'This report failed. It may be too big to process. ' \ + 'We will look into it but please let us know ' \ + 'if the problem persists.' + + # Admin shoulb be able to make some changes and retry + allow(report).to receive(:new).and_call_original + + run_report + expect(page).to have_content "Supplier" + end + it "shows products and inventory report" do login_as_admin visit admin_reports_path