Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12570 - Fix Variant Unit field is Out of Sync with the Pop-out #12602

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
dacook marked this conversation as resolved.
Show resolved Hide resolved
= 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"]')
dacook marked this conversation as resolved.
Show resolved Hide resolved
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
dacook marked this conversation as resolved.
Show resolved Hide resolved

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