Fixes button staying disabled after report fail

- added a test
This commit is contained in:
cyrillefr
2025-04-01 17:23:19 +02:00
parent a7c77dc894
commit f0a5c76b45
3 changed files with 29 additions and 4 deletions

View File

@@ -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)

View File

@@ -13,6 +13,19 @@ module ReportsHelper
expect(page).to have_button "Go", disabled: false
end
def run_failed_report(report)
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.'
end
def generate_report
run_report
click_on "Download Report"

View File

@@ -347,6 +347,14 @@ 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'
run_failed_report(Reporting::Reports::ProductsAndInventory::AllProducts)
end
it "shows products and inventory report" do
login_as_admin
visit admin_reports_path