diff --git a/spec/support/products_helper.rb b/spec/support/products_helper.rb index f9baececed..518aa45257 100644 --- a/spec/support/products_helper.rb +++ b/spec/support/products_helper.rb @@ -3,7 +3,7 @@ module ProductsHelper def create_products(amount) amount.times do |i| - create(:simple_product, name: "product #{i}", supplier: producer) + create(:simple_product, name: "product #{i}", supplier_id: producer.id) end end @@ -41,6 +41,13 @@ module ProductsHelper "tr:has(input[aria-label=Name][value='#{value}'])" end + # Selector for table row that has an input with a placeholder. + # Variant don't have display_name set, so we look for the input with placeholder matching the + # product's name to get the variant row + def row_containing_placeholder(value) + "tr:has(input[aria-label=Name][placeholder='#{value}'])" + end + # Wait for an element with the given CSS selector and class to be present def wait_for_class(selector, class_name) max_wait_time = Capybara.default_max_wait_time diff --git a/spec/system/admin/products_spec.rb b/spec/system/admin/products_spec.rb index cfbe4d3d2b..5a74e7972a 100644 --- a/spec/system/admin/products_spec.rb +++ b/spec/system/admin/products_spec.rb @@ -255,12 +255,12 @@ RSpec.describe ' describe "deleting" do let!(:product1) { - create(:simple_product, name: 'a product to keep', supplier_id: @supplier.id) + create(:simple_product, name: 'a product to keep', supplier_id: supplier.id) } context 'a simple product' do let!(:product2) { - create(:simple_product, name: 'a product to delete', supplier_id: @supplier.id + create(:simple_product, name: 'a product to delete', supplier_id: supplier.id) } before do @@ -311,7 +311,7 @@ RSpec.describe ' describe 'cloning' do let!(:product1) { - create(:simple_product, name: 'a weight product', supplier_id: @supplier.id, + create(:simple_product, name: 'a weight product', supplier_id: supplier.id, variant_unit: "weight") } diff --git a/spec/system/admin/products_v3/index_spec.rb b/spec/system/admin/products_v3/index_spec.rb index 23b678138e..264bdad71c 100644 --- a/spec/system/admin/products_v3/index_spec.rb +++ b/spec/system/admin/products_v3/index_spec.rb @@ -53,8 +53,8 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi s1 = FactoryBot.create(:supplier_enterprise) s2 = FactoryBot.create(:supplier_enterprise) s3 = FactoryBot.create(:supplier_enterprise) - p1 = FactoryBot.create(:product, supplier: s2) - p2 = FactoryBot.create(:product, supplier: s3) + p1 = FactoryBot.create(:product, supplier_id: s2.id) + p2 = FactoryBot.create(:product, supplier_id: s3.id) visit spree.admin_products_path @@ -269,7 +269,9 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi # create a product with a different supplier let!(:producer1) { create(:supplier_enterprise, name: "Producer 1") } - let!(:product_by_supplier) { create(:simple_product, name: "Apples", supplier: producer1) } + let!(:product_by_supplier) { + create(:simple_product, name: "Apples", supplier_id: producer1.id) + } before { user.enterprise_roles.create(enterprise: producer1) } diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index 835c6c8a4c..62de258992 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -418,7 +418,7 @@ RSpec.describe ' expect(page).to have_table_row ["Supplier", "Producer Suburb", "Product", "Product Properties", "Taxons", "Variant Value", "Price", "Group Buy Unit Quantity", "Amount", "SKU", - "On Demand?", "On hand"] + "On Demand?", "On Hand"] expect(page).to have_table_row [supplier.name, supplier.address.city, "Product Name", product1.properties.map(&:presentation).join(", "),