diff --git a/app/views/admin/products_v3/_table.html.haml b/app/views/admin/products_v3/_table.html.haml index 73b89847d4..d14f073714 100644 --- a/app/views/admin/products_v3/_table.html.haml +++ b/app/views/admin/products_v3/_table.html.haml @@ -27,8 +27,12 @@ .modified_summary{ 'data-bulk-form-target': "changedSummary", 'data-translation-key': 'admin.products_v3.table.changed_summary'} - if defined?(error_counts) .error_summary - -# X products were saved correctly, but Y products could not be saved correctly. Please review errors and try again - = t('.error_summary.saved', count: error_counts[:saved]) + t('.error_summary.invalid', count: error_counts[:invalid]) + - if error_counts[:saved] > 0 + -# X products were saved correctly, but Y products could not be saved correctly. Please review errors and try again + = t('.error_summary.saved', count: error_counts[:saved]) + t('.error_summary.invalid', count: error_counts[:invalid]) + - else + -# Y products could not be saved correctly. Please review errors and try again + = t('.error_summary.invalid', count: error_counts[:invalid]) .form-buttons = form.submit t('.reset'), type: :reset, class: "medium", 'data-reflex': 'click->products#fetch' = form.submit t('.save'), class: "medium" diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index 2ab88a2f29..8c8d2e18de 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -328,6 +328,33 @@ describe 'As an admin, I can manage products', feature: :admin_style_v3 do expect(page).to have_content "Changes saved" end end + + context "when only one product edited with invalid data" do + let!(:product_b) { create(:simple_product, name: "Bananas") } + + before do + within row_containing_name("Apples") do + fill_in "Name", with: "" + fill_in "SKU", with: "A" * 256 + end + end + + it "shows errors for product" do + # Also update another product with valid data + within row_containing_name("Bananas") do + fill_in "Name", with: "Bananes" + end + + expect { + click_button "Save changes" + product_a.reload + }.to_not change { product_a.name } + + expect(page).not_to have_content("0 product was saved correctly, but") + expect(page).to have_content("1 product could not be saved") + expect(page).to have_content "Please review the errors and try again" + end + end end describe "edit image" do