diff --git a/app/views/admin/products_v3/_table.html.haml b/app/views/admin/products_v3/_table.html.haml index b0bf132b16..d32927aee4 100644 --- a/app/views/admin/products_v3/_table.html.haml +++ b/app/views/admin/products_v3/_table.html.haml @@ -41,8 +41,10 @@ %td.align-left.header = product_form.hidden_field :id = product_form.text_field :name, 'aria-label': t('admin.products_page.columns.name') + = error_message_on product, :name %td.align-right = product_form.text_field :sku, 'aria-label': t('admin.products_page.columns.sku') + = error_message_on product, :sku %td.align-right .content = product.variant_unit.upcase_first diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index 3630f727e3..85bf2e8c39 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -201,7 +201,7 @@ describe 'As an admin, I can see the new product page' do visit admin_products_v3_index_url end - it "can update product and variant fields" do + it "updates product and variant fields" do within row_containing_name("Apples") do fill_in "Name", with: "Pommes" fill_in "SKU", with: "POM-00" @@ -236,7 +236,7 @@ describe 'As an admin, I can see the new product page' do expect(page).to have_content "Changes saved" end - it "can discard changes and reload latest data" do + it "discards changes and reloads latest data" do within row_containing_name("Apples") do fill_in "Name", with: "Pommes" end @@ -262,6 +262,28 @@ describe 'As an admin, I can see the new product page' do expect(page).to have_field "SKU", with: "APL-10" # Updated value shown end end + + it "shows errors for product fields" do + within row_containing_name("Apples") do + fill_in "Name", with: "" + fill_in "SKU", with: "A" * 256 + end + + expect { + click_button "Save changes" + product_a.reload + }.to_not change { product_a.name } + + # (there's no identifier displayed, so the user must remember which product it is..) + within row_containing_name("") do + expect(page).to have_field "Name", with: "" + expect(page).to have_content "can't be blank" + expect(page).to have_field "SKU", with: "A" * 256 + expect(page).to have_content "is too long" + end + pending + expect(page).to have_content "Please review the errors and try again" + end end def expect_page_to_be(page_number)