mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #12162 from isidzukuri/12003_improve_error_messageg_when_no_products_are_changed
Improve error message by not displaying the first part of the second …
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user