From 417fd21470ec96df4e1025c815d52f037341e652 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Tue, 11 Jun 2024 14:28:14 -0600 Subject: [PATCH] Adds test to check permissions when creating a new product --- .../system/admin/products_v3/products_spec.rb | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index 3f85a7e64f..1c08741ad0 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -1446,6 +1446,34 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi expect(page).to have_selector row_containing_name(product_supplied_inactive.name) end + + it "allows me to create a product" do + taxon = create(:taxon, name: 'Fruit') + shipping_category = create(:shipping_category) + + visit spree.admin_products_path + + click_link "New Product" + expect(page).to have_content "New Product" + expect(page).to have_select 'product_supplier_id', + with_options: [supplier_managed1.name, supplier_managed2.name, + supplier_permitted.name] + + within 'fieldset#new_product' do + fill_in 'product_name', with: 'Big Bag Of Apples' + select supplier_permitted.name, from: 'product_supplier_id' + select 'Weight (g)', from: 'product_variant_unit_with_scale' + fill_in 'product_unit_value', with: '100' + fill_in 'product_price', with: '10.00' + select taxon.name, from: 'product_primary_taxon_id' + select shipping_category.name, from: 'product_shipping_category_id' + end + click_button 'Create' + + expect(URI.parse(current_url).path).to eq spree.admin_products_path + expect(flash_message).to eq 'Product "Big Bag Of Apples" has been successfully created!' + expect(page).to have_selector row_containing_name('Big Bag Of Apples') + end end def create_products(amount)