Skip to content

Commit

Permalink
12570 - add specs
Browse files Browse the repository at this point in the history
  • Loading branch information
chahmedejaz committed Jul 12, 2024
1 parent 0986971 commit d835429
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/views/admin/products_v3/_variant_row.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
value: unit_value_with_description(variant), '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
= f.text_field :display_as, 'aria-label': t('admin.products_page.columns.display_as'), placeholder: VariantUnits::OptionValueNamer.new(variant).name
= error_message_on variant, :unit_value
%td.col-price.field.naked_inputs
= f.text_field :price, 'aria-label': t('admin.products_page.columns.price'), value: number_to_currency(variant.price, unit: '')&.strip # TODO: add a spec to prove that this formatting is necessary. If so, it should be in a shared form helper for currency inputs
Expand Down
20 changes: 20 additions & 0 deletions spec/system/admin/products_v3/create_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
expect(page).to have_content "New variant"
end

it "has the 1 unit value for the new variant display_as by default" do
new_variant_button.click

within new_variant_row do
unit_button = find('button[aria-label="Unit"]')
expect(unit_button.text.strip).to eq('1kg')

unit_button.click
find('input[aria-label="Display unit as"][placeholder="1kg"]')
end
end

shared_examples "creating a new variant (bulk)" do |stock|
it "handles the #{stock} behaviour" do
# the product and the default variant is displayed
Expand Down Expand Up @@ -120,4 +132,12 @@ def visit_products_page_as_admin
login_as_admin
visit spree.admin_products_path
end

def new_variant_button
find("button.secondary.condensed.naked.icon-plus")
end

def new_variant_row
'tr[data-new-record="true"]'
end
end

0 comments on commit d835429

Please sign in to comment.