mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-06 02:51:34 +00:00
Click button to add form
Now we can fill out the form, but in most cases we can't submit it because it's not marked as 'changed'.
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user