From e7317ae8a75858c99e1daa0d7c3c55f8f471efb6 Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Tue, 1 Aug 2023 11:07:41 +0000 Subject: [PATCH] [IMP] website(*)_sale(_*): tours harmonization * Impose the use of the dedicated tour utils to factorize and harmonize the way tours behave on the ecommerce. * Introduce new utils when it seems adequate and useful. This will reduce incoherences and non determinism in e-commerce tours, and ease future tasks refactoring the e-commerce design and process (since we'll be able to restrict most changes to the utils instead of adapting all the tours one by one). closes odoo/odoo#130378 Related: odoo/enterprise#44938 Signed-off-by: Victor Feyens (vfe) --- .../src/js/tours/wevent_performance_tour.js | 43 ++---- .../tours/slides_certification_member.js | 19 +-- .../static/tests/tours/website_event_booth.js | 32 ++-- .../website_event_booth_sale_pricelists.js | 5 +- .../website_event_booth_sale_exhibitor.js | 32 ++-- .../helpers/WebsiteEventSaleTourMethods.js | 138 +++++++++--------- .../static/tests/tours/website_event_sale.js | 41 +----- .../tours/website_event_sale_last_ticket.js | 31 +--- .../static/src/js/tours/tour_utils.js | 106 ++++++++++++++ .../tests/tours/website_free_delivery.js | 31 ++-- .../static/tests/tours/website_sale_buy.js | 26 +--- .../tests/tours/website_sale_cart_popover.js | 17 +-- .../tests/tours/website_sale_complete_flow.js | 40 ++--- .../tours/website_sale_shop_cart_recovery.js | 11 +- .../static/tests/autocomplete_tour.js | 19 +-- .../static/tests/tours/test_gift_card_tour.js | 37 +---- .../tests/tours/test_promo_main_tour.js | 27 +--- .../tours/website_sale_delivery_gift_card.js | 34 +---- .../static/tests/tours/onsite_payment_tour.js | 6 +- 19 files changed, 271 insertions(+), 424 deletions(-) diff --git a/addons/test_event_full/static/src/js/tours/wevent_performance_tour.js b/addons/test_event_full/static/src/js/tours/wevent_performance_tour.js index c6d9ec92958..3b29bdc3820 100644 --- a/addons/test_event_full/static/src/js/tours/wevent_performance_tour.js +++ b/addons/test_event_full/static/src/js/tours/wevent_performance_tour.js @@ -1,6 +1,7 @@ /** @odoo-module **/ import { registry } from "@web/core/registry"; +import wsTourUtils from '@website_sale/js/tours/tour_utils'; var registerSteps = [{ content: "Select 2 units of 'Ticket1' ticket type", @@ -40,38 +41,20 @@ var registerSteps = [{ extra_trigger: "input[name*='1-name'], input[name*='2-name'], input[name*='3-name']", trigger: 'button[type=submit]', run: 'click', -}, { - content: "Address filling", - trigger: 'select[name="country_id"]', - run: function () { - $('input[name="name"]').val('Raoulette Poiluchette'); - $('input[name="phone"]').val('0456112233'); - $('input[name="email"]').val('raoulette@example.com'); - $('input[name="street"]').val('Cheesy Crust Street, 42'); - $('input[name="city"]').val('CheeseCity'); - $('input[name="zip"]').val('8888'); - $('#country_id option:eq(1)').attr('selected', true); - }, -}, { +}, +wsTourUtils.fillAdressForm({ + name: "Raoulette Poiluchette", + phone: "0456112233", + email: "raoulette@example.com", + street: "Cheesy Crust Street, 42", + city: "CheeseCity", + zip: "8888", +}), { content: "Next", trigger: '.oe_cart .btn:contains("Next")', -}, { - content: 'Select Test payment provider', - trigger: '.o_payment_option_card:contains("Demo")' -}, { - content: 'Add card number', - trigger: 'input[name="customer_input"]', - run: 'text 4242424242424242' -}, { - content: "Pay now", - extra_trigger: "#cart_products:contains(Ticket1):contains(Ticket2)", - trigger: 'button:contains(Pay Now)', - run: 'click', -}, { - content: 'Payment is successful', - trigger: '.oe_website_sale_tx_status:contains("Your payment has been successfully processed.")', - run: function () {} -}]; +}, +...wsTourUtils.payWithDemo(), +]; registry.category("web_tour.tours").add('wevent_performance_register', { diff --git a/addons/test_website_slides_full/static/tests/tours/slides_certification_member.js b/addons/test_website_slides_full/static/tests/tours/slides_certification_member.js index e6f83a2cf24..45f4682f3c8 100644 --- a/addons/test_website_slides_full/static/tests/tours/slides_certification_member.js +++ b/addons/test_website_slides_full/static/tests/tours/slides_certification_member.js @@ -42,24 +42,9 @@ var buyCertificationSteps = [{ trigger: 'a:contains("Add to Cart")' }, tourUtils.goToCart(), + tourUtils.goToCheckout(), + ...tourUtils.payWithDemo(), { - content: 'eCommerce: Process Checkout', - trigger: 'a:contains("Process Checkout")' -}, { - content: 'eCommerce: select Test payment provider', - trigger: '.o_payment_option_card:contains("Demo")' -}, { - content: 'eCommerce: add card number', - trigger: 'input[name="customer_input"]', - run: 'text 4242424242424242' -}, { - content: 'eCommerce: pay', - trigger: 'button[name="o_payment_submit_button"]' -}, { - content: 'eCommerce: check that the payment is successful', - trigger: '.oe_website_sale_tx_status:contains("Your payment has been successfully processed.")', - run: function () {} -}, { content: 'eCommerce: go back to e-learning home page', trigger: '.nav-link:contains("Courses")' }, { diff --git a/addons/website_event_booth_sale/static/tests/tours/website_event_booth.js b/addons/website_event_booth_sale/static/tests/tours/website_event_booth.js index 640aa5739d9..c74a97cc3e0 100644 --- a/addons/website_event_booth_sale/static/tests/tours/website_event_booth.js +++ b/addons/website_event_booth_sale/static/tests/tours/website_event_booth.js @@ -1,6 +1,8 @@ /** @odoo-module **/ import { registry } from "@web/core/registry"; +import wsTourUtils from '@website_sale/js/tours/tour_utils'; + registry.category("web_tour.tours").add('website_event_booth_tour', { test: true, @@ -31,24 +33,16 @@ registry.category("web_tour.tours").add('website_event_booth_tour', { }, { content: 'Submit your informations', trigger: 'button[type="submit"]', -}, { - content: 'Check if the price is correct', - trigger: 'tr#order_total_untaxed .oe_currency_value:containsExact(200.00)', - run: function () {}, -}, { - content: 'Check if the tax is correct', - trigger: 'tr#order_total_taxes .oe_currency_value:containsExact(20.00)', - run: function () {}, -}, { - content: 'Click Process Checkout to continue', - trigger: 'a[role="button"] span:contains("Process Checkout")', -}, { - content: 'Check if the price is correct', - trigger: 'tr#order_total_untaxed .oe_currency_value:containsExact(200.00)', - run: function () {}, -}, { - content: 'Check if the total price is correct', - trigger: 'tr#order_total .oe_currency_value:containsExact(220.00)', - run: function () {}, }, +...wsTourUtils.assertCartAmounts({ + taxes: '20.00', + untaxed: '200.00', + total: '220.00', +}), +wsTourUtils.goToCheckout(), +...wsTourUtils.assertCartAmounts({ + taxes: '20.00', + untaxed: '200.00', + total: '220.00', +}), ]}); diff --git a/addons/website_event_booth_sale/static/tests/tours/website_event_booth_sale_pricelists.js b/addons/website_event_booth_sale/static/tests/tours/website_event_booth_sale_pricelists.js index 13f737d9add..efb8b3da62e 100644 --- a/addons/website_event_booth_sale/static/tests/tours/website_event_booth_sale_pricelists.js +++ b/addons/website_event_booth_sale/static/tests/tours/website_event_booth_sale_pricelists.js @@ -2,6 +2,7 @@ import { registry } from "@web/core/registry"; import { getPriceListChecksSteps } from '@website_event_booth_sale/../tests/tours/helpers/WebsiteEventBoothSaleTourMethods'; +import wsTourUtils from '@website_sale/js/tours/tour_utils'; registry.category("web_tour.tours").add('event_booth_sale_pricelists_different_currencies', { test: true, @@ -38,10 +39,8 @@ registry.category("web_tour.tours").add('event_booth_sale_pricelists_different_c { content: 'Submit your informations', trigger: 'button[type="submit"]', - }, { - content: 'Checkout your order', - trigger: 'a[role="button"] span:contains("Process Checkout")', }, + wsTourUtils.goToCheckout(), ...getPriceListChecksSteps({ pricelistName: "EUR With Discount Included", eventName: "Test Event Booths", diff --git a/addons/website_event_booth_sale_exhibitor/static/tests/tours/website_event_booth_sale_exhibitor.js b/addons/website_event_booth_sale_exhibitor/static/tests/tours/website_event_booth_sale_exhibitor.js index ccafa3baf1e..e7536dac7a1 100644 --- a/addons/website_event_booth_sale_exhibitor/static/tests/tours/website_event_booth_sale_exhibitor.js +++ b/addons/website_event_booth_sale_exhibitor/static/tests/tours/website_event_booth_sale_exhibitor.js @@ -1,27 +1,15 @@ /** @odoo-module **/ - import FinalSteps from "@website_event_booth_exhibitor/../tests/tours/website_event_booth_exhibitor_steps"; +import FinalSteps from "@website_event_booth_exhibitor/../tests/tours/website_event_booth_exhibitor_steps"; +import wsTourUtils from '@website_sale/js/tours/tour_utils'; - FinalSteps.include({ +FinalSteps.include({ - _getSteps: function () { - return [{ - content: 'Checkout your order', - trigger: 'a[role="button"] span:contains("Process Checkout")', - run: 'click', - }, { - content: "Select `Wire Transfer` payment method", - trigger: '#payment_method label:contains("Wire Transfer")', - }, { - content: "Pay", - //Either there are multiple payment methods, and one is checked, either there is only one, and therefore there are no radio inputs - // extra_trigger: '#payment_method input:checked,#payment_method:not(:has("input:radio:visible"))', - trigger: 'button[name="o_payment_submit_button"]:visible:not(:disabled)', - }, { - content: "Last step", - trigger: '.oe_website_sale_tx_status:contains("Please use the following transfer details")', - timeout: 30000, - }]; - } + _getSteps: function () { + return [ + wsTourUtils.goToCheckout(), + ...wsTourUtils.payWithTransfer(), + ]; + } - }); +}); diff --git a/addons/website_event_sale/static/tests/tours/helpers/WebsiteEventSaleTourMethods.js b/addons/website_event_sale/static/tests/tours/helpers/WebsiteEventSaleTourMethods.js index 9bee915d3c4..bf69adc95da 100644 --- a/addons/website_event_sale/static/tests/tours/helpers/WebsiteEventSaleTourMethods.js +++ b/addons/website_event_sale/static/tests/tours/helpers/WebsiteEventSaleTourMethods.js @@ -1,74 +1,68 @@ /** @odoo-module **/ +import wsTourUtils from '@website_sale/js/tours/tour_utils'; - export function changePricelist(pricelistName) { - return [ - { - content: "Go to page Shop", - trigger: '.nav-link:contains("Shop")', - }, - { - content: "Toggle Pricelist", - trigger: '.o_pricelist_dropdown > .dropdown-toggle', - run: 'click', - }, - { - content: `Activate Pricelist ${pricelistName}`, - trigger: `.dropdown-item:contains(${pricelistName})`, - run: 'click', - }, - { - content: 'Wait for pricelist to load', - trigger: `.dropdown-toggle:contains(${pricelistName})`, - run: function () {}, - }, - ]; - } - function checkPriceEvent(eventName, price) { - return [ - { - content: "Go to page Event", - trigger: '.nav-link:contains("Event")', - }, - { - content: "Open the Pycon event", - trigger: `.o_wevent_events_list a:contains(${eventName})`, - }, - { - content: "Verify Price", - trigger: `.oe_currency_value:contains(${price})`, - run: function () {}, // it's a check - }, - ] - } - function checkPriceDiscountEvent(eventName, price, discount) { - return [ - ...checkPriceEvent(eventName, price), - { - content: "Verify Price before discount", - trigger: `del:contains(${discount})`, - run: function () {}, // it's a check - }, - ] - } - export function checkPriceCart(price) { - return [ - { - content: "Go to page Cart", - trigger: '.fa-shopping-cart', - }, - { - content: "Verify Price", - trigger: `[id=order_total] .oe_currency_value:contains(${price})`, - run: function () {}, // it's a check - }, - ] - } - export const getPriceListChecksSteps = function ({pricelistName, eventName, price, priceBeforeDiscount=false}) { - const checkPriceSteps = priceBeforeDiscount ? checkPriceDiscountEvent(eventName, price, priceBeforeDiscount) : checkPriceEvent(eventName, price); - return [ - ...changePricelist(pricelistName), - ...checkPriceSteps, - ...checkPriceCart(price), - ] - } - export default { getPriceListChecksSteps, changePricelist, checkPriceCart } +export function changePricelist(pricelistName) { + return [ + { + content: "Go to page Shop", + trigger: '.nav-link:contains("Shop")', + }, + { + content: "Toggle Pricelist", + trigger: '.o_pricelist_dropdown > .dropdown-toggle', + run: 'click', + }, + { + content: `Activate Pricelist ${pricelistName}`, + trigger: `.dropdown-item:contains(${pricelistName})`, + run: 'click', + }, + { + content: 'Wait for pricelist to load', + trigger: `.dropdown-toggle:contains(${pricelistName})`, + run: function () {}, + }, + ]; +} +function checkPriceEvent(eventName, price) { + return [ + { + content: "Go to page Event", + trigger: '.nav-link:contains("Event")', + }, + { + content: "Open the Pycon event", + trigger: `.o_wevent_events_list a:contains(${eventName})`, + }, + { + content: "Verify Price", + trigger: `.oe_currency_value:contains(${price})`, + run: function () {}, // it's a check + }, + ] +} +function checkPriceDiscountEvent(eventName, price, discount) { + return [ + ...checkPriceEvent(eventName, price), + { + content: "Verify Price before discount", + trigger: `del:contains(${discount})`, + run: function () {}, // it's a check + }, + ] +} +export function checkPriceCart(price) { + return [ + wsTourUtils.goToCart(), + ...wsTourUtils.assertCartAmounts({total: price}), + ] +} +export const getPriceListChecksSteps = function ({pricelistName, eventName, price, priceBeforeDiscount=false}) { + const checkPriceSteps = priceBeforeDiscount ? checkPriceDiscountEvent(eventName, price, priceBeforeDiscount) : checkPriceEvent(eventName, price); + return [ + ...changePricelist(pricelistName), + ...checkPriceSteps, + ...checkPriceCart(price), + ] +} +export default { getPriceListChecksSteps, changePricelist, checkPriceCart } diff --git a/addons/website_event_sale/static/tests/tours/website_event_sale.js b/addons/website_event_sale/static/tests/tours/website_event_sale.js index 0f1b1196f39..30e34483ade 100644 --- a/addons/website_event_sale/static/tests/tours/website_event_sale.js +++ b/addons/website_event_sale/static/tests/tours/website_event_sale.js @@ -1,6 +1,7 @@ /** @odoo-module **/ import { registry } from "@web/core/registry"; +import wsTourUtils from '@website_sale/js/tours/tour_utils'; registry.category("web_tour.tours").add('event_buy_tickets', { test: true, @@ -47,39 +48,11 @@ registry.category("web_tour.tours").add('event_buy_tickets', { extra_trigger: "input[name*='1-name'], input[name*='2-name'], input[name*='3-name']", trigger: 'button[type=submit]', }, - { - content: "Check that the cart contains exactly 3 triggers", - trigger: 'a:has(.my_cart_quantity:containsExact(3)),.o_extra_menu_items .fa-plus', - run: function () {}, // it's a check - }, - { - content: "go to cart", - trigger: 'a:contains(Return to Cart)', - }, - { - content: "Now click on `Process Checkout`", - extra_trigger: 'a:has(.my_cart_quantity):contains(3),#cart_products input.js_quantity[value="3"]', - trigger: '.btn-primary:contains("Process Checkout")' - }, - { - content: "Check that the subtotal is 4,000.00 USD", // this test will fail if the currency of the main company is not USD - trigger: '#order_total_untaxed .oe_currency_value:contains("4,000.00")', - run: function () {}, // it's a check - }, - { - content: "Select `Wire Transfer` payment method", - trigger: '#payment_method label:contains("Wire Transfer")', - }, - { - content: "Pay", - //Either there are multiple payment methods, and one is checked, either there is only one, and therefore there are no radio inputs - // extra_trigger: '#payment_method input:checked,#payment_method:not(:has("input:radio:visible"))', - trigger: 'button[name="o_payment_submit_button"]:visible:not(:disabled)', - }, - { - content: "Last step", - trigger: '.oe_website_sale_tx_status:contains("Please use the following transfer details")', - timeout: 30000, - } + wsTourUtils.goToCart({quantity: 3}), + wsTourUtils.goToCheckout(), + ...wsTourUtils.assertCartAmounts({ + untaxed: '4,000.00', + }), + ...wsTourUtils.payWithTransfer(), ] }); diff --git a/addons/website_event_sale/static/tests/tours/website_event_sale_last_ticket.js b/addons/website_event_sale/static/tests/tours/website_event_sale_last_ticket.js index e78fd6b5582..a2550faa239 100644 --- a/addons/website_event_sale/static/tests/tours/website_event_sale_last_ticket.js +++ b/addons/website_event_sale/static/tests/tours/website_event_sale_last_ticket.js @@ -1,6 +1,7 @@ /** @odoo-module **/ import { registry } from "@web/core/registry"; +import wsTourUtils from '@website_sale/js/tours/tour_utils'; registry.category("web_tour.tours").add('event_buy_last_ticket', { test: true, @@ -58,33 +59,5 @@ registry.category("web_tour.tours").add('event_buy_last_ticket', { content: "Validate address", trigger: '.btn-primary:contains("Next")', }, - { - // if the seats_available checking logic is not correct, - // the shopping cart will be cleared when selling the last ticket - // the tour test will be failed here - content: "Select `Wire Transfer` payment method", - trigger: '#payment_method label:contains("Wire Transfer")', - }, - // following steps are based on the website_sale_buy.js - { - content: "Pay", - //Either there are multiple payment methods, and one is checked, either there is only one, and therefore there are no radio inputs - extra_trigger: '#payment_method label:contains("Wire Transfer") input:checked,#payment_method:not(:has("input:radio:visible"))', - trigger: 'button[name="o_payment_submit_button"]:visible:not(:disabled)', - }, - { - content: "payment finish", - trigger: '.oe_website_sale:contains("Please use the following transfer details")', - // Leave /shop/confirmation to prevent RPC loop to /shop/payment/get_status. - // The RPC could be handled in python while the tour is killed (and the session), leading to crashes - run: function () { - window.location.href = '/contactus'; // Redirect in JS to avoid the RPC loop (20x1sec) - }, - timeout: 30000, - }, - { - content: "wait page loaded", - trigger: 'h1:contains("Contact us")', - run: function () {}, // it's a check - }, + ...wsTourUtils.payWithTransfer(true), ]}); diff --git a/addons/website_sale/static/src/js/tours/tour_utils.js b/addons/website_sale/static/src/js/tours/tour_utils.js index 49ae46633a7..67878f79cde 100644 --- a/addons/website_sale/static/src/js/tours/tour_utils.js +++ b/addons/website_sale/static/src/js/tours/tour_utils.js @@ -18,6 +18,39 @@ function addToCart({productName, search = true, productHasVariants = false}) { return steps; } +function assertCartAmounts({taxes = false, untaxed = false, total = false, delivery = false}) { + let steps = []; + if (taxes) { + steps.push({ + content: 'Check if the tax is correct', + trigger: `tr#order_total_taxes .oe_currency_value:containsExact(${taxes})`, + run: function () {}, // it's a check + }); + } + if (untaxed) { + steps.push({ + content: 'Check if the tax is correct', + trigger: `tr#order_total_untaxed .oe_currency_value:containsExact(${untaxed})`, + run: function () {}, // it's a check + }); + } + if (total) { + steps.push({ + content: 'Check if the tax is correct', + trigger: `tr#order_total .oe_currency_value:containsExact(${total})`, + run: function () {}, // it's a check + }); + } + if (delivery) { + steps.push({ + content: 'Check if the tax is correct', + trigger: `tr#order_delivery .oe_currency_value:containsExact(${delivery})`, + run: function () {}, // it's a check + }); + } + return steps +} + function assertCartContains({productName, backend, notContains = false} = {}) { let trigger = `a:contains(${productName})`; @@ -80,6 +113,74 @@ function goToCart({quantity = 1, position = "bottom", backend = false} = {}) { }; } +function goToCheckout() { + return { + content: 'Checkout your order', + trigger: 'a[role="button"] span:contains("Process Checkout")', + run: 'click', + }; +} + +function pay() { + return { + content: 'Pay', + //Either there are multiple payment methods, and one is checked, either there is only one, and therefore there are no radio inputs + // extra_trigger: '#payment_method input:checked,#payment_method:not(:has("input:radio:visible"))', + trigger: 'button[name="o_payment_submit_button"]:visible:not(:disabled)' + }; +} + +function payWithDemo() { + return [{ + content: 'eCommerce: select Test payment provider', + trigger: '.o_payment_option_card:contains("Demo")' + }, { + content: 'eCommerce: add card number', + trigger: 'input[name="customer_input"]', + run: 'text 4242424242424242' + }, + pay(), + { + content: 'eCommerce: check that the payment is successful', + trigger: '.oe_website_sale_tx_status:contains("Your payment has been successfully processed.")', + run: function () {} + }] +} + +function payWithTransfer(redirect=false) { + const first_step = { + content: "Select `Wire Transfer` payment method", + trigger: '#payment_method label:contains("Wire Transfer")', + } + if (!redirect) { + return [ + first_step, + pay(), + { + content: "Last step", + trigger: '.oe_website_sale_tx_status:contains("Please use the following transfer details")', + timeout: 30000, + }] + } else { + return [ + first_step, + pay(), + { + content: "Last step", + trigger: '.oe_website_sale_tx_status:contains("Please use the following transfer details")', + timeout: 30000, + run: () => { + window.location.href = '/contactus'; // Redirect in JS to avoid the RPC loop (20x1sec) + }, + }, { + content: "wait page loaded", + trigger: 'h1:contains("Contact us")', + run: function () {}, // it's a check + } + ] + } +} + function searchProduct(productName) { return [ wTourUtils.clickOnElement('Shop', 'a:contains("Shop")'), @@ -110,10 +211,15 @@ function selectPriceList(pricelist) { export default { addToCart, + assertCartAmounts, assertCartContains, assertProductPrice, fillAdressForm, goToCart, + goToCheckout, + pay, + payWithDemo, + payWithTransfer, selectPriceList, searchProduct, }; diff --git a/addons/website_sale/static/tests/tours/website_free_delivery.js b/addons/website_sale/static/tests/tours/website_free_delivery.js index 4a9abdafe9f..547bcd681f5 100644 --- a/addons/website_sale/static/tests/tours/website_free_delivery.js +++ b/addons/website_sale/static/tests/tours/website_free_delivery.js @@ -4,24 +4,13 @@ import { registry } from "@web/core/registry"; import tourUtils from "@website_sale/js/tours/tour_utils"; registry.category("web_tour.tours").add('check_free_delivery', { - test: true, - url: '/shop?search=office chair black', - steps: () => [ + test: true, + url: '/shop', + steps: () => [ // Part 1: Check free delivery - { - content: "select office chair black", - trigger: '.oe_product_cart a:contains("Office Chair Black TEST")', - }, - { - content: "click on add to cart", - trigger: '#product_details #add_to_cart', - }, - tourUtils.goToCart(), - { - content: "go to checkout", - extra_trigger: '#cart_products input.js_quantity:propValue(1)', - trigger: 'a[href*="/shop/checkout"]', - }, + ...tourUtils.addToCart({productName: "Office Chair Black TEST"}), + tourUtils.goToCart({quantity: 1}), + tourUtils.goToCheckout(), { content: "Check Free Delivery value to be zero", extra_trigger: '#delivery_carrier label:containsExact("Delivery Now Free Over 10")', @@ -38,14 +27,12 @@ registry.category("web_tour.tours").add('check_free_delivery', { content: "Select `Wire Transfer` payment method", trigger: '#payment_method label:contains("Wire Transfer")', }, - { - content: "Click on Pay Now", - trigger: 'button[name="o_payment_submit_button"]:visible:not(:disabled)', - }, + tourUtils.pay(), { content: "Confirmation page should be shown", trigger: '#oe_structure_website_sale_confirmation_1', allowInvisible: true, run: function () {}, // it's a check } - ]}); + ], +}); diff --git a/addons/website_sale/static/tests/tours/website_sale_buy.js b/addons/website_sale/static/tests/tours/website_sale_buy.js index 18a163f347a..be5b8ede68d 100644 --- a/addons/website_sale/static/tests/tours/website_sale_buy.js +++ b/addons/website_sale/static/tests/tours/website_sale_buy.js @@ -63,30 +63,6 @@ registry.category("web_tour.tours").add('shop_buy_product', { extra_trigger: '#cart_products input.js_quantity:propValue(1)', trigger: 'a[href*="/shop/checkout"]', }, - { - content: "select payment", - trigger: '#payment_method label:contains("Wire Transfer")', - }, - { - content: "Pay Now", - //Either there are multiple payment methods, and one is checked, either there is only one, and therefore there are no radio inputs - extra_trigger: '#payment_method label:contains("Wire Transfer") input:checked,#payment_method:not(:has("input:radio:visible"))', - trigger: 'button[name="o_payment_submit_button"]:visible:not(:disabled)', - }, - { - content: "finish", - trigger: '.oe_website_sale:contains("Please use the following transfer details")', - // Leave /shop/confirmation to prevent RPC loop to /shop/payment/get_status. - // The RPC could be handled in python while the tour is killed (and the session), leading to crashes - run: function () { - window.location.href = '/contactus'; // Redirect in JS to avoid the RPC loop (20x1sec) - }, - timeout: 30000, - }, - { - content: "wait page loaded", - trigger: 'h1:contains("Contact us")', - run: function () {}, // it's a check - }, + ...tourUtils.payWithTransfer(true), ] }); diff --git a/addons/website_sale/static/tests/tours/website_sale_cart_popover.js b/addons/website_sale/static/tests/tours/website_sale_cart_popover.js index 086a60850ff..81aa27557ab 100644 --- a/addons/website_sale/static/tests/tours/website_sale_cart_popover.js +++ b/addons/website_sale/static/tests/tours/website_sale_cart_popover.js @@ -1,20 +1,13 @@ /** @odoo-module **/ import { registry } from "@web/core/registry"; -import wTourUtils from '@website/js/tours/tour_utils'; +import wsTourUtils from '@website_sale/js/tours/tour_utils'; registry.category("web_tour.tours").add('website_sale_cart_popover_tour', { - test: true, - url: '/shop', - steps: () => [ - { - content: "Search for the product", - trigger: 'form input[name="search"]', - run: 'text website_sale_cart_popover_tour_product' - }, - wTourUtils.clickOnElement('Search', 'form:has(input[name="search"]) .oe_search_button'), - wTourUtils.clickOnElement('website_sale_cart_popover_tour_product', 'a:contains(website_sale_cart_popover_tour_product)'), - wTourUtils.clickOnElement('Add to Cart', '#product_detail form[action^="/shop/cart/update"] #add_to_cart'), + test: true, + url: '/shop', + steps: () => [ + ...wsTourUtils.addToCart({productName: "website_sale_cart_popover_tour_product"}), { content: "hover on cart popover", trigger: '#top_menu a[href$="/shop/cart"]', diff --git a/addons/website_sale/static/tests/tours/website_sale_complete_flow.js b/addons/website_sale/static/tests/tours/website_sale_complete_flow.js index 9dc155ceeb3..483989fee1b 100644 --- a/addons/website_sale/static/tests/tours/website_sale_complete_flow.js +++ b/addons/website_sale/static/tests/tours/website_sale_complete_flow.js @@ -33,21 +33,11 @@ extra_trigger: '#cart_products tr:contains("Storage Box Test") input.js_quantity:propValue(2)', trigger: 'a[href*="/shop/checkout"]', }, - { - content: "Check Price b2b subtotal", - trigger: 'tr#order_total_untaxed .oe_currency_value:containsExact(158.00)', - run: function () {}, // it's a check - }, - { - content: "Check Price b2b Sale Tax(15%)", - trigger: 'tr#order_total_taxes .oe_currency_value:containsExact(23.70)', - run: function () {}, // it's a check - }, - { - content: "Check Price b2b Total amount", - trigger: 'tr#order_total .oe_currency_value:containsExact(181.70)', - run: function () {}, // it's a check - }, + ...tourUtils.assertCartAmounts({ + taxes: '23.70', + untaxed: '158.00', + total: '181.70', + }), { content: "Fulfill billing address form", trigger: 'select[name="country_id"]', @@ -227,21 +217,11 @@ extra_trigger: '#cart_products tr:contains("Storage Box Test") input.js_quantity:propValue(2)', trigger: 'a[href*="/shop/checkout"]', }, - { - content: "Check Price b2c total", - trigger: 'tr#order_total_untaxed .oe_currency_value:containsExact(158.00)', - run: function () {}, // it's a check - }, - { - content: "Check Price b2c Sale Tax(15%)", - trigger: 'tr#order_total_taxes .oe_currency_value:containsExact(23.70)', - run: function () {}, // it's a check - }, - { - content: "Check Price b2c Total amount", - trigger: 'tr#order_total .oe_currency_value:containsExact(181.70)', - run: function () {}, // it's a check - }, + ...tourUtils.assertCartAmounts({ + taxes: '23.70', + untaxed: '158.00', + total: '181.70', + }), { content: "Click on Sign in Button", trigger: '.oe_cart a:contains(" Sign in")', diff --git a/addons/website_sale/static/tests/tours/website_sale_shop_cart_recovery.js b/addons/website_sale/static/tests/tours/website_sale_shop_cart_recovery.js index d847b23a1da..8a08276d590 100644 --- a/addons/website_sale/static/tests/tours/website_sale_shop_cart_recovery.js +++ b/addons/website_sale/static/tests/tours/website_sale_shop_cart_recovery.js @@ -9,16 +9,9 @@ var recoveryLinkKey = 'website_sale.tour_shop_cart_recovery.recoveryLink'; registry.category("web_tour.tours").add('shop_cart_recovery', { test: true, - url: '/shop?search=Acoustic Bloc Screens', + url: '/shop', steps: () => [ - { - content: "select Acoustic Bloc Screens", - trigger: '.oe_product_cart a:containsExact("Acoustic Bloc Screens")', - }, - { - content: "click add to cart", - trigger: '#product_details #add_to_cart', - }, + ...tourUtils.addToCart({productName: "Acoustic Bloc Screens"}), tourUtils.goToCart(), { content: "check product is in cart, get cart id, logout, go to login", diff --git a/addons/website_sale_autocomplete/static/tests/autocomplete_tour.js b/addons/website_sale_autocomplete/static/tests/autocomplete_tour.js index 316edf7f186..68a97bdbcb1 100644 --- a/addons/website_sale_autocomplete/static/tests/autocomplete_tour.js +++ b/addons/website_sale_autocomplete/static/tests/autocomplete_tour.js @@ -12,22 +12,11 @@ function fail (errorMessage) { registry.category("web_tour.tours").add('autocomplete_tour', { test: true, url: '/shop', // /shop/address is redirected if no sales order - steps: () => [{ - content: "search test product", - trigger: 'form input[name="search"]', - run: "text A test product", -},{ - content: 'Go to the product page', - trigger: '.dropdown-item:contains("A test product")' -}, { - content: 'Add to cart', - trigger: '#add_to_cart' -}, + steps: () => [ + ...tourUtils.addToCart({productName: "A test product"}), tourUtils.goToCart(), -{ - content: 'Go to process checkout', - trigger: 'a:contains("Process Checkout")' -}, { // Actual test + tourUtils.goToCheckout(), +{ // Actual test content: 'Input in Street & Number field', trigger: 'input[name="street"]', run: 'text This is a test' diff --git a/addons/website_sale_loyalty/static/tests/tours/test_gift_card_tour.js b/addons/website_sale_loyalty/static/tests/tours/test_gift_card_tour.js index 593bd37eabd..fe3df2664cf 100644 --- a/addons/website_sale_loyalty/static/tests/tours/test_gift_card_tour.js +++ b/addons/website_sale_loyalty/static/tests/tours/test_gift_card_tour.js @@ -5,18 +5,10 @@ import tourUtils from '@website_sale/js/tours/tour_utils'; registry.category("web_tour.tours").add('shop_sale_gift_card', { test: true, - url: '/shop?search=Small%20Drawer', + url: '/shop', steps: () => [ // Add a small drawer to the order (50$) - { - content: 'select Small Drawer', - extra_trigger: '.oe_search_found', - trigger: '.oe_product_cart a:contains("TEST - Small Drawer")', - }, - { - content: 'Add Small Drawer into cart', - trigger: 'a:contains(ADD TO CART)', - }, + ...tourUtils.addToCart({productName: "TEST - Small Drawer"}), tourUtils.goToCart(), { content: 'Click on "I have a promo code"', @@ -55,29 +47,8 @@ registry.category("web_tour.tours").add('shop_sale_gift_card', { trigger: '.oe_website_sale .oe_cart', run: function () {}, // it's a check }, - { - content: 'go to shop', - trigger: 'a:contains("Shop")', - }, - { - content: "type Gift Card in search", - trigger: 'form input[name="search"]', - run: "text Gift Card", - }, - { - content: "start search", - trigger: 'form:has(input[name="search"]) .oe_search_button', - }, - { - content: "select Gift Card", - extra_trigger: '.oe_search_found', // Wait to be on search results or it sometimes throws concurent error (sent search form + click on product on /shop) - trigger: '.oe_product_cart a:containsExact("TEST - Gift Card")', - }, - { - content: "click on 'Add to Cart' button", - trigger: "a:contains(ADD TO CART)", - }, - tourUtils.goToCart({quantity: 2}), + ...tourUtils.addToCart({productName: "TEST - Gift Card"}), + tourUtils.goToCart({quantity: 2}), { content: 'check gift card amount', trigger: '.oe_website_sale .oe_cart', diff --git a/addons/website_sale_loyalty/static/tests/tours/test_promo_main_tour.js b/addons/website_sale_loyalty/static/tests/tours/test_promo_main_tour.js index c2a2534c7e4..9f918e55548 100644 --- a/addons/website_sale_loyalty/static/tests/tours/test_promo_main_tour.js +++ b/addons/website_sale_loyalty/static/tests/tours/test_promo_main_tour.js @@ -74,24 +74,7 @@ registry.category("web_tour.tours").add('shop_sale_loyalty', { }); }, }, - { - content: "type Taxed Product in search", - trigger: 'form input[name="search"]', - run: "text Taxed Product", - }, - { - content: "start search", - trigger: 'form:has(input[name="search"]) .oe_search_button', - }, - { - content: "select Taxed Product", - extra_trigger: '.oe_search_found', // Wait to be on search results or it sometimes throws concurent error (sent search form + click on product on /shop) - trigger: '.oe_product_cart a:containsExact("Taxed Product")', - }, - { - content: "click on 'Add to Cart' button", - trigger: "a:contains(ADD TO CART)", - }, + ...tourUtils.addToCart({productName: "Taxed Product"}), tourUtils.goToCart({quantity: 3}), { content: "check reduction amount got recomputed and merged both discount lines into one only", @@ -135,10 +118,8 @@ registry.category("web_tour.tours").add('shop_sale_loyalty', { content: "go to checkout", trigger: 'a[href="/shop/checkout?express=1"]', }, - { - content: "check total is unchanged once we land on payment page", - trigger: 'tr#order_total .oe_currency_value:contains("967.50")', - run: function () {}, // it's a check - }, + ...tourUtils.assertCartAmounts({ + total: '967.50', + }), ] }); diff --git a/addons/website_sale_loyalty/static/tests/tours/website_sale_delivery_gift_card.js b/addons/website_sale_loyalty/static/tests/tours/website_sale_delivery_gift_card.js index f1c0613e612..7400a46ffa3 100644 --- a/addons/website_sale_loyalty/static/tests/tours/website_sale_delivery_gift_card.js +++ b/addons/website_sale_loyalty/static/tests/tours/website_sale_delivery_gift_card.js @@ -4,22 +4,10 @@ import { registry } from "@web/core/registry"; import wsTourUtils from "@website_sale/js/tours/tour_utils"; registry.category("web_tour.tours").add('shop_sale_loyalty_delivery', { - test: true, - url: '/shop?search=Accoustic', - steps: () => [ - { - content: "select Small Cabinet", - trigger: '.oe_product a:contains("Acoustic Bloc Screens")', - }, - { - content: "add 1 Small Cabinet into cart", - trigger: '#product_details input[name="add_qty"]', - run: "text 1", - }, - { - content: "click on 'Add to Cart' button", - trigger: "a:contains(ADD TO CART)", - }, + test: true, + url: '/shop', + steps: () => [ + ...wsTourUtils.addToCart({productName: "Acoustic Bloc Screens"}), wsTourUtils.goToCart(1), { content: "go to checkout", @@ -46,15 +34,9 @@ registry.category("web_tour.tours").add('shop_sale_loyalty_delivery', { trigger: "a[role='button'].a-submit:contains(Apply)", run: 'click' }, - { - content: "check if delivery price is correct'", - trigger: "#order_delivery .oe_currency_value:contains(5.00)", - run: () => {} // this is a check - }, - { - content: "check if total price is correct", - trigger: "tr#order_total span.oe_currency_value:contains(0.00)", - run: () => {} // this is a check - }, + ...wsTourUtils.assertCartAmounts({ + total: '0.00', + delivery: '5.00' + }), ] }); diff --git a/addons/website_sale_picking/static/tests/tours/onsite_payment_tour.js b/addons/website_sale_picking/static/tests/tours/onsite_payment_tour.js index 497ec020c2d..020003b5b7f 100644 --- a/addons/website_sale_picking/static/tests/tours/onsite_payment_tour.js +++ b/addons/website_sale_picking/static/tests/tours/onsite_payment_tour.js @@ -10,7 +10,7 @@ registry.category("web_tour.tours").add('onsite_payment_tour', { steps: () => [ ...wsTourUtils.addToCart({productName: 'Chair floor protection'}), wsTourUtils.goToCart(), - wTourUtils.clickOnElement('Proceed to checkout', 'a:contains(Process Checkout)'), + wsTourUtils.goToCheckout(), ...wsTourUtils.fillAdressForm(), wTourUtils.clickOnElement('Example shipping On Site', '.o_delivery_carrier_select:contains("Example shipping On Site")'), wTourUtils.clickOnElement('pay button', 'button[name="o_payment_submit_button"]:visible:not(:disabled)'), @@ -23,7 +23,7 @@ registry.category("web_tour.tours").add('onsite_payment_tour', { ...wsTourUtils.addToCart({productName: 'Customizable Desk', productHasVariants: true}), ...wsTourUtils.addToCart({productName: 'Warranty'}), wsTourUtils.goToCart({quantity: 2}), - wTourUtils.clickOnElement('Go to payment page', 'a:contains("Process Checkout")'), + wsTourUtils.goToCheckout(), ...wsTourUtils.fillAdressForm(), wTourUtils.clickOnElement('"Pay in store when picking the product"', '.o_delivery_carrier_select:contains("Example shipping On Site")'), wTourUtils.clickOnElement('Pay button', 'button[name="o_payment_submit_button"]:visible:not(:disabled)'), @@ -35,7 +35,7 @@ registry.category("web_tour.tours").add('onsite_payment_tour', { // Test without any physical product (option pay on site should not appear) ...wsTourUtils.addToCart({productName: 'Warranty'}), wsTourUtils.goToCart(), - wTourUtils.clickOnElement('Go to payment page', 'a:contains("Process Checkout")'), + wsTourUtils.goToCheckout(), ...wsTourUtils.fillAdressForm(), { content: 'Assert pay on site is NOT an option',