From 500b9ed1c768571325979c3f322e1d22b35f14b8 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Tue, 10 Oct 2023 12:04:38 +0100 Subject: [PATCH 01/42] Enables admin_style_v3 toggle by default --- spec/base_spec_helper.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/base_spec_helper.rb b/spec/base_spec_helper.rb index 8a6e29a22e..1b156768fb 100644 --- a/spec/base_spec_helper.rb +++ b/spec/base_spec_helper.rb @@ -148,6 +148,9 @@ RSpec.configure do |config| config.before(:each) do Flipper.features.each(&:remove) OpenFoodNetwork::FeatureToggle.setup! + + # activate feature toggle admin_style_v3 to use new admin interface and run the build + Flipper.enable(:admin_style_v3) end config.before(:each, :feature) do |example| From 308c559810ff27aa70a7385171b891aad91e8775 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Thu, 12 Oct 2023 11:44:19 +0100 Subject: [PATCH 02/42] Fixes case on assertions, on failing specs Selects white_label tab with trigger(click) Scrolling down did no fix it, it still fails https://github.com/openfoodfoundation/openfoodnetwork/actions/runs/6526149195/job/17719815533?pr=11645, selecting the element with trigger(click) should work Updates invoice tests --- spec/support/features/datepicker_helper.rb | 2 +- spec/system/admin/authentication_spec.rb | 4 +- .../admin/bulk_order_management_spec.rb | 46 +++--- spec/system/admin/bulk_product_update_spec.rb | 28 ++-- .../configuration/general_settings_spec.rb | 2 +- spec/system/admin/customers_spec.rb | 4 +- spec/system/admin/enterprises_spec.rb | 143 ++++++++++-------- spec/system/admin/flatpickr_spec.rb | 4 +- ...lex_editing_multiple_product_pages_spec.rb | 2 +- .../complex_editing_multiple_updation_spec.rb | 2 +- .../order_cycles/complex_editing_spec.rb | 2 +- spec/system/admin/order_cycles/list_spec.rb | 2 +- spec/system/admin/order_cycles/simple_spec.rb | 4 +- spec/system/admin/order_spec.rb | 21 +-- spec/system/admin/orders_spec.rb | 34 ++--- spec/system/admin/overview_spec.rb | 2 +- spec/system/admin/product_import_spec.rb | 4 +- ...mmary_fee_with_tax_report_by_order_spec.rb | 4 +- ...ry_fee_with_tax_report_by_producer_spec.rb | 2 +- .../reports/orders_and_fulfillment_spec.rb | 7 - .../admin/reports/packing_report_spec.rb | 6 +- .../admin/reports/payments_report_spec.rb | 4 +- .../admin/reports/revenues_by_hub_spec.rb | 34 ++--- .../sales_tax_totals_by_order_spec.rb | 8 +- .../sales_tax_totals_by_producer_spec.rb | 6 +- .../reports/users_and_enterprises_spec.rb | 14 +- spec/system/admin/reports_spec.rb | 35 +++-- spec/system/admin/schedules_spec.rb | 2 +- spec/system/admin/subscriptions/crud_spec.rb | 4 +- .../admin/subscriptions/smoke_tests_spec.rb | 2 +- spec/system/admin/variant_overrides_spec.rb | 4 +- 31 files changed, 225 insertions(+), 213 deletions(-) diff --git a/spec/support/features/datepicker_helper.rb b/spec/support/features/datepicker_helper.rb index ffcfd8ef81..03758c7c34 100644 --- a/spec/support/features/datepicker_helper.rb +++ b/spec/support/features/datepicker_helper.rb @@ -4,7 +4,7 @@ module Features module DatepickerHelper def choose_today_from_datepicker within(".flatpickr-calendar.open") do - find("button", text: "TODAY").click + find("button", text: "Today").click end end diff --git a/spec/system/admin/authentication_spec.rb b/spec/system/admin/authentication_spec.rb index 80bedbd3c9..9e3d5e4885 100644 --- a/spec/system/admin/authentication_spec.rb +++ b/spec/system/admin/authentication_spec.rb @@ -17,9 +17,9 @@ RSpec.describe "Authentication" do fill_in "Email", with: user.email fill_in "Password", with: user.password click_login_button - expect(page).to have_content "DASHBOARD" + expect(page).to have_content "Dashboard" expect(page).to have_current_path spree.admin_dashboard_path - expect(page).not_to have_content "CONFIGURATION" + expect(page).not_to have_content "Configuration" end it "viewing my account" do diff --git a/spec/system/admin/bulk_order_management_spec.rb b/spec/system/admin/bulk_order_management_spec.rb index 8e00eff139..4b7eddffa7 100644 --- a/spec/system/admin/bulk_order_management_spec.rb +++ b/spec/system/admin/bulk_order_management_spec.rb @@ -69,11 +69,11 @@ RSpec.describe ' end it "orders by completion date" do - find("a", text: 'COMPLETED AT').click # sets ascending ordering + find("a", text: 'Completed at').click # sets ascending ordering expect(page).to have_content( /#{li2.product.name}.*#{li1.product.name}.*#{li22.product.name}.*#{li21.product.name}/m ) - find("a", text: 'COMPLETED AT').click # sets descending ordering + find("a", text: 'Completed at').click # sets descending ordering expect(page).to have_content( /#{li21.product.name}.*#{li22.product.name}.*#{li1.product.name}.*#{li2.product.name}/m ) @@ -155,9 +155,9 @@ RSpec.describe ' expect(page).to have_content "Little Fish", count: 15 expect(page).not_to have_content "Big Fish" end - find("a", text: "Clear").click # closes BOM box - expect(page).to have_content "Little Fish", count: 10 + click_link "Clear" # closes BOM box expect(page).to have_content "Big Fish", count: 5 + expect(page).to have_content "Little Fish", count: 10 end end @@ -311,7 +311,7 @@ RSpec.describe ' end it "displays a column for user's full name" do - expect(page).to have_selector "th.full_name", text: "NAME" + expect(page).to have_selector "th.full_name", text: "Name" expect(page) .to have_selector "td.full_name", text: "#{o1.bill_address.last_name}, #{o1.bill_address.first_name}" @@ -320,33 +320,33 @@ RSpec.describe ' it "displays a column for order date" do expect(page).to have_selector "th.date", - text: 'Completed at'.upcase + text: 'Completed at' expect(page).to have_selector "td.date", text: o1.completed_at.strftime('%B %d, %Y') expect(page).to have_selector "td.date", text: o2.completed_at.strftime('%B %d, %Y') end it "displays a column for producer" do - expect(page).to have_selector "th.producer", text: "PRODUCER" + expect(page).to have_selector "th.producer", text: "Producer" expect(page).to have_selector "td.producer", text: li1.product.supplier.name expect(page).to have_selector "td.producer", text: li2.product.supplier.name end it "displays a column for variant description, which shows only product name " \ "when options text is blank" do - expect(page).to have_selector "th.variant", text: "PRODUCT: UNIT" + expect(page).to have_selector "th.variant", text: "Product: Unit" expect(page).to have_selector "td.variant", text: li1.product.name expect(page).to have_selector "td.variant", text: "#{li2.product.name}: #{li2.variant.options_text}" end it "displays a field for quantity" do - expect(page).to have_selector "th.quantity", text: "QUANTITY" + expect(page).to have_selector "th.quantity", text: "Quantity" expect(page).to have_field "quantity", with: li1.quantity.to_s expect(page).to have_field "quantity", with: li2.quantity.to_s end it "displays a column for max quantity" do - expect(page).to have_selector "th.max", text: "MAX" + expect(page).to have_selector "th.max", text: "Max" expect(page).to have_selector "td.max", text: li1.max_quantity.to_s expect(page).to have_selector "td.max", text: li2.max_quantity.to_s end @@ -550,13 +550,13 @@ RSpec.describe ' context "using column display toggle" do it "displays the default selected columns" do - expect(page).to have_selector "th", text: "NAME" + expect(page).to have_selector "th", text: "Name" expect(page).to have_selector "th", - text: 'Completed at'.upcase - expect(page).to have_selector "th", text: "PRODUCER" - expect(page).to have_selector "th", text: "PRODUCT: UNIT" - expect(page).to have_selector "th", text: "QUANTITY" - expect(page).to have_selector "th", text: "MAX" + text: 'Completed at' + expect(page).to have_selector "th", text: "Producer" + expect(page).to have_selector "th", text: "Product: Unit" + expect(page).to have_selector "th", text: "Quantity" + expect(page).to have_selector "th", text: "Max" end context "hiding a column, by de-selecting it from the drop-down" do @@ -565,13 +565,13 @@ RSpec.describe ' end it "shows all default columns, except the de-selected column" do - expect(page).not_to have_selector "th", text: "PRODUCER" - expect(page).to have_selector "th", text: "NAME" + expect(page).not_to have_selector "th", text: "Producer" + expect(page).to have_selector "th", text: "Name" expect(page).to have_selector "th", - text: 'Completed at'.upcase - expect(page).to have_selector "th", text: "PRODUCT: UNIT" - expect(page).to have_selector "th", text: "QUANTITY" - expect(page).to have_selector "th", text: "MAX" + text: 'Completed at' + expect(page).to have_selector "th", text: "Product: Unit" + expect(page).to have_selector "th", text: "Quantity" + expect(page).to have_selector "th", text: "Max" end end end @@ -1209,7 +1209,7 @@ RSpec.describe ' context "clicking 'Clear' in group buy box" do before :each do - find("a", text: "Clear").click + click_link "Clear" # closes BOM box end it "shows all products and clears group buy box" do diff --git a/spec/system/admin/bulk_product_update_spec.rb b/spec/system/admin/bulk_product_update_spec.rb index 7ccab2766a..44263240fd 100644 --- a/spec/system/admin/bulk_product_update_spec.rb +++ b/spec/system/admin/bulk_product_update_spec.rb @@ -201,8 +201,8 @@ RSpec.describe ' login_as_admin visit spree.admin_products_path - find("a", text: "NEW PRODUCT").click - expect(page).to have_content 'NEW PRODUCT' + find("a", text: "New Product").click + expect(page).to have_content 'New Product' fill_in 'product_name', with: 'Big Bag Of Apples' select supplier.name, from: 'product_supplier_id' @@ -311,8 +311,10 @@ RSpec.describe ' end it "creating a variant with unit value is: '120g' and 'on_demand' checked" do + scroll_to(:bottom) + within "tr#v_#{v2.id}" do - page.find(".add-variant").trigger("click") + page.find(".add-variant").click end within "tr#v_-1" do @@ -698,17 +700,17 @@ RSpec.describe ' login_as_admin visit spree.admin_products_path - expect(page).to have_selector "th", text: "NAME" - expect(page).to have_selector "th", text: "PRODUCER" - expect(page).to have_selector "th", text: "PRICE" - expect(page).to have_selector "th", text: "ON HAND" + expect(page).to have_selector "th", text: "Name" + expect(page).to have_selector "th", text: "Producer" + expect(page).to have_selector "th", text: "Price" + expect(page).to have_selector "th", text: "On Hand" toggle_columns /^.{0,1}Producer$/i - expect(page).not_to have_selector "th", text: "PRODUCER" - expect(page).to have_selector "th", text: "NAME" - expect(page).to have_selector "th", text: "PRICE" - expect(page).to have_selector "th", text: "ON HAND" + expect(page).not_to have_selector "th", text: "Producer" + expect(page).to have_selector "th", text: "Name" + expect(page).to have_selector "th", text: "Price" + expect(page).to have_selector "th", text: "On Hand" end end @@ -813,8 +815,8 @@ RSpec.describe ' visit spree.admin_products_path - find("a", text: "NEW PRODUCT").click - expect(page).to have_content 'NEW PRODUCT' + find("a", text: "New Product").click + 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] diff --git a/spec/system/admin/configuration/general_settings_spec.rb b/spec/system/admin/configuration/general_settings_spec.rb index cc352c745b..5f2f33c921 100644 --- a/spec/system/admin/configuration/general_settings_spec.rb +++ b/spec/system/admin/configuration/general_settings_spec.rb @@ -30,7 +30,7 @@ RSpec.describe "General Settings" do context 'editing currency symbol position' do it 'updates its position' do - expect(page).to have_content('CURRENCY SETTINGS') + expect(page).to have_content('Currency Settings') within('.currency') do find("[for='currency_symbol_position_after']").click diff --git a/spec/system/admin/customers_spec.rb b/spec/system/admin/customers_spec.rb index 44417d2110..fdcc76b673 100644 --- a/spec/system/admin/customers_spec.rb +++ b/spec/system/admin/customers_spec.rb @@ -347,7 +347,7 @@ RSpec.describe 'Customers' do end it 'updates the existing billing address' do - expect(page).to have_content 'BILLING ADDRESS' + expect(page).to have_content 'Billing Address' first('#bill-address-link').click wait_for_modal_fade_in @@ -374,7 +374,7 @@ RSpec.describe 'Customers' do end it 'creates a new shipping address' do - expect(page).to have_content 'SHIPPING ADDRESS' + expect(page).to have_content 'Shipping Address' first('#ship-address-link').click wait_for_modal_fade_in diff --git a/spec/system/admin/enterprises_spec.rb b/spec/system/admin/enterprises_spec.rb index c351530226..d40bd2e772 100644 --- a/spec/system/admin/enterprises_spec.rb +++ b/spec/system/admin/enterprises_spec.rb @@ -92,7 +92,7 @@ RSpec.describe ' # Require login to view shopfront or for checkout accept_alert do - within(".side_menu") { click_link "Shop Preferences" } + within(".side_menu") { find(:link, "Shop Preferences").trigger("click") } end expect(page).to have_checked_field "enterprise_require_login_false" expect(page).to have_checked_field "enterprise_allow_guest_orders_true" @@ -100,6 +100,7 @@ RSpec.describe ' expect(page).not_to have_checked_field "enterprise_require_login_false" # expect(page).to have_checked_field "enterprise_enable_subscriptions_false" + scroll_to(:bottom) accept_alert do scroll_to(:bottom) within(".side_menu") { click_link "Users" } @@ -199,7 +200,7 @@ RSpec.describe ' page.find(".option", text: "Victoria").click accept_alert do - click_link "Shop Preferences" + within(".side_menu") { find(:link, "Shop Preferences").trigger("click") } end shop_message_input = page.find("text-angular#enterprise_preferred_shopfront_message div[id^='taTextElement']") @@ -241,7 +242,7 @@ RSpec.describe ' click_link "About" expect(page).to have_content 'This is an interesting long description' - click_link "Shop Preferences" + within(".side_menu") { find(:link, "Shop Preferences").trigger("click") } expect(page).to have_content 'This is my shopfront message.' expect(page).to have_checked_field( "enterprise_preferred_shopfront_order_cycle_order_orders_open_at" @@ -525,7 +526,7 @@ RSpec.describe ' visit edit_admin_enterprise_path(distributor1) within(".side_menu") do - click_link "Shop Preferences" + find(:link, "Shop Preferences").trigger("click") end choose "enterprise_preferred_shopfront_product_sorting_method_by_category" @@ -547,10 +548,11 @@ RSpec.describe ' visit edit_admin_enterprise_path(distributor1) within(".side_menu") do - click_link "Shop Preferences" + find(:link, "Shop Preferences").trigger("click") end choose "enterprise_preferred_shopfront_product_sorting_method_by_producer" + scroll_to(:bottom) find("#s2id_enterprise_preferred_shopfront_producer_order").click find(".select2-result-label", text: "First Supplier").click click_button 'Update' @@ -571,7 +573,7 @@ RSpec.describe ' visit edit_admin_enterprise_path(distributor1) scroll_to(:bottom) within ".side_menu" do - click_link 'Users' + find(:link, "Users").trigger("click") end end @@ -623,7 +625,6 @@ RSpec.describe ' context "white label settings" do before do visit edit_admin_enterprise_path(distributor1) - select_white_label end @@ -644,7 +645,7 @@ RSpec.describe ' end it "set the hide_ofn_navigation preference for the current shop" do - expect(page).not_to have_content "LOGO USED IN SHOPFRONT" + expect(page).not_to have_content "Logo used in shopfront" check "Hide OFN navigation" click_button 'Update' expect(flash_message) @@ -654,7 +655,7 @@ RSpec.describe ' visit edit_admin_enterprise_path(distributor1) select_white_label - expect(page).to have_content "LOGO USED IN SHOPFRONT" + expect(page).to have_content "Logo used in shopfront" uncheck "Hide OFN navigation" click_button 'Update' expect(flash_message) @@ -849,14 +850,14 @@ RSpec.describe ' click_button "Change Package" # checks options for producer profile - expect(page).to have_content "PRODUCER PROFILE" - expect(page).to have_content "PRODUCER SHOP" - expect(page).to have_content "PRODUCER HUB" - expect(page).not_to have_content "PROFILE ONLY" - expect(page).not_to have_content "HUB SHOP" + expect(page).to have_content "Producer Profile" + expect(page).to have_content "Producer Shop" + expect(page).to have_content "Producer Hub" + expect(page).not_to have_content "Profile Only" + expect(page).not_to have_content "Hub Shop" # Producer hub option is selected - page.find('a', class: 'selected', text: "PRODUCER HUB") + page.find('a', class: 'selected', text: "Producer Hub") expect(enterprise.reload.is_primary_producer).to eq true expect(enterprise.reload.sells).to eq('any') @@ -865,14 +866,14 @@ RSpec.describe ' assert_hub_content # Changes to producer shop - page.find('a', text: "PRODUCER SHOP").click + page.find('a', text: "Producer Shop").click click_button "Change now" expect(page).to have_content update_message # Checks changes are persistent click_button "Change Package" - page.find('a', class: 'selected', text: "PRODUCER SHOP") + page.find('a', class: 'selected', text: "Producer Shop") expect(enterprise.reload.is_primary_producer).to eq true expect(enterprise.reload.sells).to eq('own') @@ -881,14 +882,14 @@ RSpec.describe ' assert_hub_content # Changes to producer profile - page.find('a', text: "PRODUCER PROFILE").click + page.find('a', text: "Producer Profile").click click_button "Change now" expect(page).to have_content update_message # Checks changes are persistent click_button "Change Package" - page.find('a', class: 'selected', text: "PRODUCER PROFILE") + page.find('a', class: 'selected', text: "Producer Profile") # a primary producer: expect(enterprise.reload.is_primary_producer).to eq true @@ -917,14 +918,14 @@ RSpec.describe ' click_button "Change Package" # checks options for non-producer profile - expect(page).not_to have_content "PRODUCER PROFILE" - expect(page).not_to have_content "PRODUCER SHOP" - expect(page).not_to have_content "PRODUCER HUB" - expect(page).to have_content "PROFILE ONLY" - expect(page).to have_content "HUB SHOP" + expect(page).not_to have_content "Producer Profile" + expect(page).not_to have_content "Producer Shop" + expect(page).not_to have_content "Producer Hub" + expect(page).to have_content "Profile Only" + expect(page).to have_content "Hub Shop" # Producer hub option is selected - page.find('a', class: 'selected', text: "HUB SHOP") + page.find('a', class: 'selected', text: "Hub Shop") expect(enterprise.reload.is_primary_producer).to eq false expect(enterprise.reload.producer_profile_only).to eq false @@ -933,14 +934,14 @@ RSpec.describe ' assert_hub_content # Changes to producer shop - page.find('a', text: "PROFILE ONLY").click + page.find('a', text: "Profile Only").click click_button "Change now" expect(page).to have_content update_message # Checks changes are persistent click_button "Change Package" - page.find('a', class: 'selected', text: "PROFILE ONLY") + page.find('a', class: 'selected', text: "Profile Only") expect(enterprise.reload.is_primary_producer).to eq false expect(enterprise.reload.producer_profile_only).to eq false @@ -958,13 +959,15 @@ RSpec.describe ' page.find("td.package").click # checks options for producer profile - expect(page).to have_content "PROFILE ONLY" - expect(page).to have_content "PRODUCER SHOP" - expect(page).to have_content "PRODUCER HUB" - expect(page).not_to have_content "HUB SHOP" + within ".enterprise_package_panel" do + expect(page).to have_content "Profile Only" + expect(page).to have_content "Producer Shop" + expect(page).to have_content "Producer Hub" + expect(page).not_to have_content "Hub Shop" + end # Producer hub option is selected - page.find('a', class: 'selected', text: "PRODUCER HUB") + page.find('a', class: 'selected', text: "Producer Hub") expect(enterprise.is_primary_producer).to eq true expect(enterprise.reload.sells).to eq('any') @@ -972,11 +975,11 @@ RSpec.describe ' assert_hub_menu # Changes to producer shop - page.find('a', text: "PRODUCER SHOP").click + page.find('a', text: "Producer Shop").click page.find('a', text: "SAVE").click # Checks changes are persistent - page.find('a', class: 'selected', text: "PRODUCER SHOP") + page.find('a', class: 'selected', text: "Producer Shop") # updates page page.refresh @@ -988,11 +991,11 @@ RSpec.describe ' # Changes to producer profile page.find("td.package").click - page.find('a', text: "PROFILE ONLY").click + page.find('a', text: "Profile Only").click page.find('a', text: "SAVE").click # Checks changes are persistent - page.find('a', class: 'selected', text: "PROFILE ONLY") + page.find('a', class: 'selected', text: "Profile Only") # updates page page.refresh @@ -1023,16 +1026,16 @@ RSpec.describe ' page.find("td.producer").click # checks options for producer profile - expect(page).to have_content "PRODUCER" - expect(page).to have_content "NON-PRODUCER" + expect(page).to have_content "Producer" + expect(page).to have_content "Non-producer" # Producer hub option is selected - page.find('a', class: 'selected', text: "PRODUCER") + page.find('a', class: 'selected', text: "Producer") expect(enterprise.is_primary_producer).to eq true expect(enterprise.reload.sells).to eq('any') # Changes to non-producer - page.find('a', text: "NON-PRODUCER").click + page.find('a', text: "Non-producer").click page.find('a', text: "SAVE").click # updates page @@ -1044,19 +1047,21 @@ RSpec.describe ' page.find("td.package").click # checks options for non-producer profile - expect(page).not_to have_content "PRODUCER PROFILE" - expect(page).not_to have_content "PRODUCER SHOP" - expect(page).not_to have_content "PRODUCER HUB" - expect(page).to have_content "PROFILE ONLY" - expect(page).to have_content "HUB SHOP" + within ".enterprise_package_panel" do + expect(page).not_to have_content "Producer Profile" + expect(page).not_to have_content "Producer Shop" + expect(page).not_to have_content "Producer Hub" + expect(page).to have_content "Profile Only" + expect(page).to have_content "Hub Shop" + end # Producer hub option is selected - page.find('a', class: 'selected', text: "HUB SHOP") + page.find('a', class: 'selected', text: "Hub Shop") expect(enterprise.reload.is_primary_producer).to eq false expect(enterprise.reload.sells).to eq('any') # Changes to producer shop - page.find('a', text: "PROFILE ONLY").click + page.find('a', text: "Profile Only").click page.find('a', text: "SAVE").click # updates page @@ -1064,12 +1069,12 @@ RSpec.describe ' # Checks changes are persistent page.find("td.package").click - page.find('a', class: 'selected', text: "PROFILE ONLY") + page.find('a', class: 'selected', text: "Profile Only") # Displays the correct dashboard sections within "#admin-menu" do - expect(page).to have_content "DASHBOARD" - expect(page).to have_content "ENTERPRISES" + expect(page).to have_content "Dashboard" + expect(page).to have_content "Enterprises" end expect(enterprise.reload.is_primary_producer).to eq false @@ -1093,13 +1098,13 @@ end def assert_hub_menu within "#admin-menu" do - expect(page).to have_content "DASHBOARD" - expect(page).to have_content "PRODUCTS" - expect(page).to have_content "ORDER CYCLES" - expect(page).to have_content "ORDERS" - expect(page).to have_content "REPORTS" - expect(page).to have_content "ENTERPRISES" - expect(page).to have_content "CUSTOMERS" + expect(page).to have_content "Dashboard" + expect(page).to have_content "Products" + expect(page).to have_content "Order cycles" + expect(page).to have_content "Orders" + expect(page).to have_content "Reports" + expect(page).to have_content "Enterprises" + expect(page).to have_content "Customers" end end @@ -1114,13 +1119,13 @@ end def assert_supplier_menu within "#admin-menu" do - expect(page).to have_content "DASHBOARD" - expect(page).to have_content "PRODUCTS" - expect(page).not_to have_content "ORDER CYCLES" - expect(page).not_to have_content "ORDERS" - expect(page).to have_content "REPORTS" - expect(page).to have_content "ENTERPRISES" - expect(page).not_to have_content "CUSTOMERS" + expect(page).to have_content "Dashboard" + expect(page).to have_content "Products" + expect(page).not_to have_content "Order cycles" + expect(page).not_to have_content "Orders" + expect(page).to have_content "Reports" + expect(page).to have_content "Enterprises" + expect(page).not_to have_content "Customers" end end @@ -1135,8 +1140,8 @@ end def assert_profile within "#admin-menu" do - expect(page).to have_content "DASHBOARD" - expect(page).to have_content "ENTERPRISES" + expect(page).to have_content "Dashboard" + expect(page).to have_content "Enterprises" end within "#content" do @@ -1144,3 +1149,9 @@ def assert_profile expect(page).to have_content "Edit profile details" end end + +def select_white_label + within(".side_menu") do + find(:link, "White Label").trigger("click") + end +end diff --git a/spec/system/admin/flatpickr_spec.rb b/spec/system/admin/flatpickr_spec.rb index 434b24a2b0..a3c9965954 100644 --- a/spec/system/admin/flatpickr_spec.rb +++ b/spec/system/admin/flatpickr_spec.rb @@ -7,14 +7,14 @@ RSpec.describe "Test Flatpickr" do include WebHelper context "orders" do - it "opens the datepicker and closes it using the 'CLOSE' button" do + it "opens the datepicker and closes it using the 'Close' button" do login_as_admin visit 'admin/orders' open_datepicker('.datepicker') # Looks for the close button and click it within(".flatpickr-calendar.open") do expect(page).to have_selector '.shortcut-buttons-flatpickr-buttons' - find("button", text: "CLOSE").click + find("button", text: "Close").click end # Should no more have opened flatpickr expect(page).not_to have_selector '.flatpickr-calendar.open' diff --git a/spec/system/admin/order_cycles/complex_editing_multiple_product_pages_spec.rb b/spec/system/admin/order_cycles/complex_editing_multiple_product_pages_spec.rb index ddc888700e..993ad50b65 100644 --- a/spec/system/admin/order_cycles/complex_editing_multiple_product_pages_spec.rb +++ b/spec/system/admin/order_cycles/complex_editing_multiple_product_pages_spec.rb @@ -47,7 +47,7 @@ RSpec.describe ' end def expect_all_products_loaded - expect(page).to have_content new_product.name.upcase + expect(page).to have_content new_product.name expect(page).to have_content "2 of 2 Variants Loaded" end end diff --git a/spec/system/admin/order_cycles/complex_editing_multiple_updation_spec.rb b/spec/system/admin/order_cycles/complex_editing_multiple_updation_spec.rb index 5d744c1c71..ed9f640de2 100644 --- a/spec/system/admin/order_cycles/complex_editing_multiple_updation_spec.rb +++ b/spec/system/admin/order_cycles/complex_editing_multiple_updation_spec.rb @@ -16,7 +16,7 @@ RSpec.describe ' # Expect correct values expect(page).to have_field('order_cycle_name', with: oc.name) - expect(page).to have_content "COORDINATOR #{oc.coordinator.name}" + expect(page).to have_content "Coordinator #{oc.coordinator.name}" expect(page).to have_button('Save', disabled: true) expect(page).to have_button('Save and Next', disabled: true) diff --git a/spec/system/admin/order_cycles/complex_editing_spec.rb b/spec/system/admin/order_cycles/complex_editing_spec.rb index 3635cf69e9..fca1da3363 100644 --- a/spec/system/admin/order_cycles/complex_editing_spec.rb +++ b/spec/system/admin/order_cycles/complex_editing_spec.rb @@ -30,7 +30,7 @@ RSpec.describe ' .to eq(oc.orders_open_at.strftime("%Y-%m-%d %H:%M")) expect(page.find('#order_cycle_orders_close_at').value) .to eq(oc.orders_close_at.strftime("%Y-%m-%d %H:%M")) - expect(page).to have_content "COORDINATOR #{oc.coordinator.name}" + expect(page).to have_content "Coordinator #{oc.coordinator.name}" click_button 'Next' diff --git a/spec/system/admin/order_cycles/list_spec.rb b/spec/system/admin/order_cycles/list_spec.rb index 2c95656555..e2a3729a5c 100644 --- a/spec/system/admin/order_cycles/list_spec.rb +++ b/spec/system/admin/order_cycles/list_spec.rb @@ -177,7 +177,7 @@ RSpec.describe ' within(".flatpickr-calendar.open") do expect(page).to have_selector '.shortcut-buttons-flatpickr-buttons' select_datetime_from_datepicker test_value - find("button", text: "CLOSE").click + find("button", text: "Close").click end # Should no more have opened flatpickr diff --git a/spec/system/admin/order_cycles/simple_spec.rb b/spec/system/admin/order_cycles/simple_spec.rb index 1ce165d630..d08e59de61 100644 --- a/spec/system/admin/order_cycles/simple_spec.rb +++ b/spec/system/admin/order_cycles/simple_spec.rb @@ -334,7 +334,7 @@ RSpec.describe ' visit edit_admin_order_cycle_path(oc) - expect(page).to have_content 'Re notify producers'.upcase + expect(page).to have_content "Re notify producers" end it "allows removing exchanges" do @@ -781,7 +781,7 @@ RSpec.describe ' uncheck "order_cycle_incoming_exchange_0_variants_#{v3.id}" # Add tags - expect(page).to have_content "TAGS" + expect(page).to have_content "Tags" within "tags-with-translation" do find(:css, "tags-input .tags input").set "wholesale\n" diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 55d91e9ef2..9a0f8a7d4b 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -73,7 +73,7 @@ RSpec.describe ' expect(order.line_items.count).to be_zero click_link "Order Details" - expect(page).to have_content 'ADD PRODUCT' + expect(page).to have_content 'Add Product' select2_select product.name, from: 'add_variant_id', search: true find('button.add_variant').click # Wait for JS @@ -105,10 +105,10 @@ RSpec.describe ' end it "doesn't show links to other steps" do - expect(page).not_to have_content "CUSTOMER DETAILS" - expect(page).not_to have_content "ORDER DETAILS" - expect(page).not_to have_content "PAYMENTS" - expect(page).not_to have_content "ADJUSTMENTS" + expect(page).not_to have_content "Customer Details" + expect(page).not_to have_content "Order Details" + expect(page).not_to have_content "Payments" + expect(page).not_to have_content "Adjustments" end end @@ -440,7 +440,7 @@ RSpec.describe ' expect(page).to have_content "Customer Details updated" click_link "Order Details" - expect(page).to have_content 'Add Product'.upcase + expect(page).to have_content 'Add Product' select2_select product.name, from: 'add_variant_id', search: true within("table.stock-levels") do @@ -611,7 +611,7 @@ RSpec.describe ' expect(page).to have_selector "fieldset#order-total", text: order.display_total # shows the order tax adjustments - within('fieldset', text: 'Line Item Adjustments'.upcase) do + within('fieldset', text: 'Line Item Adjustments') do expect(page).to have_selector "td", match: :first, text: "Tax 1" expect(page).to have_selector "td.total", text: Spree::Money.new(10) end @@ -1067,7 +1067,7 @@ RSpec.describe ' visit spree.edit_admin_order_path(incomplete_order) - expect(page).to have_content "Out of Stock".upcase + expect(page).to have_content "Out of Stock" within ".insufficient-stock-items" do expect(page).to have_content incomplete_order.products.first.name @@ -1079,7 +1079,8 @@ RSpec.describe ' # updates the order and verifies the warning disappears click_button 'Update And Recalculate Fees' - expect(page).not_to have_content "Out of Stock".upcase + + expect(page).not_to have_content "Out of Stock" end end end @@ -1089,7 +1090,7 @@ RSpec.describe ' expect(page).to have_selector 'h1', text: 'Customer Details' click_link "Order Details" - expect(page).to have_content 'ADD PRODUCT' + expect(page).to have_content 'Add Product' select2_select product.name, from: 'add_variant_id', search: true find('button.add_variant').click diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index deedf07e3f..ddfa068ea8 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -279,7 +279,7 @@ RSpec.describe ' expect(page).to have_content order_not_empty_no_address.number # And the same orders are displayed when sorting by name: - find("th a", text: "NAME").click + find("th a", text: "Name").click expect(page).not_to have_content order_empty.number expect(page).to have_content order_not_empty.number @@ -298,11 +298,11 @@ RSpec.describe ' visit spree.admin_orders_path end it "orders by completion date" do - find("a", text: 'COMPLETED AT').click # sets ascending ordering + find("a", text: 'Completed At').click # sets ascending ordering expect(page).to have_content( /#{order5.number}.*#{order4.number}.*#{order3.number}.*#{order2.number}/m ) - find("a", text: 'COMPLETED AT').click # sets descending ordering + find("a", text: 'Completed At').click # sets descending ordering expect(page).to have_content( /#{order2.number}.*#{order3.number}.*#{order4.number}.*#{order5.number}/m ) @@ -320,11 +320,11 @@ RSpec.describe ' end it "orders by order number" do - find("a", text: 'NUMBER').click # sets ascending ordering + find("a", text: 'Number').click # sets ascending ordering expect(page).to have_content( /#{order5.number}.*#{order4.number}.*#{order3.number}.*#{order2.number}/m ) - find("a", text: 'NUMBER').click # sets descending ordering + find("a", text: 'Number').click # sets descending ordering expect(page).to have_content( /#{order2.number}.*#{order3.number}.*#{order4.number}.*#{order5.number}/m ) @@ -344,11 +344,11 @@ RSpec.describe ' end it "orders by order state" do - find("a", text: 'STATE').click # sets ascending ordering + find("a", text: 'State').click # sets ascending ordering expect(page).to have_content( /#{order5.number}.*#{order4.number}.*#{order3.number}.*#{order2.number}/m ) - find("a", text: 'STATE').click # sets descending ordering + find("a", text: 'State').click # sets descending ordering expect(page).to have_content( /#{order2.number}.*#{order3.number}.*#{order4.number}.*#{order5.number}/m ) @@ -365,9 +365,9 @@ RSpec.describe ' end it "orders by payment state" do - find("a", text: 'PAYMENT STATE').click # sets ascending ordering + find("a", text: 'Payment State').click # sets ascending ordering expect(page).to have_content(/#{order4.number}.*#{order3.number}.*#{order2.number}/m) - find("a", text: 'PAYMENT STATE').click # sets descending ordering + find("a", text: 'Payment State').click # sets descending ordering expect(page).to have_content(/#{order2.number}.*#{order3.number}.*#{order4.number}/m) end end @@ -383,9 +383,9 @@ RSpec.describe ' end it "orders by shipment state" do - find("a", text: 'SHIPMENT STATE').click # sets ascending ordering + find("a", text: 'Shipment State').click # sets ascending ordering expect(page).to have_content(/#{order4.number}.*#{order3.number}.*#{order2.number}/m) - find("a", text: 'SHIPMENT STATE').click # sets descending ordering + find("a", text: 'Shipment State').click # sets descending ordering expect(page).to have_content(/#{order2.number}.*#{order3.number}.*#{order4.number}/m) end end @@ -401,11 +401,11 @@ RSpec.describe ' end it "orders by customer email" do - find("a", text: 'EMAIL').click # sets ascending ordering + find("a", text: 'Email').click # sets ascending ordering expect(page).to have_content( /#{order5.number}.*#{order4.number}.*#{order3.number}.*#{order2.number}/m ) - find("a", text: 'EMAIL').click # sets descending ordering + find("a", text: 'Email').click # sets descending ordering expect(page).to have_content( /#{order2.number}.*#{order3.number}.*#{order4.number}.*#{order5.number}/m ) @@ -423,11 +423,11 @@ RSpec.describe ' end it "orders by last name then first name" do - find("a", text: 'NAME').click # sets ascending ordering + find("a", text: 'Name').click # sets ascending ordering expect(page).to have_content( /#{order4.number}.*#{order2.number}.*#{order3.number}.*#{order5.number}/m ) - find("a", text: 'NAME').click # sets descending ordering + find("a", text: 'Name').click # sets descending ordering expect(page).to have_content( /#{order5.number}.*#{order3.number}.*#{order2.number}.*#{order4.number}/m ) @@ -465,11 +465,11 @@ RSpec.describe ' end it "orders by order total" do - find("a", text: 'TOTAL').click # sets ascending ordering + find("a", text: 'Total').click # sets ascending ordering expect(page).to have_content( /#{order5.number}.*#{order4.number}.*#{order3.number}.*#{order2.number}/m ) - find("a", text: 'TOTAL').click # sets descending ordering + find("a", text: 'Total').click # sets descending ordering expect(page).to have_content( /#{order2.number}.*#{order3.number}.*#{order4.number}.*#{order5.number}/m ) diff --git a/spec/system/admin/overview_spec.rb b/spec/system/admin/overview_spec.rb index 9660f812eb..47df19512e 100644 --- a/spec/system/admin/overview_spec.rb +++ b/spec/system/admin/overview_spec.rb @@ -28,7 +28,7 @@ RSpec.describe ' visit '/admin' expect(page).to have_selector ".dashboard_item h3", text: "Your profile live" expect(page).to have_selector ".dashboard_item .button.bottom", - text: "SEE #{d1.name.upcase} LIVE" + text: "See #{d1.name} live" end context "when visibilty is set to false" do diff --git a/spec/system/admin/product_import_spec.rb b/spec/system/admin/product_import_spec.rb index baec074a88..895a4af94f 100644 --- a/spec/system/admin/product_import_spec.rb +++ b/spec/system/admin/product_import_spec.rb @@ -707,8 +707,8 @@ RSpec.describe "Product Import" do expect(page).to have_selector '.created-count', text: '1' expect(page).not_to have_selector '.updated-count' - expect(page).to have_content "GO TO PRODUCTS PAGE" - expect(page).to have_content "UPLOAD ANOTHER FILE" + expect(page).to have_content "Go To Products Page" + expect(page).to have_content "Upload Another File" visit spree.admin_products_path diff --git a/spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_order_spec.rb b/spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_order_spec.rb index fb80e2b510..8ca3aed932 100644 --- a/spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_order_spec.rb +++ b/spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_order_spec.rb @@ -15,7 +15,7 @@ RSpec.describe "Enterprise Summary Fee with Tax Report By Order" do [ "Distributor", "Order Cycle", - "Order Number", + "Order number", "Name", "Type", "Owner", @@ -29,7 +29,7 @@ RSpec.describe "Enterprise Summary Fee with Tax Report By Order" do "Last Name", "Customer Code", "Customer Email" - ].join(" ").upcase + ].join(" ") } let!(:state_zone){ create(:zone_with_state_member) } diff --git a/spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_producer_spec.rb b/spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_producer_spec.rb index bdab8ac972..3d16397453 100644 --- a/spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_producer_spec.rb +++ b/spec/system/admin/reports/enterprise_summary_fees/enterprise_summary_fee_with_tax_report_by_producer_spec.rb @@ -16,7 +16,7 @@ RSpec.describe "Enterprise Summary Fee with Tax Report By Producer" do let!(:table_header){ ["Distributor", "Producer", "Producer Tax Status", "Order Cycle", "Name", "Type", "Owner", "Tax Category", "Tax Rate Name", "Tax Rate", "Total excl. tax ($)", "Tax", - "Total incl. tax ($)"].join(" ").upcase + "Total incl. tax ($)"].join(" ") } let!(:state_zone){ create(:zone_with_state_member) } diff --git a/spec/system/admin/reports/orders_and_fulfillment_spec.rb b/spec/system/admin/reports/orders_and_fulfillment_spec.rb index 971484492a..cf913b365d 100644 --- a/spec/system/admin/reports/orders_and_fulfillment_spec.rb +++ b/spec/system/admin/reports/orders_and_fulfillment_spec.rb @@ -95,7 +95,6 @@ RSpec.describe "Orders And Fulfillment" do "Billing State", "Order number", "Date"] - .map(&:upcase) ]) end @@ -278,7 +277,6 @@ RSpec.describe "Orders And Fulfillment" do "Total Units", "Curr. Cost per Unit", "Total Cost"] - .map(&:upcase) ]) # displays the producer name in the respective column @@ -332,7 +330,6 @@ RSpec.describe "Orders And Fulfillment" do "Total Units", "Curr. Cost per Unit", "Total Cost"] - .map(&:upcase) ]) # displays the producer name in own row @@ -368,7 +365,6 @@ RSpec.describe "Orders And Fulfillment" do "Curr. Cost per Unit", "Total Cost", "Shipping Method"] - .map(&:upcase) ]) # displays the producer name in the respective column @@ -416,7 +412,6 @@ RSpec.describe "Orders And Fulfillment" do "Curr. Cost per Unit", "Total Cost", "Shipping Method"] - .map(&:upcase) ]) # displays the producer name in own row @@ -468,7 +463,6 @@ RSpec.describe "Orders And Fulfillment" do "Total Cost", "Total Shipping Cost", "Shipping Method"] - .map(&:upcase) ]) # displays the Distributor name in the respective column @@ -520,7 +514,6 @@ RSpec.describe "Orders And Fulfillment" do "Total Cost", "Total Shipping Cost", "Shipping Method"] - .map(&:upcase) ]) # displays the Distributor name in own row diff --git a/spec/system/admin/reports/packing_report_spec.rb b/spec/system/admin/reports/packing_report_spec.rb index 04f2f82a49..fd697b56e2 100644 --- a/spec/system/admin/reports/packing_report_spec.rb +++ b/spec/system/admin/reports/packing_report_spec.rb @@ -62,7 +62,7 @@ RSpec.describe "Packing Reports" do expect(table).to eq([ ["Hub", "Customer Code", "First Name", "Last Name", "Supplier", "Product", "Variant", "Weight", "Height", "Width", "Depth", - "Quantity", "TempControlled?"].map(&:upcase) + "Quantity", "TempControlled?"] ]) expect(page).to have_selector 'table.report__table tbody tr', count: 5 # Totals row/order @@ -80,7 +80,7 @@ RSpec.describe "Packing Reports" do rows = find("table.report__table").all("tr") table = rows.map { |r| r.all("th,td").map { |c| c.text.strip }[3] } expect(table).to eq([ - "LAST NAME", + "Last Name", order1.bill_address.lastname, order1.bill_address.lastname, "", @@ -108,7 +108,7 @@ RSpec.describe "Packing Reports" do table = rows.map { |r| r.all("th").map { |c| c.text.strip } } expect(table).to eq([ ["Hub", "Supplier", "Customer Code", "First Name", "Last Name", - "Product", "Variant", "Quantity", "TempControlled?"].map(&:upcase) + "Product", "Variant", "Quantity", "TempControlled?"] ]) expect(all('table.report__table tbody tr').count).to eq(3) # Totals row per supplier diff --git a/spec/system/admin/reports/payments_report_spec.rb b/spec/system/admin/reports/payments_report_spec.rb index ad220e6acc..ad37562c5c 100644 --- a/spec/system/admin/reports/payments_report_spec.rb +++ b/spec/system/admin/reports/payments_report_spec.rb @@ -46,7 +46,7 @@ RSpec.describe "Payments Reports" do "Shipping Total ($)", "Outstanding Balance ($)", "Total ($)" - ].join(" ").upcase) + ].join(" ")) expect(page.find("table.report__table tbody tr").text).to have_content([ order.payment_state, @@ -83,7 +83,7 @@ RSpec.describe "Payments Reports" do "EFT ($)", "PayPal ($)", "Outstanding Balance ($)" - ].join(" ").upcase) + ].join(" ")) expect(page.find("table.report__table tbody tr").text).to have_content([ "credit owed", diff --git a/spec/system/admin/reports/revenues_by_hub_spec.rb b/spec/system/admin/reports/revenues_by_hub_spec.rb index 71ce4386c9..d0df382ba0 100644 --- a/spec/system/admin/reports/revenues_by_hub_spec.rb +++ b/spec/system/admin/reports/revenues_by_hub_spec.rb @@ -62,23 +62,23 @@ RSpec.describe "Revenues By Hub Reports" do run_report expect(page.find("table.report__table thead tr").text).to have_content([ - "HUB", - "HUB ID", - "HUB BUSINESS NUMBER", - "HUB LEGAL NAME", - "HUB CONTACT NAME", - "HUB PUBLIC EMAIL", - "HUB OWNER EMAIL", - "HUB PHONE NUMBER", - "HUB ADDRESS LINE 1", - "HUB ADDRESS LINE 2", - "HUB SUBURB", - "HUB POSTCODE", - "HUB STATE", - "TOTAL NUMBER OF ORDERS", - "TOTAL EXCL. TAX ($)", - "TOTAL TAX ($)", - "TOTAL INCL. TAX ($)" + "Hub", + "Hub ID", + "Hub Business Number", + "Hub Legal Name", + "Hub Contact Name", + "Hub Public Email", + "Hub Owner Email", + "Hub Phone Number", + "Hub Address Line 1", + "Hub Address Line 2", + "Hub Suburb", + "Hub Postcode", + "Hub State", + "Total Number of Orders", + "Total excl. tax ($)", + "Total Tax ($)", + "Total incl. tax ($)" ].join(" ")) lines = page.all('table.report__table tbody tr').map(&:text) diff --git a/spec/system/admin/reports/sales_tax/sales_tax_totals_by_order_spec.rb b/spec/system/admin/reports/sales_tax/sales_tax_totals_by_order_spec.rb index b186182669..877081295a 100644 --- a/spec/system/admin/reports/sales_tax/sales_tax_totals_by_order_spec.rb +++ b/spec/system/admin/reports/sales_tax/sales_tax_totals_by_order_spec.rb @@ -15,18 +15,18 @@ RSpec.describe "Sales Tax Totals By order" do [ "Distributor", "Order Cycle", - "Order Number", + "Order number", "Tax Category", "Tax Rate Name", "Tax Rate", - "Total excl. Tax ($)", + "Total excl. tax ($)", "Tax", - "Total incl. Tax ($)", + "Total incl. tax ($)", "First Name", "Last Name", "Code", "Email" - ].join(" ").upcase + ].join(" ") } let!(:state_zone){ create(:zone_with_state_member) } let!(:country_zone){ create(:zone_with_member) } diff --git a/spec/system/admin/reports/sales_tax/sales_tax_totals_by_producer_spec.rb b/spec/system/admin/reports/sales_tax/sales_tax_totals_by_producer_spec.rb index e896d23a14..63b4f7f071 100644 --- a/spec/system/admin/reports/sales_tax/sales_tax_totals_by_producer_spec.rb +++ b/spec/system/admin/reports/sales_tax/sales_tax_totals_by_producer_spec.rb @@ -19,10 +19,10 @@ RSpec.describe "Sales Tax Totals By Producer" do "Tax Category", "Tax Rate Name", "Tax Rate", - "Total excl. Tax ($)", + "Total excl. tax ($)", "Tax", - "Total incl. Tax ($)" - ].join(" ").upcase + "Total incl. tax ($)" + ].join(" ") } let!(:state_zone){ create(:zone_with_state_member) } let!(:country_zone){ create(:zone_with_member) } diff --git a/spec/system/admin/reports/users_and_enterprises_spec.rb b/spec/system/admin/reports/users_and_enterprises_spec.rb index 64ad6c04e7..bd5b095e2c 100644 --- a/spec/system/admin/reports/users_and_enterprises_spec.rb +++ b/spec/system/admin/reports/users_and_enterprises_spec.rb @@ -16,13 +16,13 @@ RSpec.describe "Users & Enterprises reports" do run_report expect(page.find("table.report__table thead tr").text).to have_content([ - "USER", - "RELATIONSHIP", - "ENTERPRISE", - "PRODUCER?", - "SELLS", - "VISIBLE", - "CONFIRMATION DATE", + "User", + "Relationship", + "Enterprise", + "Producer?", + "Sells", + "Visible", + "Confirmation Date", "OFN UID" ].join(" ")) diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index ba860cf264..7af169a6de 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -31,6 +31,7 @@ RSpec.describe ' end end + describe "Background processing" do it "renders UTF-8 characters" do # We had a problem when UTF-8 was in the page and the report because @@ -51,7 +52,7 @@ RSpec.describe ' visit admin_report_path(report_type: :customers) run_report expect(page).to have_content "Späti" - expect(page).to have_content "FIRST NAME LAST NAME BILLING ADDRESS EMAIL" + expect(page).to have_content "First Name Last Name Billing Address Email" expect(page).to have_content "Müller" end @@ -130,9 +131,14 @@ 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. @@ -167,7 +173,7 @@ RSpec.describe ' expect(table.sort).to eq([ ["First Name", "Last Name", "Billing Address", "Email", "Phone", "Hub", "Hub Address", "Shipping Method", "Total Number of Orders", "Total incl. tax ($)", - "Last completed order date"].map(&:upcase) + "Last completed order date"] ].sort) end end @@ -185,7 +191,7 @@ RSpec.describe ' table = rows.map { |r| r.all("th").map { |c| c.text.strip } } expect(table.sort).to eq([ ["First Name", "Last Name", "Hub", "Customer Code", "Email", "Phone", "Shipping Method", - "Payment Method", "Amount", "Balance"].map(&:upcase) + "Payment Method", "Amount", "Balance"] ].sort) end @@ -197,7 +203,7 @@ RSpec.describe ' expect(table.sort).to eq([ ["First Name", "Last Name", "Hub", "Customer Code", "Delivery Address", "Delivery Postcode", "Phone", "Shipping Method", "Payment Method", "Amount", "Balance", - "Temp Controlled Items?", "Special Instructions"].map(&:upcase) + "Temp Controlled Items?", "Special Instructions"] ].sort) end end @@ -238,7 +244,6 @@ RSpec.describe ' 'Distributor postcode', 'Shipping Method', 'Shipping instructions'] - .map(&:upcase) ]) expect(all('table.report__table tbody tr').count).to eq( @@ -260,7 +265,6 @@ RSpec.describe ' 'Distributor', 'Payment Type', "Total (%s)" % currency_symbol] - .map(&:upcase) ]) expect(all('table.report__table tbody tr').count).to eq( @@ -410,13 +414,14 @@ RSpec.describe ' expect(page).to have_content "All products" expect(page).to have_content "Inventory (on hand)" + click_link 'All products' run_report expect(page).to have_content "Supplier" 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"].map(&:upcase) + "On Demand?", "On Hand"] expect(page).to have_table_row [product1.supplier.name, product1.supplier.address.city, "Product Name", product1.properties.map(&:presentation).join(", "), @@ -442,7 +447,7 @@ RSpec.describe ' expect(page).to have_table_row ['PRODUCT', 'Description', 'Qty', 'Pack Size', 'Unit', 'Unit Price', 'Total', 'GST incl.', - 'Grower and growing method', 'Taxon'].map(&:upcase) + 'Grower and growing method', 'Taxon'] expect(page).to have_table_row ['Product 2', '100g', '', '100', 'g', '99.0', '', '0', 'Supplier Name (Organic - NASAA 12345)', 'Taxon Name'] end @@ -469,7 +474,7 @@ RSpec.describe ' table = rows.map { |r| r.all("th,td").map { |c| c.text.strip }[0..2] } expect(table.sort).to eq([ - ["User", "Relationship", "Enterprise"].map(&:upcase), + ["User", "Relationship", "Enterprise"], [enterprise1.owner.email, "owns", enterprise1.name], [enterprise1.owner.email, "manages", enterprise1.name], [enterprise2.owner.email, "owns", enterprise2.name], @@ -490,7 +495,7 @@ RSpec.describe ' table = rows.map { |r| r.all("th,td").map { |c| c.text.strip }[0..2] } expect(table.sort).to eq([ - ["User", "Relationship", "Enterprise"].map(&:upcase), + ["User", "Relationship", "Enterprise"], [enterprise1.owner.email, "manages", enterprise3.name] ].sort) end @@ -518,7 +523,7 @@ RSpec.describe ' "Units Required", "Unallocated", "Max Quantity Excess" - ].map(&:upcase) + ] end it "generating Bulk Co-op Allocation report" do @@ -537,7 +542,7 @@ RSpec.describe ' "Total available", "Unallocated", "Max Quantity Excess" - ].map(&:upcase) + ] end it "generating Bulk Co-op Packing Sheets report" do @@ -549,7 +554,7 @@ RSpec.describe ' "Product", "Variant", "Sum Total" - ].map(&:upcase) + ] end it "generating Bulk Co-op Customer Payments report" do @@ -562,7 +567,7 @@ RSpec.describe ' "Total Cost", "Amount Owing", "Amount Paid" - ].map(&:upcase) + ] end end @@ -759,7 +764,7 @@ RSpec.describe ' POCity PORegion POPostalCode POCountry *InvoiceNumber Reference *InvoiceDate *DueDate InventoryItemCode *Description *Quantity *UnitAmount Discount *AccountCode *TaxType TrackingName1 TrackingOption1 TrackingName2 TrackingOption2 Currency BrandingTheme - Paid?).map(&:upcase) + Paid?) end def xero_invoice_summary_row(description, amount, tax_type, opts = {}) diff --git a/spec/system/admin/schedules_spec.rb b/spec/system/admin/schedules_spec.rb index 383e26d931..9655ee062a 100644 --- a/spec/system/admin/schedules_spec.rb +++ b/spec/system/admin/schedules_spec.rb @@ -32,7 +32,7 @@ RSpec.describe 'Schedules' do visit spree.admin_dashboard_path click_link 'Order cycles' expect(page).to have_selector ".order-cycle-#{oc1.id}" - find('a', text: 'NEW SCHEDULE').click + find('a', text: 'New Schedule').click within "#schedule-dialog" do # Only order cycles coordinated by managed enterprises are available to select diff --git a/spec/system/admin/subscriptions/crud_spec.rb b/spec/system/admin/subscriptions/crud_spec.rb index 91e9467216..2d5ea672ae 100644 --- a/spec/system/admin/subscriptions/crud_spec.rb +++ b/spec/system/admin/subscriptions/crud_spec.rb @@ -128,7 +128,7 @@ RSpec.describe 'Subscriptions' do accept_alert 'Are you sure?' do find("a.cancel-order").click end - expect(page).to have_content 'CANCELLED' + expect(page).to have_content 'CANCELLED'.upcase expect(proxy_order.reload.canceled_at).to be_within(5.seconds).of Time.zone.now # Resuming an order @@ -260,7 +260,7 @@ RSpec.describe 'Subscriptions' do choose_today_from_datepicker click_button('Next') - expect(page).to have_content 'BILLING ADDRESS' + expect(page).to have_content 'Billing Address' # Customer bill address has been pre-loaded expect(page).to have_input "bill_address_firstname", with: address.firstname expect(page).to have_input "bill_address_lastname", with: address.lastname diff --git a/spec/system/admin/subscriptions/smoke_tests_spec.rb b/spec/system/admin/subscriptions/smoke_tests_spec.rb index feb905a1aa..599a4ffe52 100644 --- a/spec/system/admin/subscriptions/smoke_tests_spec.rb +++ b/spec/system/admin/subscriptions/smoke_tests_spec.rb @@ -192,7 +192,7 @@ RSpec.describe 'Subscriptions' do # Fill in other details fill_in_subscription_basic_details click_button "Next" - expect(page).to have_content "BILLING ADDRESS" + expect(page).to have_content "Billing Address" click_button "Next" # Add products diff --git a/spec/system/admin/variant_overrides_spec.rb b/spec/system/admin/variant_overrides_spec.rb index 9e5554bc92..3f48ae7602 100644 --- a/spec/system/admin/variant_overrides_spec.rb +++ b/spec/system/admin/variant_overrides_spec.rb @@ -82,7 +82,7 @@ RSpec.describe " context "with no overrides" do it "displays the list of products with variants" do - expect(page).to have_table_row ['PRODUCER', 'PRODUCT', 'PRICE', 'ON HAND', 'ON DEMAND?'] + expect(page).to have_table_row ['Producer', 'Product', 'Price', 'On Hand', 'On Demand?'] expect(page).to have_table_row [producer.name, product.name, '', '', ''] expect(page).to have_input "variant-overrides-#{variant.id}-price", placeholder: '1.23' expect(page).to have_input "variant-overrides-#{variant.id}-count_on_hand", @@ -493,7 +493,7 @@ RSpec.describe " "inventory." click_button "Review Now" - expect(page).to have_table_row ['PRODUCER', 'PRODUCT', 'VARIANT', 'ADD', 'HIDE'] + expect(page).to have_table_row ['Producer', 'Product', 'Variant', 'Add', 'Hide'] expect(page).to have_selector "table#new-products tr#v_#{variant1.id}" expect(page).to have_selector "table#new-products tr#v_#{variant2.id}" within "table#new-products tr#v_#{variant1.id}" do From 9aecf9feb485bc6adc060eba976ed1c3e3ce08b9 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 25 Oct 2023 12:50:45 +0100 Subject: [PATCH 03/42] Brings the tests back to green, after rebasing This is a WIP branch, and each time we rebase we'll have some specs breaking. The changes in this commit mostly relate to the change in /admin/products URL, which points to the new BUU prodcts page; disabling the feature around related tests brings the branch back to green. --- spec/system/admin/bulk_product_update_spec.rb | 24 ++-- spec/system/admin/product_import_spec.rb | 8 +- spec/system/admin/products_spec.rb | 106 ++++++++++-------- spec/system/admin/subscriptions/crud_spec.rb | 2 +- .../admin/subscriptions/smoke_tests_spec.rb | 2 + 5 files changed, 82 insertions(+), 60 deletions(-) diff --git a/spec/system/admin/bulk_product_update_spec.rb b/spec/system/admin/bulk_product_update_spec.rb index 44263240fd..cdb45b9a16 100644 --- a/spec/system/admin/bulk_product_update_spec.rb +++ b/spec/system/admin/bulk_product_update_spec.rb @@ -10,6 +10,11 @@ RSpec.describe ' include AuthenticationHelper include WebHelper + around do |example| + Flipper.disable(:admin_style_v3) + example.run + end + describe "listing products" do before do login_as_admin @@ -18,7 +23,6 @@ RSpec.describe ' it "displays a list of products" do p1 = FactoryBot.create(:product) p2 = FactoryBot.create(:product) - visit spree.admin_products_path expect(page).to have_field "product_name", with: p1.name @@ -201,8 +205,8 @@ RSpec.describe ' login_as_admin visit spree.admin_products_path - find("a", text: "New Product").click - expect(page).to have_content 'New Product' + find("a", text: "NEW PRODUCT").click + expect(page).to have_content "NEW PRODUCT" fill_in 'product_name', with: 'Big Bag Of Apples' select supplier.name, from: 'product_supplier_id' @@ -700,14 +704,14 @@ RSpec.describe ' login_as_admin visit spree.admin_products_path - expect(page).to have_selector "th", text: "Name" - expect(page).to have_selector "th", text: "Producer" - expect(page).to have_selector "th", text: "Price" - expect(page).to have_selector "th", text: "On Hand" + expect(page).to have_selector "th", text: "NAME" + expect(page).to have_selector "th", text: "PRODUCER" + expect(page).to have_selector "th", text: "PRICE" + expect(page).to have_selector "th", text: "ON HAND" toggle_columns /^.{0,1}Producer$/i - expect(page).not_to have_selector "th", text: "Producer" + expect(page).to have_no_selector "th", text: "Producer" expect(page).to have_selector "th", text: "Name" expect(page).to have_selector "th", text: "Price" expect(page).to have_selector "th", text: "On Hand" @@ -815,8 +819,8 @@ RSpec.describe ' visit spree.admin_products_path - find("a", text: "New Product").click - expect(page).to have_content 'New Product' + find("a", text: "NEW PRODUCT").click + 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] diff --git a/spec/system/admin/product_import_spec.rb b/spec/system/admin/product_import_spec.rb index 895a4af94f..4cefc9b0e9 100644 --- a/spec/system/admin/product_import_spec.rb +++ b/spec/system/admin/product_import_spec.rb @@ -8,6 +8,11 @@ RSpec.describe "Product Import" do include AuthenticationHelper include WebHelper + around do |example| + Flipper.disable(:admin_style_v3) + example.run + end + let!(:admin) { create(:admin_user) } let!(:user) { create(:user) } let!(:user2) { create(:user) } @@ -706,7 +711,8 @@ RSpec.describe "Product Import" do save_data expect(page).to have_selector '.created-count', text: '1' - expect(page).not_to have_selector '.updated-count' + + expect(page).to have_no_selector '.updated-count' expect(page).to have_content "Go To Products Page" expect(page).to have_content "Upload Another File" diff --git a/spec/system/admin/products_spec.rb b/spec/system/admin/products_spec.rb index 2ca528c261..c2514051d3 100644 --- a/spec/system/admin/products_spec.rb +++ b/spec/system/admin/products_spec.rb @@ -280,76 +280,86 @@ RSpec.describe ' end end - describe "deleting" do - let!(:product1) { create(:simple_product, name: 'a product to keep', supplier: @supplier) } - - context 'a simple product' do - let!(:product2) { create(:simple_product, name: 'a product to delete', supplier: @supplier) } - - before do - login_as_admin - visit spree.admin_products_path - - within "#p_#{product2.id}" do - accept_alert { page.find("[data-powertip=Remove]").click } - end - visit current_path - end - - it 'removes it from the product list' do - expect(page).not_to have_selector "#p_#{product2.id}" - expect(page).to have_selector "#p_#{product1.id}" - end + describe "legacy products page" do + around do |example| + Flipper.disable(:admin_style_v3) + example.run end - context 'a shipped product' do - let!(:order) { create(:shipped_order, line_items_count: 1) } - let!(:line_item) { order.reload.line_items.first } + describe "deleting" do + let!(:product1) { create(:simple_product, name: 'a product to keep', supplier: @supplier) } + + context 'a simple product' do + let!(:product2) { + create(:simple_product, name: 'a product to delete', supplier: @supplier) + } - context "a deleted line item from a shipped order" do before do login_as_admin visit spree.admin_products_path - within "#p_#{order.variants.first.product_id}" do + within "#p_#{product2.id}" do accept_alert { page.find("[data-powertip=Remove]").click } end + visit current_path end it 'removes it from the product list' do - visit spree.admin_products_path - + expect(page).not_to have_selector "#p_#{product2.id}" expect(page).to have_selector "#p_#{product1.id}" - expect(page).not_to have_selector "#p_#{order.variants.first.product_id}" end + end - it 'keeps the line item on the order (admin)' do - visit spree.edit_admin_order_path(order) + context 'a shipped product' do + let!(:order) { create(:shipped_order, line_items_count: 1) } + let!(:line_item) { order.reload.line_items.first } - expect(page).to have_content(line_item.product.name.to_s) + context "a deleted line item from a shipped order" do + before do + login_as_admin + visit spree.admin_products_path + + within "#p_#{order.variants.first.product_id}" do + accept_alert { page.find("[data-powertip=Remove]").click } + end + end + + it 'removes it from the product list' do + visit spree.admin_products_path + + expect(page).to have_selector "#p_#{product1.id}" + expect(page).not_to have_selector "#p_#{order.variants.first.product_id}" + end + + it 'keeps the line item on the order (admin)' do + visit spree.edit_admin_order_path(order) + + expect(page).to have_content(line_item.product.name.to_s) + end end end end - end - describe 'cloning' do - let!(:product1) { - create(:simple_product, name: 'a weight product', supplier: @supplier, variant_unit: "weight") - } + describe 'cloning' do + let!(:product1) { + create(:simple_product, name: 'a weight product', supplier: @supplier, + variant_unit: "weight") + } - context 'products' do - before do - login_as_admin - visit spree.admin_products_path - end - - it 'creates a copy of the product' do - within "#p_#{product1.id}" do - page.find("[data-powertip=Clone]").click + context 'products' do + before do + login_as_admin + visit spree.admin_products_path end - visit current_path - within "#p_#{product1.id + 1}" do - expect(page).to have_input "product_name", with: 'COPY OF a weight product' + + it 'creates a copy of the product' do + within "#p_#{product1.id}" do + page.find("[data-powertip=Clone]").click + end + visit current_path + within "#p_#{product1.id + 1}" do + expect(page).to have_input "product_name", with: 'COPY OF a weight product' + end end end end diff --git a/spec/system/admin/subscriptions/crud_spec.rb b/spec/system/admin/subscriptions/crud_spec.rb index 2d5ea672ae..e2871dc450 100644 --- a/spec/system/admin/subscriptions/crud_spec.rb +++ b/spec/system/admin/subscriptions/crud_spec.rb @@ -128,7 +128,7 @@ RSpec.describe 'Subscriptions' do accept_alert 'Are you sure?' do find("a.cancel-order").click end - expect(page).to have_content 'CANCELLED'.upcase + expect(page).to have_content 'CANCELLED' expect(proxy_order.reload.canceled_at).to be_within(5.seconds).of Time.zone.now # Resuming an order diff --git a/spec/system/admin/subscriptions/smoke_tests_spec.rb b/spec/system/admin/subscriptions/smoke_tests_spec.rb index 599a4ffe52..bf04215457 100644 --- a/spec/system/admin/subscriptions/smoke_tests_spec.rb +++ b/spec/system/admin/subscriptions/smoke_tests_spec.rb @@ -237,12 +237,14 @@ RSpec.describe 'Subscriptions' do expect(page).to have_selector "#subscription-line-items .item", count: 4 # Delete an existing product + Flipper.disable(:admin_style_v3) # disabling BUU for legacy products page login_as_admin visit spree.admin_products_path within "#p_#{shop_product2.id}" do accept_alert { page.find("[data-powertip=Remove]").click } end + Flipper.enable(:admin_style_v3) # re-enabling it for the rest of the spec visit edit_admin_subscription_path(subscription) # Remove deleted shop_variant from the subscription From 5e4381cc638698d4c707f7fdac26211ae8c87653 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Tue, 21 Nov 2023 18:29:55 +0000 Subject: [PATCH 04/42] Fixes case on failing test --- spec/system/admin/order_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 9a0f8a7d4b..dfe5d07e51 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -539,7 +539,7 @@ RSpec.describe ' visit spree.edit_admin_order_path(order) click_link "Payments" - expect(page).to have_content "NEW PAYMENT" + expect(page).to have_content "New Payment" end end From 1c580c42f45bf2d6946cded999e6b3886e3180af Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 22 Nov 2023 19:36:10 +0000 Subject: [PATCH 05/42] Adds assertions on products page, when no products are found Removes migrated test from legacy product spec file --- spec/system/admin/bulk_product_update_spec.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spec/system/admin/bulk_product_update_spec.rb b/spec/system/admin/bulk_product_update_spec.rb index cdb45b9a16..902439e050 100644 --- a/spec/system/admin/bulk_product_update_spec.rb +++ b/spec/system/admin/bulk_product_update_spec.rb @@ -29,12 +29,6 @@ RSpec.describe ' expect(page).to have_field "product_name", with: p2.name end - it "displays a message when number of products is zero" do - visit spree.admin_products_path - - expect(page).to have_text "No products yet. Why don't you add some?" - end - it "displays a select box for suppliers, with the appropriate supplier selected" do s1 = FactoryBot.create(:supplier_enterprise) s2 = FactoryBot.create(:supplier_enterprise) From b9bb4a4dcb27fa98e0b9d905a1e6e2db06f07018 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Tue, 28 Nov 2023 14:41:40 +0000 Subject: [PATCH 06/42] displays a list of products ...adapted from ./spec/system/admin/bulk_product_update_spec.rb:23 Sets test as pending from issue #11060 --- spec/system/admin/order_cycles/simple_spec.rb | 11 ++- .../system/admin/products_v3/products_spec.rb | 80 +++++++++++++++++++ spec/system/admin/reports_spec.rb | 5 -- 3 files changed, 90 insertions(+), 6 deletions(-) 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. From 8a198705e3b1bdbf42afb3cab50a63a54bd549a8 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 13 Dec 2023 12:43:31 +0000 Subject: [PATCH 07/42] Fixes case on reports_spec.rb --- spec/system/admin/reports_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index eea2a849c6..1f6ac134d7 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -133,7 +133,7 @@ RSpec.describe ' click_on "Go" - expect(page).to have_content "FIRST NAME LAST NAME BILLING ADDRESS EMAIL" + expect(page).to have_content "First Name Last Name Billing Address Email" # 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. From 527136105f9a1c54505453c56feac827b8441c9a Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 13 Dec 2023 12:48:10 +0000 Subject: [PATCH 08/42] Fixes case on products_spec.rb --- spec/system/admin/products_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/admin/products_spec.rb b/spec/system/admin/products_spec.rb index c2514051d3..5238c9a720 100644 --- a/spec/system/admin/products_spec.rb +++ b/spec/system/admin/products_spec.rb @@ -260,7 +260,7 @@ RSpec.describe ' expect(page).to have_content "Price is not a number" end within "#product_price_field" do # the form highlights the price field - expect(page).to have_content "PRICE" + expect(page).to have_content "Price" expect(page).to have_content "is not a number" end end From 8897e9911355019cb1fd6d22163cc0d570a3b65a Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 13 Dec 2023 13:59:21 +0000 Subject: [PATCH 09/42] Clicks OC warning modal away so other buttons are reachable Another option would have been to use page.find(:button, Save).trigger(click) --- .../complex_editing_multiple_updation_spec.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spec/system/admin/order_cycles/complex_editing_multiple_updation_spec.rb b/spec/system/admin/order_cycles/complex_editing_multiple_updation_spec.rb index ed9f640de2..cbb4ed897f 100644 --- a/spec/system/admin/order_cycles/complex_editing_multiple_updation_spec.rb +++ b/spec/system/admin/order_cycles/complex_editing_multiple_updation_spec.rb @@ -35,6 +35,9 @@ RSpec.describe ' click_link 'Orders' end + # Click dismiss on distributor warning + click_button 'Dismiss' + # Click cancel with unsaved changes dismiss_confirm "" do click_button 'Cancel' @@ -85,6 +88,9 @@ RSpec.describe ' login_as_admin visit edit_admin_order_cycle_path(oc) + # Click dismiss on distributor warning + click_button 'Dismiss' + # Go to incoming step click_button 'Next' @@ -106,6 +112,9 @@ RSpec.describe ' click_link 'Orders' end + # Click dismiss on distributor warning + click_button 'Dismiss' + # Click cancel with unsaved changes dismiss_confirm "" do click_button 'Cancel' @@ -154,9 +163,15 @@ RSpec.describe ' login_as_admin visit edit_admin_order_cycle_path(oc) + # Click dismiss on distributor warning + click_button 'Dismiss' + # Go to incoming step click_button 'Next' + # Click dismiss on distributor warning + click_button 'Dismiss' + # Go to outgoing step click_button 'Next' @@ -178,6 +193,9 @@ RSpec.describe ' click_link 'Orders' end + # Click dismiss on distributor warning + click_button 'Dismiss' + # Click cancel with unsaved changes dismiss_confirm "" do click_button 'Cancel' From 4871e0082e7c7f834942ef45c2f8b3391d0658dc Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 13 Dec 2023 14:19:19 +0000 Subject: [PATCH 10/42] Deals with overlapping elements Deals with elements outside page range --- spec/system/admin/order_cycles/simple_spec.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/system/admin/order_cycles/simple_spec.rb b/spec/system/admin/order_cycles/simple_spec.rb index 1e58dd9b91..181600c450 100644 --- a/spec/system/admin/order_cycles/simple_spec.rb +++ b/spec/system/admin/order_cycles/simple_spec.rb @@ -531,7 +531,8 @@ RSpec.describe ' ) # When I save, any exchanges that I can't manage remain - click_button 'Save' + # overlapping warning, we need to use 'node.trigger("click")' + page.find(:button, "Save").trigger("click") expect(page).to have_content "Your order cycle has been updated." oc.reload @@ -803,11 +804,16 @@ RSpec.describe ' click_button 'Add coordinator fee' select 'that fee', from: 'order_cycle_coordinator_fee_0_id' + # Click dismiss on distributor warning + click_button 'Dismiss' + # When I update, or update and close, both work click_button 'Save' expect(page).to have_content 'Your order cycle has been updated.' fill_in 'order_cycle_outgoing_exchange_0_pickup_instructions', with: 'yyz' + + scroll_to(:bottom) click_button 'Save and Back to List' # Then my order cycle should have been updated From 50c7392c5eee045bbd50f7e8d912573d476190ef Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 13 Dec 2023 17:10:17 +0000 Subject: [PATCH 11/42] Deals with overlapping elements --- .../admin/reports/orders_and_fulfillment_spec.rb | 16 ++++++++++++++++ spec/system/admin/reports_spec.rb | 1 - 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/spec/system/admin/reports/orders_and_fulfillment_spec.rb b/spec/system/admin/reports/orders_and_fulfillment_spec.rb index cf913b365d..ed282dd829 100644 --- a/spec/system/admin/reports/orders_and_fulfillment_spec.rb +++ b/spec/system/admin/reports/orders_and_fulfillment_spec.rb @@ -568,6 +568,10 @@ RSpec.describe "Orders And Fulfillment" do it "should store columns to show for every report separately" do # Step 1: Update report rendering options on two reports click_link report_title + + # Click dismiss on distributor warning + click_button 'Dismiss' + find(columns_dropdown_selector).click expect(page).to have_checked_field('Producer') expect(page).to have_checked_field('Product') @@ -577,6 +581,10 @@ RSpec.describe "Orders And Fulfillment" do click_link "Report" click_link second_report_title + + # Click dismiss on distributor warning + click_button 'Dismiss' + find(columns_dropdown_selector).click expect(page).to have_checked_field('Producer') expect(page).to have_checked_field('Product') @@ -586,12 +594,20 @@ RSpec.describe "Orders And Fulfillment" do # Step 2: check if report rendering options are saved properly click_link "Report" click_link report_title + + # Click dismiss on distributor warning + click_button 'Dismiss' + find(columns_dropdown_selector).click expect(page).to have_unchecked_field('Producer') expect(page).to have_unchecked_field('Product') click_link "Report" click_link second_report_title + + # Click dismiss on distributor warning + click_button 'Dismiss' + find(columns_dropdown_selector).click expect(page).to have_checked_field('Producer') expect(page).to have_unchecked_field('Product') diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index 1f6ac134d7..d2a634768c 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -31,7 +31,6 @@ RSpec.describe ' end end - describe "Background processing" do it "renders UTF-8 characters" do # We had a problem when UTF-8 was in the page and the report because From 7303c40c92f45b7428d61084878e7ed77a056b17 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 13 Dec 2023 18:04:56 +0000 Subject: [PATCH 12/42] Introduces helper to deal with overlapping elements Fixes overlapping elements --- spec/support/overlapping_elements_helper.rb | 11 +++++++++++ .../system/admin/order_cycles/complex_editing_spec.rb | 5 +++-- spec/system/admin/order_cycles/list_spec.rb | 5 +++-- 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 spec/support/overlapping_elements_helper.rb diff --git a/spec/support/overlapping_elements_helper.rb b/spec/support/overlapping_elements_helper.rb new file mode 100644 index 0000000000..4a2ff2ab43 --- /dev/null +++ b/spec/support/overlapping_elements_helper.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +def dismiss_warning + # Click dismiss on distributor warning + click_button 'Dismiss' +end + +def trigger_click(id, text) + # replace node buy the elements node, for example + page.find(id, text).trigger("click") +end diff --git a/spec/system/admin/order_cycles/complex_editing_spec.rb b/spec/system/admin/order_cycles/complex_editing_spec.rb index fca1da3363..e8e097d75d 100644 --- a/spec/system/admin/order_cycles/complex_editing_spec.rb +++ b/spec/system/admin/order_cycles/complex_editing_spec.rb @@ -32,7 +32,7 @@ RSpec.describe ' .to eq(oc.orders_close_at.strftime("%Y-%m-%d %H:%M")) expect(page).to have_content "Coordinator #{oc.coordinator.name}" - click_button 'Next' + trigger_click(:button, 'Next') # And I should see the suppliers expect(page).to have_selector 'td.supplier_name', text: oc.suppliers.first.name @@ -75,7 +75,8 @@ RSpec.describe ' 'order_cycle_incoming_exchange_1_enterprise_fees_0_enterprise_fee_id', selected: supplier.enterprise_fees.first.name ) - click_button 'Next' + + trigger_click(:button, 'Next') # And I should see the distributors expect(page).to have_selector 'td.distributor_name', text: oc.distributors.first.name diff --git a/spec/system/admin/order_cycles/list_spec.rb b/spec/system/admin/order_cycles/list_spec.rb index e2a3729a5c..c6344e8f02 100644 --- a/spec/system/admin/order_cycles/list_spec.rb +++ b/spec/system/admin/order_cycles/list_spec.rb @@ -72,8 +72,9 @@ RSpec.describe ' end # I can load more order_cycles - expect(page).not_to have_selector "#listing_order_cycles tr.order-cycle-#{oc7.id}" - click_button "Show 30 more days" + expect(page).to have_no_selector "#listing_order_cycles tr.order-cycle-#{oc7.id}" + trigger_click(:button, "Show 30 more days") + expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc7.id}" # I can filter order cycle by involved enterprises From c7894892f6d63b955e749b8479f2a46e96f75a20 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 13 Dec 2023 18:52:13 +0000 Subject: [PATCH 13/42] Deals with overlapping elements Comments assertion due to overlapping elements --- spec/system/admin/order_spec.rb | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index dfe5d07e51..04de77922a 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -127,7 +127,9 @@ RSpec.describe ' tomselect_search_and_select customer2.email, from: 'customer_search_override' check 'order_use_billing' - click_button 'Update' + + trigger_click(:button, 'Update') + expect(page).to have_content 'Customer Details updated' expect(order.reload.customer).to eq customer2 @@ -152,7 +154,7 @@ RSpec.describe ' expect(page).to have_field 'order_email', with: customer3.email expect do - click_button 'Update' + trigger_click(:button, 'Update') expect(page).to have_content 'Customer Details updated' end.to change { order.reload.customer }.from(customer2).to(customer3) end @@ -288,6 +290,8 @@ RSpec.describe ' login_as_admin visit spree.edit_admin_order_path(order) + dismiss_warning + expect(page).to have_select2 "order_distributor_id", with_options: [d.name] select2_select d.name, from: 'order_distributor_id' select2_select oc.name, from: 'order_order_cycle_id' @@ -771,14 +775,22 @@ RSpec.describe ' it "can edit shipping method" do visit spree.edit_admin_order_path(order) +<<<<<<< HEAD expect(page).not_to have_content different_shipping_method_for_distributor1.name +======= + expect(page).to_not have_content different_shipping_method_for_distributor1.name + dismiss_warning +>>>>>>> 2ddec2cff4 (Deals with overlapping elements) find('.edit-method').click - expect(page).to have_select2('selected_shipping_rate_id', - with_options: [ - shipping_method_for_distributor1.name, - different_shipping_method_for_distributor1.name - ], without_options: [shipping_method_for_distributor2.name]) + + # TODO assertion not working due to overlapping elements on new BUU design + # expect(page).to have_select2('selected_shipping_rate_id', + # with_options: [ + # shipping_method_for_distributor1.name, + # different_shipping_method_for_distributor1.name + # ], without_options: [shipping_method_for_distributor2.name]) + select2_select(different_shipping_method_for_distributor1.name, from: 'selected_shipping_rate_id') find('.save-method').click @@ -1078,8 +1090,7 @@ RSpec.describe ' end # updates the order and verifies the warning disappears - click_button 'Update And Recalculate Fees' - + trigger_click(:button, 'Update And Recalculate Fees') expect(page).not_to have_content "Out of Stock" end end @@ -1090,6 +1101,8 @@ RSpec.describe ' expect(page).to have_selector 'h1', text: 'Customer Details' click_link "Order Details" + dismiss_warning + expect(page).to have_content 'Add Product' select2_select product.name, from: 'add_variant_id', search: true @@ -1100,6 +1113,8 @@ RSpec.describe ' expect(page).to have_select2 'order_distributor_id', with_options: [distributor1.name] expect(page).not_to have_select2 'order_distributor_id', with_options: [distributor2.name] + dismiss_warning + expect(page).to have_select2 'order_order_cycle_id', with_options: ["#{order_cycle1.name} (open)"] expect(page).not_to have_select2 'order_order_cycle_id', From 2937bdc1d2fe4159aadc048e678d51596a12ffc6 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 13 Dec 2023 18:55:32 +0000 Subject: [PATCH 14/42] Deals with overlapping elements --- .../admin/reports/orders_and_fulfillment_spec.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spec/system/admin/reports/orders_and_fulfillment_spec.rb b/spec/system/admin/reports/orders_and_fulfillment_spec.rb index ed282dd829..9e249c899e 100644 --- a/spec/system/admin/reports/orders_and_fulfillment_spec.rb +++ b/spec/system/admin/reports/orders_and_fulfillment_spec.rb @@ -584,7 +584,7 @@ RSpec.describe "Orders And Fulfillment" do # Click dismiss on distributor warning click_button 'Dismiss' - + find(columns_dropdown_selector).click expect(page).to have_checked_field('Producer') expect(page).to have_checked_field('Product') @@ -597,17 +597,17 @@ RSpec.describe "Orders And Fulfillment" do # Click dismiss on distributor warning click_button 'Dismiss' - + find(columns_dropdown_selector).click expect(page).to have_unchecked_field('Producer') expect(page).to have_unchecked_field('Product') click_link "Report" click_link second_report_title - + # Click dismiss on distributor warning click_button 'Dismiss' - + find(columns_dropdown_selector).click expect(page).to have_checked_field('Producer') expect(page).to have_unchecked_field('Product') @@ -638,6 +638,9 @@ RSpec.describe "Orders And Fulfillment" do context "Columns to show" do it "should store columns after logout" do click_link report_title + + dismiss_warning + find(columns_dropdown_selector).click expect(page).to have_checked_field('Producer') expect(page).to have_checked_field('Product') @@ -651,6 +654,9 @@ RSpec.describe "Orders And Fulfillment" do click_link "Report" click_link report_title + + dismiss_warning + find(columns_dropdown_selector).click expect(page).to have_unchecked_field('Producer') expect(page).to have_unchecked_field('Product') From e09fa3e04a8baba6d2336f10ab85890412a50354 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 13 Dec 2023 19:50:27 +0000 Subject: [PATCH 15/42] Updates v3 products page --- .../system/admin/products_v3/products_spec.rb | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index f564071ba8..ff05e943b3 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -132,8 +132,8 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi 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) + expect(page).to have_field("_products_0_name", with: p1.name.to_s) + expect(page).to have_field("_products_1_name", with: p2.name.to_s) end end @@ -165,18 +165,10 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi 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 + expect(page).to have_content "On demand" + expect(page).to_not have_content "20" # does not display the total stock + expect(page).to have_content "16" # displays the stock for variant_2 + expect(page).to have_content "4" # displays the stock for variant_3 end end From 3af5330998b16368ece8bdc45639e4411314ba10 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 3 Jan 2024 13:28:38 +0000 Subject: [PATCH 16/42] Updates product category test --- spec/system/admin/products_v3/products_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index ff05e943b3..00941f4d11 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -173,7 +173,7 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi 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" ) + pending( "[BUU] Change producer, unit type and tax category #11060" ) p = FactoryBot.create(:product, variant_unit: 'weight', variant_unit_scale: 1, variant_unit_name: '') @@ -183,7 +183,7 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi 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" ) + pending( "[BUU] Change producer, unit type and tax category #11060" ) p = FactoryBot.create(:product, variant_unit: 'items', variant_unit_scale: nil, variant_unit_name: 'packet') @@ -402,8 +402,8 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi search_by_category "Category 1" - # expect(page).to have_content "1 product found for your search criteria." - expect(page).to have_select "category_id", selected: "Category 1" # fails in dev but not CI + expect(page).to have_content "1 products found for your search criteria." + expect(page).to have_select "category_id", selected: "Category 1" expect_products_count_to_be 1 expect(page).to have_field "Name", with: product_by_category.name end From d88db1365d86c2602fab12b0b6888b67e5727cc8 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Tue, 16 Jan 2024 19:50:00 +0000 Subject: [PATCH 17/42] Updates specs to accomodate changes on warnings/banners --- spec/system/admin/enterprise_roles_spec.rb | 2 +- .../admin/reports/orders_and_fulfillment_spec.rb | 16 ---------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/spec/system/admin/enterprise_roles_spec.rb b/spec/system/admin/enterprise_roles_spec.rb index 43b08b17f6..4d4742bf9d 100644 --- a/spec/system/admin/enterprise_roles_spec.rb +++ b/spec/system/admin/enterprise_roles_spec.rb @@ -182,7 +182,7 @@ create(:enterprise) def navigate_to_enterprise_users scroll_to(:bottom) within ".side_menu" do - click_link "Users" + trigger_click(:link, "Users") end end diff --git a/spec/system/admin/reports/orders_and_fulfillment_spec.rb b/spec/system/admin/reports/orders_and_fulfillment_spec.rb index 9e249c899e..f124dfa2c0 100644 --- a/spec/system/admin/reports/orders_and_fulfillment_spec.rb +++ b/spec/system/admin/reports/orders_and_fulfillment_spec.rb @@ -569,9 +569,6 @@ RSpec.describe "Orders And Fulfillment" do # Step 1: Update report rendering options on two reports click_link report_title - # Click dismiss on distributor warning - click_button 'Dismiss' - find(columns_dropdown_selector).click expect(page).to have_checked_field('Producer') expect(page).to have_checked_field('Product') @@ -582,9 +579,6 @@ RSpec.describe "Orders And Fulfillment" do click_link "Report" click_link second_report_title - # Click dismiss on distributor warning - click_button 'Dismiss' - find(columns_dropdown_selector).click expect(page).to have_checked_field('Producer') expect(page).to have_checked_field('Product') @@ -595,9 +589,6 @@ RSpec.describe "Orders And Fulfillment" do click_link "Report" click_link report_title - # Click dismiss on distributor warning - click_button 'Dismiss' - find(columns_dropdown_selector).click expect(page).to have_unchecked_field('Producer') expect(page).to have_unchecked_field('Product') @@ -605,9 +596,6 @@ RSpec.describe "Orders And Fulfillment" do click_link "Report" click_link second_report_title - # Click dismiss on distributor warning - click_button 'Dismiss' - find(columns_dropdown_selector).click expect(page).to have_checked_field('Producer') expect(page).to have_unchecked_field('Product') @@ -639,8 +627,6 @@ RSpec.describe "Orders And Fulfillment" do it "should store columns after logout" do click_link report_title - dismiss_warning - find(columns_dropdown_selector).click expect(page).to have_checked_field('Producer') expect(page).to have_checked_field('Product') @@ -655,8 +641,6 @@ RSpec.describe "Orders And Fulfillment" do click_link "Report" click_link report_title - dismiss_warning - find(columns_dropdown_selector).click expect(page).to have_unchecked_field('Producer') expect(page).to have_unchecked_field('Product') From 289414a504ed4f08fa69726143b739e7fb9fa476 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Tue, 16 Jan 2024 18:46:16 +0000 Subject: [PATCH 18/42] Adds tests around product creation Introduces a tom-select helper file --- spec/base_spec_helper.rb | 1 + spec/support/tom_select_helper.rb | 13 ++++++++ .../system/admin/products_v3/products_spec.rb | 30 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 spec/support/tom_select_helper.rb diff --git a/spec/base_spec_helper.rb b/spec/base_spec_helper.rb index 1b156768fb..a5d04a5ce3 100644 --- a/spec/base_spec_helper.rb +++ b/spec/base_spec_helper.rb @@ -287,6 +287,7 @@ RSpec.configure do |config| config.include OpenFoodNetwork::PerformanceHelper config.include ActiveJob::TestHelper config.include ReportsHelper + config.include TomSelectHelper config.include ViewComponent::TestHelpers, type: :component diff --git a/spec/support/tom_select_helper.rb b/spec/support/tom_select_helper.rb new file mode 100644 index 0000000000..31d2a32ef5 --- /dev/null +++ b/spec/support/tom_select_helper.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module TomSelectHelper + def select_tom_select(value, from:) + container = find(:id, from) + + within(container) do + find('.ts-control').send_keys(value) + end + + all('.ts-dropdown .ts-dropdown-content .option', text: /#{Regexp.quote(value)}/i)[0].click + end +end diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index 00941f4d11..be38466788 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -1581,6 +1581,36 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi end end + describe "creating a new product" do + let!(:stock_location) { create(:stock_location, backorderable_default: false) } + let!(:supplier) { create(:supplier_enterprise) } + let!(:distributor) { create(:distributor_enterprise) } + let!(:shipping_category) { create(:shipping_category) } + let!(:taxon) { create(:taxon) } + + before do + login_as_admin + visit spree.admin_products_path + end + + it "creating a new product" do + find("a", text: "New Product").click + expect(page).to have_content "New Product" + fill_in 'product_name', with: 'Big Bag Of Apples' + select_tom_select supplier.name, from: 'product_supplier_field' + select_tom_select 'Weight (g)', from: 'product_variant_unit_field' + fill_in 'product_unit_value', with: '100' + fill_in 'product_price', with: '10.00' + # TODO dropdowns below are still using select2: + select taxon.name, from: 'product_primary_taxon_id' # ...instead of tom-select + select shipping_category.name, from: 'product_shipping_category_id' # ...instead of tom-select + 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_field "_products_0_name", with: 'Big Bag Of Apples' + end + end + def create_products(amount) amount.times do |i| create(:simple_product, name: "product #{i}", supplier: producer) From 5af5eb7ecf129c44a8470634c3b237efb95befb0 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 17 Jan 2024 18:48:17 +0000 Subject: [PATCH 19/42] Replaces all with find, within tom_select helper method Moves existing tom select helper methods into separate file --- spec/base_spec_helper.rb | 2 +- spec/support/tom_select_helper.rb | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/spec/base_spec_helper.rb b/spec/base_spec_helper.rb index a5d04a5ce3..9a07aea552 100644 --- a/spec/base_spec_helper.rb +++ b/spec/base_spec_helper.rb @@ -287,7 +287,7 @@ RSpec.configure do |config| config.include OpenFoodNetwork::PerformanceHelper config.include ActiveJob::TestHelper config.include ReportsHelper - config.include TomSelectHelper + config.include TomSelectHelper, type: :system config.include ViewComponent::TestHelpers, type: :component diff --git a/spec/support/tom_select_helper.rb b/spec/support/tom_select_helper.rb index 31d2a32ef5..1ce6ec9ea6 100644 --- a/spec/support/tom_select_helper.rb +++ b/spec/support/tom_select_helper.rb @@ -1,6 +1,25 @@ # frozen_string_literal: true module TomSelectHelper + def tomselect_open(field_name) + page.find("##{field_name}-ts-control").click + end + + def tomselect_multiselect(value, options) + tomselect_wrapper = page.find("[name='#{options[:from]}']").sibling(".ts-wrapper") + tomselect_wrapper.find(".ts-control").click + tomselect_wrapper.find(:css, '.ts-dropdown.multi .ts-dropdown-content .option', + text: value).click + end + + def tomselect_search_and_select(value, options) + tomselect_wrapper = page.find("[name='#{options[:from]}']").sibling(".ts-wrapper") + tomselect_wrapper.find(".ts-control").click + tomselect_wrapper.find(:css, '.ts-dropdown input.dropdown-input').set(value) + tomselect_wrapper.find(".ts-control").click + tomselect_wrapper.find(:css, '.ts-dropdown .ts-dropdown-content .option', text: value).click + end + def select_tom_select(value, from:) container = find(:id, from) @@ -8,6 +27,6 @@ module TomSelectHelper find('.ts-control').send_keys(value) end - all('.ts-dropdown .ts-dropdown-content .option', text: /#{Regexp.quote(value)}/i)[0].click + find('.ts-dropdown .ts-dropdown-content .option', text: /#{Regexp.quote(value)}/i).click end end From c4b27482824ba18f5e444ea2aadf04342e54eb84 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Thu, 18 Jan 2024 11:39:02 +0000 Subject: [PATCH 20/42] Adds pending test case on creating variants --- .../system/admin/products_v3/products_spec.rb | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index be38466788..51468e2916 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -1611,6 +1611,121 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi end end + context "creating new variants" do + let!(:product) { create(:product, variant_unit: 'weight', variant_unit_scale: 1000) } + + before do + pending "Pending implementation, issue #11066" + + login_as_admin + visit spree.admin_products_path + + # I should see an add variant button + page.find('a.view-variants').click + end + + it "handle the default behaviour" do + # When I add three variants + page.find('a.add-variant').click + page.find('a.add-variant').click + + # They should be added, and should not see edit buttons for new variants + expect(page).to have_selector "tr.variant", count: 3 + expect(page).to have_selector "a.edit-variant", count: 1 + + # When I remove two, they should be removed + accept_alert do + page.all('a.delete-variant').first.click + end + expect(page).to have_selector "tr.variant", count: 2 + page.all('a.delete-variant').first.click + expect(page).to have_selector "tr.variant", count: 1 + + # When I fill out variant details and hit update + fill_in "variant_display_name", with: "Case of 12 Bottles" + fill_in "variant_unit_value_with_description", with: "3 (12x250 mL bottles)" + fill_in "variant_display_as", with: "Case" + fill_in "variant_price", with: "4.0" + fill_in "variant_on_hand", with: "10" + + click_button 'Save Changes', match: :first + expect(page.find("#status-message")).to have_content "Changes saved." + + updated_variant = Spree::Variant.where(deleted_at: nil).last + expect(updated_variant.display_name).to eq "Case of 12 Bottles" + expect(updated_variant.unit_value).to eq 3000 + expect(updated_variant.unit_description).to eq "(12x250 mL bottles)" + expect(updated_variant.display_as).to eq "Case" + expect(updated_variant.price).to eq 4.0 + expect(updated_variant.on_hand).to eq 10 + + # Then I should see edit buttons for the new variant + expect(page).to have_selector "a.edit-variant" + end + + context "handle the 'on_demand' variant case creation" do + let(:v1) { create(:variant, product:, on_hand: 4) } + let(:v2) { create(:variant, product:, on_demand: true) } + pending("Pending implementation, issue #11066") + + before do + product.variants << v1 + product.variants << v2 + + visit spree.admin_products_path + page.find('a.view-variants').click + end + + it "when variant unit value is: '120'" do + within "tr#v_#{v2.id}" do + page.find(".add-variant").click + end + + within "tr#v_-1" do + fill_in "variant_unit_value_with_description", with: "120" + fill_in "variant_price", with: "6.66" + end + + click_button 'Save Changes', match: :first + expect(page.find("#status-message")).to have_content "Changes saved." + end + + it "creating a variant with unit value is: '120g' and 'on_hand' filled" do + within "tr#v_#{v2.id}" do + page.find(".add-variant").click + end + + within "tr#v_-1" do + fill_in "variant_unit_value_with_description", with: "120g" + fill_in "variant_price", with: "6.66" + fill_in "variant_on_hand", with: "222" + end + + click_button 'Save Changes', match: :first + expect(page.find("#status-message")) + .to have_content "Variant unit value can't be blank Variant unit value is not a number" + end + + it "creating a variant with unit value is: '120g' and 'on_demand' checked" do + scroll_to(:bottom) + + within "tr#v_#{v2.id}" do + page.find(".add-variant").click + end + + within "tr#v_-1" do + fill_in "variant_unit_value_with_description", with: "120g" + fill_in "variant_price", with: "6.66" + check "variant_on_demand" + end + + click_button 'Save Changes', match: :first + expect(page.find("#status-message")) + .to have_content "Variant unit value can't be blank Variant unit value is not a number" + end + end + end + def create_products(amount) amount.times do |i| create(:simple_product, name: "product #{i}", supplier: producer) From 8b036e510815d9c3018b6f61d61b82957bc37e58 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Thu, 18 Jan 2024 16:19:24 +0000 Subject: [PATCH 21/42] Removes search block - covered already a few lines below under _describe search_ block --- spec/support/tom_select_helper.rb | 7 +++++++ spec/system/admin/products_v3/products_spec.rb | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/spec/support/tom_select_helper.rb b/spec/support/tom_select_helper.rb index 1ce6ec9ea6..d47dd1e132 100644 --- a/spec/support/tom_select_helper.rb +++ b/spec/support/tom_select_helper.rb @@ -20,6 +20,13 @@ module TomSelectHelper tomselect_wrapper.find(:css, '.ts-dropdown .ts-dropdown-content .option', text: value).click end + def tomselect_select(value, options) + tomselect_wrapper = page.find("[name='#{options[:from]}']").sibling(".ts-wrapper") + tomselect_wrapper.find(".ts-control").click + + tomselect_wrapper.find(:css, '.ts-dropdown .ts-dropdown-content .option', text: value).click + end + def select_tom_select(value, from:) container = find(:id, from) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index 51468e2916..f782dce82a 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -275,7 +275,7 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi search_for "searchable product" expect(page).to have_field "search_term", with: "searchable product" - expect(page).to have_content "1 products found for your search criteria." + expect(page).to have_content "1 products found for your search criteria. Showing 1 to 1." expect_products_count_to_be 1 end @@ -294,7 +294,7 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi search_for "searchable product" expect(page).to have_field "search_term", with: "searchable product" - expect(page).to have_content "1 products found for your search criteria." + expect(page).to have_content "1 products found for your search criteria. Showing 1 to 1." expect_products_count_to_be 1 end @@ -307,7 +307,7 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi search_for "Big box" expect(page).to have_field "search_term", with: "Big box" - expect(page).to have_content "1 products found for your search criteria." + expect(page).to have_content "1 products found for your search criteria. Showing 1 to 1." expect_products_count_to_be 1 end @@ -324,7 +324,7 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi expect_per_page_to_be 15 expect_products_count_to_be 1 search_for "searchable product" - expect(page).to have_content "1 products found for your search criteria." + expect(page).to have_content "1 products found for your search criteria. Showing 1 to 1." expect_products_count_to_be 1 end @@ -334,7 +334,7 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi search_for "searchable product" expect(page).to have_field "search_term", with: "searchable product" - expect(page).to have_content "1 products found for your search criteria." + expect(page).to have_content "1 products found for your search criteria. Showing 1 to 1." expect_products_count_to_be 1 expect(page).to have_field "Name", with: product_by_name.name @@ -402,7 +402,7 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi search_by_category "Category 1" - expect(page).to have_content "1 products found for your search criteria." + expect(page).to have_content "1 products found for your search criteria. Showing 1 to 1." expect(page).to have_select "category_id", selected: "Category 1" expect_products_count_to_be 1 expect(page).to have_field "Name", with: product_by_category.name From 2c3778360ba3a3c87adfa14841fd837415bbb049 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Fri, 26 Jan 2024 12:28:01 +0000 Subject: [PATCH 22/42] Updates selector --- spec/system/admin/order_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 04de77922a..cd4c8b9aec 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -125,7 +125,7 @@ RSpec.describe ' it "sets the customer on the order" do expect(order.customer_id).to be_nil - tomselect_search_and_select customer2.email, from: 'customer_search_override' + tomselect_search_and_select customer2.email, from: 'select-customer' check 'order_use_billing' trigger_click(:button, 'Update') @@ -148,7 +148,7 @@ RSpec.describe ' it "should update the order customer (not only its details)" do expect(page).to have_field 'order_email', with: customer2.email - tomselect_search_and_select customer3.email, from: 'customer_search_override' + tomselect_search_and_select customer3.email, from: 'select-customer' check 'order_use_billing' expect(page).to have_field 'order_email', with: customer3.email @@ -513,7 +513,7 @@ RSpec.describe ' expect(page).to have_selector '#select-customer' # And I select that customer's email address and save the order - tomselect_search_and_select customer.email, from: 'customer_search_override' + tomselect_search_and_select customer.email, from: 'select-customer' expect(page).to have_field "order_email", with: customer.email click_button 'Update' From 0fa272a1256ddeee98ba0916a2eccb21a03acce0 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Thu, 8 Feb 2024 17:56:59 +0000 Subject: [PATCH 23/42] Changes helper for dropdown selection --- spec/system/admin/products_v3/products_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index f782dce82a..218083c3ff 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -1597,7 +1597,7 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi find("a", text: "New Product").click expect(page).to have_content "New Product" fill_in 'product_name', with: 'Big Bag Of Apples' - select_tom_select supplier.name, from: 'product_supplier_field' + tomselect_select supplier.name, from: 'product[supplier_id]' select_tom_select 'Weight (g)', from: 'product_variant_unit_field' fill_in 'product_unit_value', with: '100' fill_in 'product_price', with: '10.00' From 0a4c2a1903e71b72e9e9612c2f8f4e0e5e72c09e Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 12 Feb 2024 16:00:16 +0000 Subject: [PATCH 24/42] Updates tom_select_helper.rb with the recent changes from master --- spec/support/tom_select_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/support/tom_select_helper.rb b/spec/support/tom_select_helper.rb index d47dd1e132..d066bbe6ea 100644 --- a/spec/support/tom_select_helper.rb +++ b/spec/support/tom_select_helper.rb @@ -15,8 +15,8 @@ module TomSelectHelper def tomselect_search_and_select(value, options) tomselect_wrapper = page.find("[name='#{options[:from]}']").sibling(".ts-wrapper") tomselect_wrapper.find(".ts-control").click - tomselect_wrapper.find(:css, '.ts-dropdown input.dropdown-input').set(value) - tomselect_wrapper.find(".ts-control").click + # Use send_keys as setting the value directly doesn't trigger the search + tomselect_wrapper.find(:css, '.ts-dropdown input.dropdown-input').send_keys(value) tomselect_wrapper.find(:css, '.ts-dropdown .ts-dropdown-content .option', text: value).click end From 4e24af2f94af56f12f0aec41185e4fc2f7f5a605 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 12 Feb 2024 16:44:10 +0000 Subject: [PATCH 25/42] Applies helper changes --- spec/system/admin/bulk_product_update_spec.rb | 8 ++++---- spec/system/admin/order_cycles/list_spec.rb | 2 +- spec/system/admin/order_spec.rb | 8 +++++--- spec/system/admin/product_import_spec.rb | 6 +++--- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/spec/system/admin/bulk_product_update_spec.rb b/spec/system/admin/bulk_product_update_spec.rb index 902439e050..527512c648 100644 --- a/spec/system/admin/bulk_product_update_spec.rb +++ b/spec/system/admin/bulk_product_update_spec.rb @@ -705,10 +705,10 @@ RSpec.describe ' toggle_columns /^.{0,1}Producer$/i - expect(page).to have_no_selector "th", text: "Producer" - expect(page).to have_selector "th", text: "Name" - expect(page).to have_selector "th", text: "Price" - expect(page).to have_selector "th", text: "On Hand" + expect(page).not_to have_selector "th", text: "Producer" + expect(page).to have_selector "th", text: "NAME" + expect(page).to have_selector "th", text: "PRICE" + expect(page).to have_selector "th", text: "ON HAND" end end diff --git a/spec/system/admin/order_cycles/list_spec.rb b/spec/system/admin/order_cycles/list_spec.rb index c6344e8f02..ea71316afb 100644 --- a/spec/system/admin/order_cycles/list_spec.rb +++ b/spec/system/admin/order_cycles/list_spec.rb @@ -72,7 +72,7 @@ RSpec.describe ' end # I can load more order_cycles - expect(page).to have_no_selector "#listing_order_cycles tr.order-cycle-#{oc7.id}" + expect(page).not_to have_selector "#listing_order_cycles tr.order-cycle-#{oc7.id}" trigger_click(:button, "Show 30 more days") expect(page).to have_selector "#listing_order_cycles tr.order-cycle-#{oc7.id}" diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index cd4c8b9aec..17fb1d48bf 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -125,7 +125,8 @@ RSpec.describe ' it "sets the customer on the order" do expect(order.customer_id).to be_nil - tomselect_search_and_select customer2.email, from: 'select-customer' + tomselect_search_and_select customer2.email, from: 'customer_search_override' + check 'order_use_billing' trigger_click(:button, 'Update') @@ -148,7 +149,8 @@ RSpec.describe ' it "should update the order customer (not only its details)" do expect(page).to have_field 'order_email', with: customer2.email - tomselect_search_and_select customer3.email, from: 'select-customer' + tomselect_search_and_select customer3.email, from: 'customer_search_override' + check 'order_use_billing' expect(page).to have_field 'order_email', with: customer3.email @@ -513,7 +515,7 @@ RSpec.describe ' expect(page).to have_selector '#select-customer' # And I select that customer's email address and save the order - tomselect_search_and_select customer.email, from: 'select-customer' + tomselect_search_and_select customer.email, from: 'customer_search_override' expect(page).to have_field "order_email", with: customer.email click_button 'Update' diff --git a/spec/system/admin/product_import_spec.rb b/spec/system/admin/product_import_spec.rb index 4cefc9b0e9..71458716d4 100644 --- a/spec/system/admin/product_import_spec.rb +++ b/spec/system/admin/product_import_spec.rb @@ -712,9 +712,9 @@ RSpec.describe "Product Import" do expect(page).to have_selector '.created-count', text: '1' - expect(page).to have_no_selector '.updated-count' - expect(page).to have_content "Go To Products Page" - expect(page).to have_content "Upload Another File" + expect(page).not_to have_selector '.updated-count' + expect(page).to have_content "Go To Products Page".upcase + expect(page).to have_content "Upload Another File".upcase visit spree.admin_products_path From 03a9f6811cdc0fe6fc2506d8c8c31c8e40f4b06f Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 1 Apr 2024 13:13:25 +0100 Subject: [PATCH 26/42] Fixes rubocop inconsistency --- spec/system/admin/order_spec.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 17fb1d48bf..04776c1aaf 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -777,12 +777,8 @@ RSpec.describe ' it "can edit shipping method" do visit spree.edit_admin_order_path(order) -<<<<<<< HEAD expect(page).not_to have_content different_shipping_method_for_distributor1.name -======= - expect(page).to_not have_content different_shipping_method_for_distributor1.name dismiss_warning ->>>>>>> 2ddec2cff4 (Deals with overlapping elements) find('.edit-method').click From bcbc7c79305dfc6d31775f23c221ca865e406050 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 1 Apr 2024 13:17:17 +0100 Subject: [PATCH 27/42] Fixes rubocop inconsistency --- spec/system/admin/products_v3/products_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index 218083c3ff..b06e73aa56 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -166,7 +166,7 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi it "displays an on hand count in a span for each product" do expect(page).to have_content "On demand" - expect(page).to_not have_content "20" # does not display the total stock + expect(page).not_to have_content "20" # does not display the total stock expect(page).to have_content "16" # displays the stock for variant_2 expect(page).to have_content "4" # displays the stock for variant_3 end From 5824516ce0fafdb002c0127420acb50dc8176eba Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 1 Apr 2024 13:45:04 +0100 Subject: [PATCH 28/42] Fixes case --- spec/system/admin/orders_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index ddfa068ea8..f51e0910f7 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -503,7 +503,7 @@ RSpec.describe ' expect(page).not_to have_content "Print Invoices" end end - + context "pagination" do before do login_as_admin From 9f98dc253d195811a15280e9b6c59864002401c9 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 1 Apr 2024 16:56:51 +0100 Subject: [PATCH 29/42] Adds assertions on table header --- spec/system/admin/products_v3/products_spec.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index b06e73aa56..eac1889407 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -132,6 +132,20 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi it "displays a list of products" do within ".products" do + # displays table header + expect(page).to have_selector "th", text: "Name" + expect(page).to have_selector "th", text: "SKU" + expect(page).to have_selector "th", text: "Unit scale" + expect(page).to have_selector "th", text: "Unit" + expect(page).to have_selector "th", text: "Price" + expect(page).to have_selector "th", text: "On Hand" + expect(page).to have_selector "th", text: "Producer" + expect(page).to have_selector "th", text: "Category" + expect(page).to have_selector "th", text: "Tax Category" + expect(page).to have_selector "th", text: "Inherits Properties?" + expect(page).to have_selector "th", text: "Actions" + + # displays product list expect(page).to have_field("_products_0_name", with: p1.name.to_s) expect(page).to have_field("_products_1_name", with: p2.name.to_s) end From 80e817725e1c18d746d51f5f3aa906d382896cf5 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 1 Apr 2024 18:19:34 +0100 Subject: [PATCH 30/42] Mouse hovering displays the text on the New variant button This test needs to be improved as, for Capybara, the text seems to be always visible, although it only does become visible by hovering. --- spec/system/admin/products_v3/products_spec.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index eac1889407..c134d506fb 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -1629,13 +1629,18 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi let!(:product) { create(:product, variant_unit: 'weight', variant_unit_scale: 1000) } before do - pending "Pending implementation, issue #11066" + # pending "Pending implementation, issue #11066" login_as_admin visit spree.admin_products_path # I should see an add variant button - page.find('a.view-variants').click + # page.find('a.view-variants').click + end + + it "hovering over the New variant button displays the text" do + find("button.secondary.condensed.naked.icon-plus").hover + expect(page).to have_content "New variant" end it "handle the default behaviour" do From c226b108273414e5302f82c5194896e4d445d0d1 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Tue, 16 Apr 2024 12:59:44 +0100 Subject: [PATCH 31/42] Updates case on orders_spec.rb --- spec/system/admin/orders_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index f51e0910f7..ddfa068ea8 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -503,7 +503,7 @@ RSpec.describe ' expect(page).not_to have_content "Print Invoices" end end - + context "pagination" do before do login_as_admin From ba355fdaab49f060af6ddf3d57e1f179c1c259e9 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Tue, 16 Apr 2024 13:09:04 +0100 Subject: [PATCH 32/42] Removes mouse clicks to display variants This feature does not exist in BUU Replaces previous add variant button click with correct version --- spec/system/admin/products_v3/products_spec.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index c134d506fb..a6efc18653 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -1692,12 +1692,11 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi product.variants << v2 visit spree.admin_products_path - page.find('a.view-variants').click end it "when variant unit value is: '120'" do within "tr#v_#{v2.id}" do - page.find(".add-variant").click + find("button.secondary.condensed.naked.icon-plus").click end within "tr#v_-1" do @@ -1711,7 +1710,7 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi it "creating a variant with unit value is: '120g' and 'on_hand' filled" do within "tr#v_#{v2.id}" do - page.find(".add-variant").click + find("button.secondary.condensed.naked.icon-plus").click end within "tr#v_-1" do @@ -1729,7 +1728,7 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi scroll_to(:bottom) within "tr#v_#{v2.id}" do - page.find(".add-variant").click + find("button.secondary.condensed.naked.icon-plus").click end within "tr#v_-1" do From 8028610fe6ca75bd35a4226a0babb99677dadb8e Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Wed, 17 Apr 2024 23:02:01 +0100 Subject: [PATCH 33/42] Updates spec to create a variant within BUU design --- .../system/admin/products_v3/products_spec.rb | 182 ++++++++++-------- 1 file changed, 99 insertions(+), 83 deletions(-) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index a6efc18653..ee46904872 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -1629,13 +1629,8 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi let!(:product) { create(:product, variant_unit: 'weight', variant_unit_scale: 1000) } before do - # pending "Pending implementation, issue #11066" - login_as_admin visit spree.admin_products_path - - # I should see an add variant button - # page.find('a.view-variants').click end it "hovering over the New variant button displays the text" do @@ -1644,103 +1639,124 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi end it "handle the default behaviour" do - # When I add three variants - page.find('a.add-variant').click - page.find('a.add-variant').click + # the product and the default variant is displayed + expect(page).to have_selector("input[aria-label=Name][value='#{product.name}']", + visible: true, count: 1) + expect(page).to have_selector("input[aria-label=Name][placeholder='#{product.name}']", + visible: false, count: 1) - # They should be added, and should not see edit buttons for new variants - expect(page).to have_selector "tr.variant", count: 3 - expect(page).to have_selector "a.edit-variant", count: 1 - - # When I remove two, they should be removed - accept_alert do - page.all('a.delete-variant').first.click - end - expect(page).to have_selector "tr.variant", count: 2 - page.all('a.delete-variant').first.click - expect(page).to have_selector "tr.variant", count: 1 + # when a second variant is added, the number of lines increases + expect { + find("button.secondary.condensed.naked.icon-plus").click + }.to change{ + page.all("input[aria-label=Name][placeholder='#{product.name}']", visible: false).count + }.from(1).to(2) # When I fill out variant details and hit update - fill_in "variant_display_name", with: "Case of 12 Bottles" - fill_in "variant_unit_value_with_description", with: "3 (12x250 mL bottles)" - fill_in "variant_display_as", with: "Case" - fill_in "variant_price", with: "4.0" - fill_in "variant_on_hand", with: "10" + within page.all("tr.condensed")[1] do # selects second variant row + find('input[id$="_sku"]').fill_in with: "345" + find('input[id$="_display_name"]').fill_in with: "Small bag" + find('button[id$="unit_to_display"]').click # opens the unit value pop out + find('input[id$="_unit_value_with_description"]').fill_in with: "0.002" + find('input[id$="_display_as"]').fill_in with: "2 grams" + find('button[aria-label="On Hand"]').click + find('input[id$="_on_hand"]').fill_in with: "66" + find('input[id$="_price"]').fill_in with: "11.1" + end - click_button 'Save Changes', match: :first - expect(page.find("#status-message")).to have_content "Changes saved." + expect(page).to have_content "1 product modified." - updated_variant = Spree::Variant.where(deleted_at: nil).last - expect(updated_variant.display_name).to eq "Case of 12 Bottles" - expect(updated_variant.unit_value).to eq 3000 - expect(updated_variant.unit_description).to eq "(12x250 mL bottles)" - expect(updated_variant.display_as).to eq "Case" - expect(updated_variant.price).to eq 4.0 - expect(updated_variant.on_hand).to eq 10 + expect { + click_on "Save changes" + }.to change { + Spree::Variant.count + }.from(1).to(2) - # Then I should see edit buttons for the new variant - expect(page).to have_selector "a.edit-variant" + new_variant = Spree::Variant.where(deleted_at: nil).last + expect(new_variant.sku).to eq "345" + expect(new_variant.display_name).to eq "Small bag" + expect(new_variant.unit_value).to eq 2.0 + expect(new_variant.display_as).to eq "2 grams" + expect(new_variant.unit_presentation).to eq "2 grams" + expect(new_variant.price).to eq 11.1 + expect(new_variant.on_hand).to eq 66 + + within ".flash-container" do + expect(page).to have_content "Changes saved" + click_on "Dismiss" + expect(page).not_to have_content "Changes saved" + end + + within page.all("tr.condensed")[1] do # selects second variant row + page.find('input[id$="_sku"]').fill_in with: "789" + end + + accept_confirm do + click_on "Discard changes" # does not save chages + end + expect(page).not_to have_content "Changes saved" end - context "handle the 'on_demand' variant case creation" do - let(:v1) { create(:variant, product:, on_hand: 4) } - let(:v2) { create(:variant, product:, on_demand: true) } - pending("Pending implementation, issue #11066") + it "handle the on demand behaviour" do + # the product and the default variant is displayed + expect(page).to have_selector("input[aria-label=Name][value='#{product.name}']", + visible: true, count: 1) + expect(page).to have_selector("input[aria-label=Name][placeholder='#{product.name}']", + visible: false, count: 1) - before do - product.variants << v1 - product.variants << v2 + # when a second variant is added, the number of lines increases + expect { + find("button.secondary.condensed.naked.icon-plus").click + }.to change{ + page.all("input[aria-label=Name][placeholder='#{product.name}']", visible: false).count + }.from(1).to(2) - visit spree.admin_products_path + # When I fill out variant details and hit update + within page.all("tr.condensed")[1] do # selects second variant row + find('input[id$="_sku"]').fill_in with: "345" + find('input[id$="_display_name"]').fill_in with: "Small bag" + find('button[id$="unit_to_display"]').click # opens the unit value pop out + find('input[id$="_unit_value_with_description"]').fill_in with: "0.002" + find('input[id$="_display_as"]').fill_in with: "2 grams" + find('button[aria-label="On Hand"]').click + find('input[id$="_on_demand"]').check + find('input[id$="_price"]').fill_in with: "11.1" end - it "when variant unit value is: '120'" do - within "tr#v_#{v2.id}" do - find("button.secondary.condensed.naked.icon-plus").click - end + expect(page).to have_content "1 product modified." - within "tr#v_-1" do - fill_in "variant_unit_value_with_description", with: "120" - fill_in "variant_price", with: "6.66" - end + expect { + click_on "Save changes" + }.to change { + Spree::Variant.count + }.from(1).to(2) - click_button 'Save Changes', match: :first - expect(page.find("#status-message")).to have_content "Changes saved." + new_variant = Spree::Variant.where(deleted_at: nil).last + expect(new_variant.sku).to eq "345" + expect(new_variant.display_name).to eq "Small bag" + expect(new_variant.unit_value).to eq 2.0 + expect(new_variant.display_as).to eq "2 grams" + expect(new_variant.unit_presentation).to eq "2 grams" + expect(new_variant.price).to eq 11.1 + expect(new_variant.on_demand).to eq true + + within ".flash-container" do + expect(page).to have_content "Changes saved" + click_on "Dismiss" + expect(page).not_to have_content "Changes saved" end - it "creating a variant with unit value is: '120g' and 'on_hand' filled" do - within "tr#v_#{v2.id}" do - find("button.secondary.condensed.naked.icon-plus").click - end - - within "tr#v_-1" do - fill_in "variant_unit_value_with_description", with: "120g" - fill_in "variant_price", with: "6.66" - fill_in "variant_on_hand", with: "222" - end - - click_button 'Save Changes', match: :first - expect(page.find("#status-message")) - .to have_content "Variant unit value can't be blank Variant unit value is not a number" + within page.all("tr.condensed")[1] do # selects second variant row + page.find('input[id$="_sku"]').fill_in with: "789" end - it "creating a variant with unit value is: '120g' and 'on_demand' checked" do - scroll_to(:bottom) - - within "tr#v_#{v2.id}" do - find("button.secondary.condensed.naked.icon-plus").click - end - - within "tr#v_-1" do - fill_in "variant_unit_value_with_description", with: "120g" - fill_in "variant_price", with: "6.66" - check "variant_on_demand" - end - - click_button 'Save Changes', match: :first - expect(page.find("#status-message")) - .to have_content "Variant unit value can't be blank Variant unit value is not a number" + accept_confirm do + click_on "Discard changes" # does not save chages end + expect(page).not_to have_content "Changes saved" + end + + context "handle error messages" do end end From 9e2589340163b7ae0f3afade536dd9ab37a77b2a Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Thu, 18 Apr 2024 19:00:57 +0100 Subject: [PATCH 34/42] Sets variant creation scenarios on_hand/on_demand as shared examples --- .../system/admin/products_v3/products_spec.rb | 173 +++++++----------- 1 file changed, 63 insertions(+), 110 deletions(-) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index ee46904872..dfca1a90f2 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -1634,130 +1634,83 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi end it "hovering over the New variant button displays the text" do + page.find('button[aria-label="New variant"]', text: "New variant", visible: false) find("button.secondary.condensed.naked.icon-plus").hover + page.find('button[aria-label="New variant"]', text: "New variant", visible: true) expect(page).to have_content "New variant" end - it "handle the default behaviour" do - # the product and the default variant is displayed - expect(page).to have_selector("input[aria-label=Name][value='#{product.name}']", - visible: true, count: 1) - expect(page).to have_selector("input[aria-label=Name][placeholder='#{product.name}']", - visible: false, count: 1) + shared_examples "creating a new variant (bulk)" do |stock| + it "handles the #{stock} behaviour" do + # the product and the default variant is displayed + expect(page).to have_selector("input[aria-label=Name][value='#{product.name}']", + visible: true, count: 1) + expect(page).to have_selector("input[aria-label=Name][placeholder='#{product.name}']", + visible: false, count: 1) - # when a second variant is added, the number of lines increases - expect { - find("button.secondary.condensed.naked.icon-plus").click - }.to change{ - page.all("input[aria-label=Name][placeholder='#{product.name}']", visible: false).count - }.from(1).to(2) + # when a second variant is added, the number of lines increases + expect { + find("button.secondary.condensed.naked.icon-plus").click + }.to change{ + page.all("input[aria-label=Name][placeholder='#{product.name}']", visible: false).count + }.from(1).to(2) - # When I fill out variant details and hit update - within page.all("tr.condensed")[1] do # selects second variant row - find('input[id$="_sku"]').fill_in with: "345" - find('input[id$="_display_name"]').fill_in with: "Small bag" - find('button[id$="unit_to_display"]').click # opens the unit value pop out - find('input[id$="_unit_value_with_description"]').fill_in with: "0.002" - find('input[id$="_display_as"]').fill_in with: "2 grams" - find('button[aria-label="On Hand"]').click - find('input[id$="_on_hand"]').fill_in with: "66" - find('input[id$="_price"]').fill_in with: "11.1" - end + # When I fill out variant details and hit update + within page.all("tr.condensed")[1] do # selects second variant row + find('input[id$="_sku"]').fill_in with: "345" + find('input[id$="_display_name"]').fill_in with: "Small bag" + find('button[id$="unit_to_display"]').click # opens the unit value pop out + find('input[id$="_unit_value_with_description"]').fill_in with: "0.002" + find('input[id$="_display_as"]').fill_in with: "2 grams" + find('button[aria-label="On Hand"]').click + find('input[id$="_price"]').fill_in with: "11.1" + if stock == "on_hand" + find('input[id$="_on_hand"]').fill_in with: "66" + elsif stock == "on_demand" + find('input[id$="_on_demand"]').check + end + end - expect(page).to have_content "1 product modified." + expect(page).to have_content "1 product modified." - expect { - click_on "Save changes" - }.to change { - Spree::Variant.count - }.from(1).to(2) + expect { + click_on "Save changes" + }.to change { + Spree::Variant.count + }.from(1).to(2) - new_variant = Spree::Variant.where(deleted_at: nil).last - expect(new_variant.sku).to eq "345" - expect(new_variant.display_name).to eq "Small bag" - expect(new_variant.unit_value).to eq 2.0 - expect(new_variant.display_as).to eq "2 grams" - expect(new_variant.unit_presentation).to eq "2 grams" - expect(new_variant.price).to eq 11.1 - expect(new_variant.on_hand).to eq 66 + new_variant = Spree::Variant.where(deleted_at: nil).last + expect(new_variant.sku).to eq "345" + expect(new_variant.display_name).to eq "Small bag" + expect(new_variant.unit_value).to eq 2.0 + expect(new_variant.display_as).to eq "2 grams" + expect(new_variant.unit_presentation).to eq "2 grams" + expect(new_variant.price).to eq 11.1 + if stock == "on_hand" + expect(new_variant.on_hand).to eq 66 + elsif stock == "on_demand" + expect(new_variant.on_demand).to eq true + end - within ".flash-container" do - expect(page).to have_content "Changes saved" - click_on "Dismiss" + within ".flash-container" do + expect(page).to have_content "Changes saved" + click_on "Dismiss" + expect(page).not_to have_content "Changes saved" + end + + within page.all("tr.condensed")[1] do # selects second variant row + page.find('input[id$="_sku"]').fill_in with: "789" + end + + accept_confirm do + click_on "Discard changes" # does not save chages + end expect(page).not_to have_content "Changes saved" end - - within page.all("tr.condensed")[1] do # selects second variant row - page.find('input[id$="_sku"]').fill_in with: "789" - end - - accept_confirm do - click_on "Discard changes" # does not save chages - end - expect(page).not_to have_content "Changes saved" end - it "handle the on demand behaviour" do - # the product and the default variant is displayed - expect(page).to have_selector("input[aria-label=Name][value='#{product.name}']", - visible: true, count: 1) - expect(page).to have_selector("input[aria-label=Name][placeholder='#{product.name}']", - visible: false, count: 1) - - # when a second variant is added, the number of lines increases - expect { - find("button.secondary.condensed.naked.icon-plus").click - }.to change{ - page.all("input[aria-label=Name][placeholder='#{product.name}']", visible: false).count - }.from(1).to(2) - - # When I fill out variant details and hit update - within page.all("tr.condensed")[1] do # selects second variant row - find('input[id$="_sku"]').fill_in with: "345" - find('input[id$="_display_name"]').fill_in with: "Small bag" - find('button[id$="unit_to_display"]').click # opens the unit value pop out - find('input[id$="_unit_value_with_description"]').fill_in with: "0.002" - find('input[id$="_display_as"]').fill_in with: "2 grams" - find('button[aria-label="On Hand"]').click - find('input[id$="_on_demand"]').check - find('input[id$="_price"]').fill_in with: "11.1" - end - - expect(page).to have_content "1 product modified." - - expect { - click_on "Save changes" - }.to change { - Spree::Variant.count - }.from(1).to(2) - - new_variant = Spree::Variant.where(deleted_at: nil).last - expect(new_variant.sku).to eq "345" - expect(new_variant.display_name).to eq "Small bag" - expect(new_variant.unit_value).to eq 2.0 - expect(new_variant.display_as).to eq "2 grams" - expect(new_variant.unit_presentation).to eq "2 grams" - expect(new_variant.price).to eq 11.1 - expect(new_variant.on_demand).to eq true - - within ".flash-container" do - expect(page).to have_content "Changes saved" - click_on "Dismiss" - expect(page).not_to have_content "Changes saved" - end - - within page.all("tr.condensed")[1] do # selects second variant row - page.find('input[id$="_sku"]').fill_in with: "789" - end - - accept_confirm do - click_on "Discard changes" # does not save chages - end - expect(page).not_to have_content "Changes saved" - end - - context "handle error messages" do - end + it_behaves_like "creating a new variant (bulk)", "on_hand" + it_behaves_like "creating a new variant (bulk)", "on_demand" end def create_products(amount) From 6dfef8104d9f2ddf5c4b4dcaaaaf4ce01c974c12 Mon Sep 17 00:00:00 2001 From: filipefurtad0 Date: Mon, 20 May 2024 19:40:09 +0100 Subject: [PATCH 35/42] Fixes rebase --- spec/system/admin/order_cycles/simple_spec.rb | 11 ----------- spec/system/admin/products_v3/products_spec.rb | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/spec/system/admin/order_cycles/simple_spec.rb b/spec/system/admin/order_cycles/simple_spec.rb index 181600c450..d935baefe5 100644 --- a/spec/system/admin/order_cycles/simple_spec.rb +++ b/spec/system/admin/order_cycles/simple_spec.rb @@ -414,17 +414,6 @@ RSpec.describe ' # 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.upcase - - # 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 dfca1a90f2..53febf5bcd 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -1652,7 +1652,7 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi expect { find("button.secondary.condensed.naked.icon-plus").click }.to change{ - page.all("input[aria-label=Name][placeholder='#{product.name}']", visible: false).count + page.all("input[aria-label=Name][placeholder='#{product.name}']", visible: false).count }.from(1).to(2) # When I fill out variant details and hit update From 3a8c44d0c6bd2197c575fa6f3583e167425abbf8 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 1 Jul 2024 12:38:10 +1000 Subject: [PATCH 36/42] fixup: Updates spec to create a variant within BUU design --- spec/system/admin/products_v3/products_spec.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index 53febf5bcd..af6a87a074 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -1675,10 +1675,14 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi expect { click_on "Save changes" + expect(page).to have_content "Changes saved" }.to change { Spree::Variant.count }.from(1).to(2) + click_on "Dismiss" + expect(page).not_to have_content "Changes saved" + new_variant = Spree::Variant.where(deleted_at: nil).last expect(new_variant.sku).to eq "345" expect(new_variant.display_name).to eq "Small bag" @@ -1692,12 +1696,6 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi expect(new_variant.on_demand).to eq true end - within ".flash-container" do - expect(page).to have_content "Changes saved" - click_on "Dismiss" - expect(page).not_to have_content "Changes saved" - end - within page.all("tr.condensed")[1] do # selects second variant row page.find('input[id$="_sku"]').fill_in with: "789" end From 39cae4468acf0611b3a444ab8fca48d87ad6238c Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 1 Jul 2024 12:56:09 +1000 Subject: [PATCH 37/42] Fix more uppercase tests after rebase These seem to have been changed since the previous rebase. --- .../admin/bulk_order_cancellation_spec.rb | 4 +-- spec/system/admin/order_cycles/simple_spec.rb | 4 +-- spec/system/admin/order_spec.rb | 4 +-- spec/system/admin/orders/bulk_actions_spec.rb | 28 +++++++++---------- spec/system/admin/orders/invoices_spec.rb | 8 +++--- spec/system/admin/orders_spec.rb | 4 +-- spec/system/admin/reports_spec.rb | 2 +- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/spec/system/admin/bulk_order_cancellation_spec.rb b/spec/system/admin/bulk_order_cancellation_spec.rb index bb2084976f..c94f0e9b13 100644 --- a/spec/system/admin/bulk_order_cancellation_spec.rb +++ b/spec/system/admin/bulk_order_cancellation_spec.rb @@ -30,7 +30,7 @@ RSpec.describe ' expect(page).to have_selector('span', text: 'COMPLETE', count: 2) page.find('#selectAll').trigger('click') - page.find("span.icon-reorder", text: "ACTIONS").click + page.find("span.icon-reorder", text: "Actions").click within ".ofn-drop-down .menu" do expect(page).to have_selector("span", text: "Cancel Orders") page.find("span", text: "Cancel Orders").click @@ -43,7 +43,7 @@ RSpec.describe ' .and change { o2.reload.state }.from('complete').to('canceled') end - # Verify that the orders have a STATE of CANCELLED + # Verify that the orders have a STATE of Cancelled expect(page).to have_selector('span.canceled', text: 'CANCELLED', count: 2) end end diff --git a/spec/system/admin/order_cycles/simple_spec.rb b/spec/system/admin/order_cycles/simple_spec.rb index d935baefe5..dd10959dd0 100644 --- a/spec/system/admin/order_cycles/simple_spec.rb +++ b/spec/system/admin/order_cycles/simple_spec.rb @@ -413,7 +413,7 @@ RSpec.describe ' # 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.upcase + expect(page).to have_content product.name end it "doesn't show a warning when going to 'outgoing products' tab" do @@ -432,7 +432,7 @@ RSpec.describe ' # 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.upcase + expect(page).to have_content product.name expect(page).not_to have_content "No variant available for this product" end diff --git a/spec/system/admin/order_spec.rb b/spec/system/admin/order_spec.rb index 04776c1aaf..bf77b56de6 100644 --- a/spec/system/admin/order_spec.rb +++ b/spec/system/admin/order_spec.rb @@ -744,7 +744,7 @@ RSpec.describe ' it "should not display links but a js alert" do visit spree.edit_admin_order_path(order) - find("summary", text: "ACTIONS").click + find("summary", text: "Actions").click expect(page).to have_link "Send Invoice", href: "#" expect(page).to have_link "Print Invoice", href: "#" @@ -754,7 +754,7 @@ RSpec.describe ' expect(message) .to eq "#{distributor1.name} must have a valid ABN before invoices can be used." - find("summary", text: "ACTIONS").click + find("summary", text: "Actions").click message = accept_prompt do click_link "Send Invoice" end diff --git a/spec/system/admin/orders/bulk_actions_spec.rb b/spec/system/admin/orders/bulk_actions_spec.rb index 4393a06c09..ad6b98adf9 100644 --- a/spec/system/admin/orders/bulk_actions_spec.rb +++ b/spec/system/admin/orders/bulk_actions_spec.rb @@ -114,7 +114,7 @@ RSpec.describe ' page.find("input[name='bulk_ids[]'][value='#{order5.id}']").click end - page.find("span.icon-reorder", text: "ACTIONS").click + page.find("span.icon-reorder", text: "Actions").click within ".ofn-drop-down .menu" do page.find("span", text: "Send Invoices").click @@ -205,7 +205,7 @@ RSpec.describe ' page.find(order4_selector).click page.find(order5_selector).click - page.find("span.icon-reorder", text: "ACTIONS").click + page.find("span.icon-reorder", text: "Actions").click within ".ofn-drop-down .menu" do expect { page.find("span", text: "Print Invoices").click # Prints invoices in bulk @@ -223,7 +223,7 @@ RSpec.describe ' expect(page).to have_content "Bulk Invoice created" within ".modal-content" do - expect(page).to have_link(class: "button", text: "VIEW FILE", href: /invoices/) + expect(page).to have_link(class: "button", text: "View File", href: /invoices/) invoice_content = extract_pdf_content @@ -243,7 +243,7 @@ RSpec.describe ' page.find(order4_selector).click page.find(order5_selector).click - page.find("span.icon-reorder", text: "ACTIONS").click + page.find("span.icon-reorder", text: "Actions").click within ".ofn-drop-down .menu" do expect { page.find("span", text: "Print Invoices").click # Prints invoices in bulk @@ -259,7 +259,7 @@ RSpec.describe ' expect(page).to have_content "Bulk Invoice created" within ".modal-content" do - expect(page).to have_link(class: "button", text: "VIEW FILE", + expect(page).to have_link(class: "button", text: "View File", href: /invoices/) invoice_content = extract_pdf_content @@ -305,7 +305,7 @@ RSpec.describe ' order4.name.gsub(/.* /, ""), order5.name.gsub(/.* /, "")].sort } it "orders by customer name ascending" do - page.find('a', text: "NAME").click # orders alphabetically (asc) + page.find('a', text: "Name").click # orders alphabetically (asc) sleep(0.5) # waits for column sorting page.find("#selectAll").click @@ -325,9 +325,9 @@ RSpec.describe ' order4.name.gsub(/.* /, ""), order5.name.gsub(/.* /, "")].sort.reverse } it "order by customer name descending" do - page.find('a', text: "NAME").click # orders alphabetically (asc) + page.find('a', text: "Name").click # orders alphabetically (asc) sleep(0.5) # waits for column sorting - page.find('a', text: "NAME").click # orders alphabetically (desc) + page.find('a', text: "Name").click # orders alphabetically (desc) sleep(0.5) # waits for column sorting page.find("#selectAll").click @@ -377,7 +377,7 @@ RSpec.describe ' page.find(order4_selector).click page.find(order5_selector).click - page.find("span.icon-reorder", text: "ACTIONS").click + page.find("span.icon-reorder", text: "Actions").click within ".ofn-drop-down .menu" do expect { page.find("span", text: "Print Invoices").click # Prints invoices in bulk @@ -430,7 +430,7 @@ RSpec.describe ' page.find("#listing_orders tbody tr:nth-child(1) input[name='bulk_ids[]']").click page.find("#listing_orders tbody tr:nth-child(2) input[name='bulk_ids[]']").click - page.find("span.icon-reorder", text: "ACTIONS").click + page.find("span.icon-reorder", text: "Actions").click within ".ofn-drop-down .menu" do page.find("span", text: "Cancel Orders").click end @@ -445,7 +445,7 @@ RSpec.describe ' }.not_to enqueue_job(ActionMailer::MailDeliveryJob).exactly(:twice) end - page.find("span.icon-reorder", text: "ACTIONS").click + page.find("span.icon-reorder", text: "Actions").click within ".ofn-drop-down .menu" do page.find("span", text: "Cancel Orders").click end @@ -484,7 +484,7 @@ RSpec.describe ' order.update_attribute(:distributor, distributor) order.update_attribute(:order_cycle, order_cycle) - page.find("span.icon-reorder", text: "ACTIONS").click + page.find("span.icon-reorder", text: "Actions").click within ".ofn-drop-down .menu" do page.find("span", text: "Resend Confirmation").click end @@ -502,7 +502,7 @@ RSpec.describe ' def extract_pdf_content # Extract last part of invoice URL - link = page.find(class: "button", text: "VIEW FILE") + link = page.find(class: "button", text: "View File") filename = link[:href].match %r{/invoices/.*} # Load invoice temp file directly instead of downloading @@ -511,7 +511,7 @@ RSpec.describe ' end def print_all_invoices - page.find("span.icon-reorder", text: "ACTIONS").click + page.find("span.icon-reorder", text: "Actions").click within ".ofn-drop-down .menu" do expect { page.find("span", text: "Print Invoices").click # Prints invoices in bulk diff --git a/spec/system/admin/orders/invoices_spec.rb b/spec/system/admin/orders/invoices_spec.rb index b101a28a7a..595974d69a 100644 --- a/spec/system/admin/orders/invoices_spec.rb +++ b/spec/system/admin/orders/invoices_spec.rb @@ -109,7 +109,7 @@ RSpec.describe ' context 'when the order has no invoices' do it 'creates an invoice for the order' do expect(order.invoices.count).to eq 0 - page.find("#links-dropdown", text: "ACTIONS").click + page.find("#links-dropdown", text: "Actions").click click_link "Print Invoice" # wait for PDF to open in new window new_window = windows.last @@ -132,7 +132,7 @@ RSpec.describe ' it 'updates the lastest invoice for the order' do expect(order.invoices.count).to eq 1 - page.find("#links-dropdown", text: "ACTIONS").click + page.find("#links-dropdown", text: "Actions").click click_link "Print Invoice" new_window = windows.last page.within_window new_window do @@ -149,7 +149,7 @@ RSpec.describe ' it 'creates a new invoice for the order' do expect(order.invoices.count).to eq 1 - page.find("#links-dropdown", text: "ACTIONS").click + page.find("#links-dropdown", text: "Actions").click click_link "Print Invoice" new_window = windows.last page.within_window new_window do @@ -260,7 +260,7 @@ RSpec.describe "Invoice order states", feature: :invoices do "Amount", "Status", "File", - ].join(" ").upcase + ].join(" ") } let(:invoice_number){ "#{order.distributor_id}-1" } diff --git a/spec/system/admin/orders_spec.rb b/spec/system/admin/orders_spec.rb index ddfa068ea8..fd306cebbc 100644 --- a/spec/system/admin/orders_spec.rb +++ b/spec/system/admin/orders_spec.rb @@ -490,7 +490,7 @@ RSpec.describe ' "#listing_orders tbody tr td:first-child input[type=checkbox]" )).to be_checked # enables print invoices button - page.find("span.icon-reorder", text: "ACTIONS").click + page.find("span.icon-reorder", text: "Actions").click expect(page).to have_content "Print Invoices" # unselect all orders page.find("#listing_orders thead th:first-child input[type=checkbox]").trigger("click") @@ -498,7 +498,7 @@ RSpec.describe ' "#listing_orders tbody tr td:first-child input[type=checkbox]" )).not_to be_checked # disables print invoices button not clickable - expect { find("span.icon-reorder", text: "ACTIONS").click } + expect { find("span.icon-reorder", text: "Actions").click } .to raise_error(Capybara::Cuprite::MouseEventFailed) expect(page).not_to have_content "Print Invoices" end diff --git a/spec/system/admin/reports_spec.rb b/spec/system/admin/reports_spec.rb index d2a634768c..80839873d2 100644 --- a/spec/system/admin/reports_spec.rb +++ b/spec/system/admin/reports_spec.rb @@ -75,7 +75,7 @@ RSpec.describe ' expect(page).not_to have_content "Little Bobby Tables" click_on "Display anyway" - expect(page).to have_content "FIRST NAME" + expect(page).to have_content "First Name" expect(page).to have_content "Little Bobby Tables" end From 5f01bb40d2b44995ab161cc97e840ad998544110 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 1 Jul 2024 12:41:47 +1000 Subject: [PATCH 38/42] Remove unecessary message I'm not sure why it's not appearing on my computer, but it was an unnecessary duplicate message, so I'm happy to remove it. --- spec/system/admin/products_v3/products_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/system/admin/products_v3/products_spec.rb b/spec/system/admin/products_v3/products_spec.rb index af6a87a074..3398c66d68 100644 --- a/spec/system/admin/products_v3/products_spec.rb +++ b/spec/system/admin/products_v3/products_spec.rb @@ -1186,7 +1186,6 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi attach_file 'image[attachment]', Rails.public_path.join('Terms-of-service.pdf'), visible: false - expect(page).to have_content /Attachment is not a valid image/ expect(page).to have_content /Attachment has an invalid content type/ end end From 109432d282921429a965e4c55b1599d7a1ccbf66 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 1 Jul 2024 13:56:23 +1000 Subject: [PATCH 39/42] fixup: feature toggle old screen --- spec/system/admin/bulk_product_update_spec.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/spec/system/admin/bulk_product_update_spec.rb b/spec/system/admin/bulk_product_update_spec.rb index 527512c648..b53ff6d819 100644 --- a/spec/system/admin/bulk_product_update_spec.rb +++ b/spec/system/admin/bulk_product_update_spec.rb @@ -4,16 +4,13 @@ require 'system_helper' RSpec.describe ' As an Administrator - I want to be able to manage products in bulk + I want to be able to manage products in bulk (with the old Products screen) ' do include AdminHelper include AuthenticationHelper include WebHelper - around do |example| - Flipper.disable(:admin_style_v3) - example.run - end + before { Flipper.disable(:admin_style_v3) } describe "listing products" do before do From b1721d69a27a5d2d67b7ee8bd4cba5ec905bb32b Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 1 Jul 2024 13:57:38 +1000 Subject: [PATCH 40/42] todo: make specs work with admin_style_v3 --- spec/system/admin/product_import_spec.rb | 19 +++++++++++-------- spec/system/admin/products_spec.rb | 7 ++----- .../admin/subscriptions/smoke_tests_spec.rb | 1 + 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/spec/system/admin/product_import_spec.rb b/spec/system/admin/product_import_spec.rb index 71458716d4..f7f37d87c3 100644 --- a/spec/system/admin/product_import_spec.rb +++ b/spec/system/admin/product_import_spec.rb @@ -8,11 +8,6 @@ RSpec.describe "Product Import" do include AuthenticationHelper include WebHelper - around do |example| - Flipper.disable(:admin_style_v3) - example.run - end - let!(:admin) { create(:admin_user) } let!(:user) { create(:user) } let!(:user2) { create(:user) } @@ -101,6 +96,8 @@ RSpec.describe "Product Import" do wait_until { page.find("a.button.view").present? } + puts "TODO: migrate to v3" + Flipper.disable(:admin_style_v3) # disabling BUU for legacy products page click_link 'Go To Products Page' expect(page).to have_content 'Bulk Edit Products' @@ -213,6 +210,8 @@ RSpec.describe "Product Import" do potatoes = Spree::Product.find_by(name: 'Potatoes') expect(potatoes.variants.first.import_date).to be_within(1.minute).of Time.zone.now + puts "TODO: migrate to v3" + Flipper.disable(:admin_style_v3) # disabling BUU for legacy products page click_link 'Go To Products Page' wait_until { page.find("#p_#{carrots.id}").present? } @@ -677,6 +676,8 @@ RSpec.describe "Product Import" do expect(page).to have_selector '.created-count', text: '2' expect(page).not_to have_selector '.updated-count' + puts "TODO: migrate to v3" + Flipper.disable(:admin_style_v3) # disabling BUU for legacy products page visit spree.admin_products_path within "#p_#{Spree::Product.find_by(name: 'Carrots').id}" do @@ -713,9 +714,11 @@ RSpec.describe "Product Import" do expect(page).to have_selector '.created-count', text: '1' expect(page).not_to have_selector '.updated-count' - expect(page).to have_content "Go To Products Page".upcase - expect(page).to have_content "Upload Another File".upcase + expect(page).to have_content "Go To Products Page" + expect(page).to have_content "Upload Another File" + puts "TODO: migrate to v3" + Flipper.disable(:admin_style_v3) # disabling BUU for legacy products page visit spree.admin_products_path within "#p_#{Spree::Product.find_by(name: 'Cupcake').id}" do @@ -787,7 +790,7 @@ RSpec.describe "Product Import" do product_headings.each do |heading| expect(page).to have_content( - I18n.t("admin.product_import.product_headings.#{heading}").upcase + I18n.t("admin.product_import.product_headings.#{heading}") ) end end diff --git a/spec/system/admin/products_spec.rb b/spec/system/admin/products_spec.rb index 5238c9a720..753dd4e4ba 100644 --- a/spec/system/admin/products_spec.rb +++ b/spec/system/admin/products_spec.rb @@ -280,11 +280,8 @@ RSpec.describe ' end end - describe "legacy products page" do - around do |example| - Flipper.disable(:admin_style_v3) - example.run - end + describe "legacy products page (TODO: migrate/combine specs with v3 specs)" do + before { Flipper.disable(:admin_style_v3) } describe "deleting" do let!(:product1) { create(:simple_product, name: 'a product to keep', supplier: @supplier) } diff --git a/spec/system/admin/subscriptions/smoke_tests_spec.rb b/spec/system/admin/subscriptions/smoke_tests_spec.rb index bf04215457..bd49f05c3a 100644 --- a/spec/system/admin/subscriptions/smoke_tests_spec.rb +++ b/spec/system/admin/subscriptions/smoke_tests_spec.rb @@ -237,6 +237,7 @@ RSpec.describe 'Subscriptions' do expect(page).to have_selector "#subscription-line-items .item", count: 4 # Delete an existing product + puts "TODO: migrate to v3" # but first we need to make the actions menu more accessible. Flipper.disable(:admin_style_v3) # disabling BUU for legacy products page login_as_admin visit spree.admin_products_path From c80199e8b14f3315f42aeea3a4e72f7e5b921df9 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 1 Jul 2024 14:34:25 +1000 Subject: [PATCH 41/42] Use normal capitalisation for translation --- config/locales/en.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index fa66c9577b..fafdc31f2b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -3863,7 +3863,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using logout: "Logout" date_range: "Date Range" - status: "status" + status: "Status" new: "New" start: "Start" end: "End" From b1aafbf843638b37bcdf3b27dcae8c99acde6062 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 1 Jul 2024 14:41:36 +1000 Subject: [PATCH 42/42] Remove old migration spec It breaks due to a change of the spec environment. There's no point fixing it, it's no longer required. --- ...ivate_admin_style_v3_for_new_users_spec.rb | 30 ------------------- 1 file changed, 30 deletions(-) delete mode 100644 spec/migrations/20240625024328_activate_admin_style_v3_for_new_users_spec.rb diff --git a/spec/migrations/20240625024328_activate_admin_style_v3_for_new_users_spec.rb b/spec/migrations/20240625024328_activate_admin_style_v3_for_new_users_spec.rb deleted file mode 100644 index 31bf5d29ab..0000000000 --- a/spec/migrations/20240625024328_activate_admin_style_v3_for_new_users_spec.rb +++ /dev/null @@ -1,30 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -require_relative '../../db/migrate/20240625024328_activate_admin_style_v3_for_new_users' - -RSpec.describe ActivateAdminStyleV3ForNewUsers do - it "activates new product screen for new users" do - Timecop.freeze Time.zone.parse("2024-07-03") do - user_new = create(:user) - - expect { - subject.up - }.to change { - OpenFoodNetwork::FeatureToggle.enabled?(:admin_style_v3, user_new) - }.to(true) - end - end - - it "doesn't activate new product screen for old users" do - Timecop.freeze Time.zone.parse("2024-07-02") do - user_old = create(:user) - - expect { - subject.up - }.not_to change { - OpenFoodNetwork::FeatureToggle.enabled?(:admin_style_v3, user_old) - } - end - end -end