mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Adds test-case on the inventory import for unit Items
This commit is contained in:
@@ -333,6 +333,34 @@ feature "Product Import", js: true do
|
||||
expect(page).to have_input "variant-overrides-#{Spree::Product.find_by(name: 'Beets').variants.first.id}-price", with: "3.2"
|
||||
end
|
||||
|
||||
it "handles the Items unit for inventory import" do
|
||||
|
||||
product = create(:simple_product, supplier: enterprise, on_hand: nil, name: 'Aubergine', unit_value: '1', variant_unit_scale: nil, variant_unit: "items", variant_unit_name: "Bag")
|
||||
csv_data = CSV.generate do |csv|
|
||||
csv << ["name", "distributor", "producer", "category", "on_hand", "price", "unit_type", "units", "on_demand", "variant_unit_name"]
|
||||
csv << ["Aubergine", "Another Enterprise", "User Enterprise", "Vegetables", "", "3.3", "kg", "1", "true", "Bag"]
|
||||
end
|
||||
|
||||
File.write('/tmp/test.csv', csv_data)
|
||||
visit main_app.admin_product_import_path
|
||||
select2_select I18n.t('admin.product_import.index.inventories'), from: "settings_import_into"
|
||||
attach_file 'file', '/tmp/test.csv'
|
||||
click_button 'Upload'
|
||||
proceed_to_validation
|
||||
expect(page).to have_selector '.item-count', text: "1"
|
||||
expect(page).to have_no_selector '.invalid-count'
|
||||
expect(page).to have_selector '.inv-create-count', text: '1'
|
||||
save_data
|
||||
|
||||
expect(page).to have_selector '.inv-created-count', text: '1'
|
||||
|
||||
visit main_app.admin_inventory_path
|
||||
|
||||
expect(page).to have_content "Aubergine"
|
||||
expect(page).to have_select "variant-overrides-#{Spree::Product.find_by(name: 'Aubergine').variants.first.id}-on_demand", selected: "Yes"
|
||||
expect(page).to have_input "variant-overrides-#{Spree::Product.find_by(name: 'Aubergine').variants.first.id}-price", with: "3.3"
|
||||
end
|
||||
|
||||
it "handles on_demand and on_hand validations with inventory" do
|
||||
csv_data = CSV.generate do |csv|
|
||||
csv << ["name", "distributor", "producer", "category", "on_hand", "price", "units", "on_demand"]
|
||||
|
||||
Reference in New Issue
Block a user