diff --git a/app/views/admin/products_v3/_table.html.haml b/app/views/admin/products_v3/_table.html.haml index 1079e28db4..9ffbc22f30 100644 --- a/app/views/admin/products_v3/_table.html.haml +++ b/app/views/admin/products_v3/_table.html.haml @@ -46,7 +46,7 @@ %th.align-right= t('admin.products_page.columns.actions') - products.each_with_index do |product, product_index| = form.fields_for("products", product, index: product_index) do |product_form| - %tbody.relaxed{ 'data-record-id': product_form.object.id } + %tbody.relaxed{ 'data-record-id': product_form.object.id, 'data-controller': "nested-form" } %tr = render partial: 'product_row', locals: { product:, f: product_form } @@ -56,12 +56,14 @@ = render partial: 'variant_row', locals: { variant:, f: variant_form } = form.fields_for("products][#{product_index}][variants_attributes][NEW_RECORD", product.variants.build) do |new_variant_form| - %template + %template{ 'data-nested-form-target': "template" } %tr.condensed = render partial: 'variant_row', locals: { variant: new_variant_form.object, f: new_variant_form } + %tr{ 'data-nested-form-target': "target" } %tr.condensed %td %td{ colspan: 10 } - %button.secondary.condensed.naked.icon-plus{ 'aria-label': t('.new_variant') } + %button.secondary.condensed.naked.icon-plus{ 'data-action': "nested-form#add", + 'aria-label': t('.new_variant') } =t('.new_variant') diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index a35f425858..c170187e3a 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -341,7 +341,7 @@ describe 'As an admin, I can manage products', feature: :admin_style_v3 do describe "adding variants" do it "creates a new variant" do - # click_on "New variant" + click_on "New variant" # find empty row for Apples new_variant_row = find_field("Name", placeholder: "Apples", with: "").ancestor("tr") @@ -357,6 +357,7 @@ describe 'As an admin, I can manage products', feature: :admin_style_v3 do fill_in "On Hand", with: "3" expect { + pending "changes are not detected" click_button "Save changes" expect(page).to have_content "Changes saved" @@ -381,7 +382,7 @@ describe 'As an admin, I can manage products', feature: :admin_style_v3 do context "with invalid data" do before do - # click_on "New variant" + click_on "New variant" # find empty row for Apples new_variant_row = find_field("Name", placeholder: "Apples", with: "").ancestor("tr") @@ -431,12 +432,12 @@ describe 'As an admin, I can manage products', feature: :admin_style_v3 do it "saves changes after fixing errors" do expect { + pending "changes are not detected" click_button "Save changes" variant_a1.reload }.to_not change { variant_a1.display_name } - pending within row_containing_name("N" * 256) do fill_in "Name", with: "Nice box" fill_in "SKU", with: "APL-02"