mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-09 03:20:21 +00:00
Remove errored variants
I found another case.
This commit is contained in:
@@ -71,7 +71,7 @@
|
||||
|
||||
- product.variants.each_with_index do |variant, variant_index|
|
||||
= form.fields_for("products][#{product_index}][variants_attributes][", variant, index: variant_index) do |variant_form|
|
||||
%tr.condensed{ 'data-controller': "variant" }
|
||||
%tr.condensed{ 'data-controller': "variant", 'class': "nested-form-wrapper", 'data-new-record': variant.new_record? ? "true" : false }
|
||||
= render partial: 'variant_row', locals: { variant:, f: variant_form, category_options:, tax_category_options: }
|
||||
|
||||
= form.fields_for("products][#{product_index}][variants_attributes][NEW_RECORD", product.variants.build) do |new_variant_form|
|
||||
|
||||
@@ -735,6 +735,22 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi
|
||||
expect(new_variant.price).to eq 10.25
|
||||
expect(new_variant.unit_value).to eq 200
|
||||
end
|
||||
|
||||
it "removes unsaved record" do
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_text("1 product could not be saved.")
|
||||
|
||||
within row_containing_name("N" * 256) do
|
||||
page.find(".vertical-ellipsis-menu").click
|
||||
page.find('a', text: 'Remove').click
|
||||
end
|
||||
|
||||
# Now that invalid variant is removed, we can proceed to save
|
||||
click_button "Save changes"
|
||||
expect(page).not_to have_text("1 product could not be saved.")
|
||||
expect(page).not_to have_css('form.disabled-section#filters')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user