Prevent submitting empty value

This commit is contained in:
David Cook
2024-03-26 11:10:29 +11:00
parent 49226ffdbc
commit cf31d09ad8
2 changed files with 4 additions and 4 deletions

View File

@@ -20,7 +20,7 @@
-# todo: create a method for value_with_description
= f.text_field :unit_value_with_description,
value: [number_with_precision(variant.unit_value, precision: nil,strip_insignificant_zeros: true), variant.unit_description].compact_blank.join(" "),
'aria-label': t('admin.products_page.columns.unit_value')
'aria-label': t('admin.products_page.columns.unit_value'), required: true
.field
= f.label :display_as, t('admin.products_page.columns.display_as')
= f.text_field :display_as, placeholder: VariantUnits::OptionValueNamer.new(variant).name

View File

@@ -192,9 +192,9 @@ describe 'As an admin, I can manage products', feature: :admin_style_v3 do
# Unit popout
# TODO: prevent empty value
# fill_in "Unit value", with: ""
# click_button "Save changes" # attempt to save or close the popout
# expect(page).to have_field "Unit value", with: "" # popout is still open
fill_in "Unit value", with: ""
click_button "Save changes" # attempt to save or close the popout
expect(page).to have_field "Unit value", with: "" # popout is still open
fill_in "Unit value", with: "500.1"
within row_containing_name("Medium box") do