diff --git a/spec/system/admin/order_cycles/simple_spec.rb b/spec/system/admin/order_cycles/simple_spec.rb index d08e59de61..1e58dd9b91 100644 --- a/spec/system/admin/order_cycles/simple_spec.rb +++ b/spec/system/admin/order_cycles/simple_spec.rb @@ -415,7 +415,16 @@ RSpec.describe ' # toggle the variant box and evaluate the following assertion expect(page).to have_content product.name.upcase - expect(page).to have_content "No variant available for this product" + # we need this assertion here to assure there is enough time to + # toggle the variant box and evaluate the following assertion + expect(page).to have_content product.name + + # iterates between true / false, depending on the test case + expectation = expect_message ? :to : :not_to + expect(page).public_send(expectation, + have_content(%(No variant available for this product + (hidden via inventory settings)).squish)) + end end it "doesn't show a warning when going to 'outgoing products' tab" do diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index c1fbc7dfcb..f564071ba8 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -122,6 +122,86 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi end end + describe "listing" do + let!(:p1) { create(:product) } + let!(:p2) { create(:product) } + + before do + visit admin_products_url + end + + it "displays a list of products" do + within ".products" do + expect(page).to have_field("_products__name", with: p1.name.to_s) + expect(page).to have_field("_products__name", with: p2.name.to_s) + end + end + + it "displays a select box for suppliers, with the appropriate supplier selected" do + pending( "[BUU] Change producer, unit type, category and tax category #11060" ) + 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) + + visit spree.admin_products_path + + expect(page).to have_select "producer_id", with_options: [s1.name, s2.name, s3.name], + selected: s2.name + expect(page).to have_select "producer_id", with_options: [s1.name, s2.name, s3.name], + selected: s3.name + end + + context "with several variants" do + let!(:variant1) { p1.variants.first } + let!(:variant2) { p2.variants.first } + let!(:variant3) { create(:variant, product: p2, on_demand: false, on_hand: 4) } + + before do + variant1.update!(on_hand: 0, on_demand: true) + variant2.update!(on_hand: 16, on_demand: false) + visit spree.admin_products_path + end + + it "displays an on hand count in a span for each product" do + within(:xpath, '//*[@id="products-form"]/table/tbody[1]/tr[1]/td[5]/div') do + expect(page).to have_content "On demand" + end + within(:xpath, '//*[@id="products-form"]/table/tbody[2]/tr[1]/td[5]/div') do + expect(page).to have_content "20" # displays the total stock + end + within(:xpath, '//*[@id="products-form"]/table/tbody[2]/tr[2]/td[5]/div') do + expect(page).to have_content "16" # displays the stock for variant_2 + end + within(:xpath, '//*[@id="products-form"]/table/tbody[2]/tr[3]/td[5]/div') do + expect(page).to have_content "4" # displays the stock for variant_3 + end + end + end + + it "displays a select box for the unit of measure for the product's variants" do + pending( "[BUU] Change producer, unit type, category and tax category #11060" ) + p = FactoryBot.create(:product, variant_unit: 'weight', variant_unit_scale: 1, + variant_unit_name: '') + + visit spree.admin_products_path + + expect(page).to have_select "variant_unit_with_scale", selected: "Weight (g)" + end + + it "displays a text field for the item name when unit is set to 'Items'" do + pending( "[BUU] Change producer, unit type, category and tax category #11060" ) + p = FactoryBot.create(:product, variant_unit: 'items', variant_unit_scale: nil, + variant_unit_name: 'packet') + + visit spree.admin_products_path + + expect(page).to have_select "variant_unit_with_scale", selected: "Items" + expect(page).to have_field "variant_unit_name", with: "packet" + end + end + describe "sorting" do let!(:product_b) { create(:simple_product, name: "Bananas") } let!(:product_a) { create(:simple_product, name: "Apples") } diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index 7af169a6de..eea2a849c6 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -131,14 +131,9 @@ RSpec.describe ' breakpoint.synchronize { "continue after unlocked" } end -<<<<<<< HEAD click_on "Go" expect(page).to have_content "FIRST NAME LAST NAME BILLING ADDRESS EMAIL" -======= - expect(page).to have_selector "#report-table table" - expect(page).to have_content "First Name Last Name Billing Address Email" ->>>>>>> 0a69712a7b (Fixes case on assertions, on failing specs) # Now that we see the report, we need to make sure that it's not replaced # by the "loading" spinner when the controller action finishes.