[FIX] website_sale_picking: make tour run as public user
This commits changes the onsite_payment_tour to public, this required to write some more steps to fill the adress form for instance. task_id=2980494 closes odoo/odoo#100239 Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
This commit is contained in:
@@ -3,7 +3,73 @@ odoo.define("website_sale.tour_utils", function (require) {
|
||||
|
||||
const core = require("web.core");
|
||||
const _t = core._t;
|
||||
const wTourUtils = require('website.tour_utils');
|
||||
|
||||
function addToCart({productName, search = true, productHasVariants = false}) {
|
||||
const steps = [];
|
||||
if (search) {
|
||||
steps.push(...searchProduct(productName));
|
||||
}
|
||||
steps.push(wTourUtils.clickOnElement(productName, `a:contains(${productName})`));
|
||||
steps.push(wTourUtils.clickOnElement('Add to cart', '#add_to_cart'));
|
||||
if (productHasVariants) {
|
||||
steps.push(wTourUtils.clickOnElement('Continue Shopping', 'button:contains("Continue Shopping")'));
|
||||
}
|
||||
return steps;
|
||||
}
|
||||
|
||||
function assertCartContains({productName, backend, notContains = false} = {}) {
|
||||
let trigger = `a:contains(${productName})`;
|
||||
|
||||
if (notContains) {
|
||||
trigger = `:not(${trigger})`;
|
||||
}
|
||||
return {
|
||||
content: `Checking if ${productName} is in the cart`,
|
||||
trigger: `${backend ? "iframe" : ""} ${trigger}`,
|
||||
run: () => {}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to assert if the price attribute of a given product is correct on the /shop view
|
||||
*/
|
||||
function assertProductPrice(attribute, value, productName) {
|
||||
return {
|
||||
content: `The ${attribute} of the ${productName} is ${value}`,
|
||||
trigger: `div:contains("${productName}") [data-oe-expression="template_price_vals['${attribute}']"] .oe_currency_value:contains("${value}")`,
|
||||
run: () => {}
|
||||
};
|
||||
}
|
||||
|
||||
function fillAdressForm(adressParams = {
|
||||
name: "John Doe",
|
||||
phone: "123456789",
|
||||
email: "johndoe@gmail.com",
|
||||
street: "1 rue de la paix",
|
||||
city: "Paris",
|
||||
zip: "75000"
|
||||
}) {
|
||||
let steps = [];
|
||||
steps.push({
|
||||
content: "Address filling",
|
||||
trigger: 'select[name="country_id"]',
|
||||
run: () => {
|
||||
$('input[name="name"]').val(adressParams.name);
|
||||
$('input[name="phone"]').val(adressParams.phone);
|
||||
$('input[name="email"]').val(adressParams.email);
|
||||
$('input[name="street"]').val(adressParams.street);
|
||||
$('input[name="city"]').val(adressParams.city);
|
||||
$('input[name="zip"]').val(adressParams.zip);
|
||||
$('#country_id option:eq(1)').attr('selected', true);
|
||||
}
|
||||
});
|
||||
steps.push({
|
||||
content: "Next",
|
||||
trigger: '.oe_cart .btn:contains("Next")',
|
||||
});
|
||||
return steps;
|
||||
}
|
||||
|
||||
function goToCart({quantity = 1, position = "bottom", backend = false} = {}) {
|
||||
return {
|
||||
@@ -14,17 +80,16 @@ odoo.define("website_sale.tour_utils", function (require) {
|
||||
};
|
||||
}
|
||||
|
||||
function assertCartContains({productName, backend, notContains = false} = {}) {
|
||||
let trigger = `a:contains(${productName})`;
|
||||
|
||||
if (notContains) {
|
||||
trigger = `:not(${trigger})`;
|
||||
}
|
||||
return {
|
||||
content: `Checking if ${productName} is in the cart`,
|
||||
trigger: `${backend ? "iframe" : ""} ${trigger}`,
|
||||
run: () => {}
|
||||
};
|
||||
function searchProduct(productName) {
|
||||
return [
|
||||
wTourUtils.clickOnElement('Shop', 'a:contains("Shop")'),
|
||||
{
|
||||
content: "Search for the product",
|
||||
trigger: 'form input[name="search"]',
|
||||
run: `text ${productName}`
|
||||
},
|
||||
wTourUtils.clickOnElement('Search', 'form:has(input[name="search"]) .oe_search_button'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -43,22 +108,13 @@ odoo.define("website_sale.tour_utils", function (require) {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to assert if the price attribute of a given product is correct on the /shop view
|
||||
*/
|
||||
function assertProductPrice(attribute, value, productName) {
|
||||
return {
|
||||
content: `The ${attribute} of the ${productName} is ${value}`,
|
||||
trigger: `div:contains("${productName}") [data-oe-expression="template_price_vals['${attribute}']"] .oe_currency_value:contains("${value}")`,
|
||||
run: () => {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
addToCart,
|
||||
assertCartContains,
|
||||
assertProductPrice,
|
||||
fillAdressForm,
|
||||
goToCart,
|
||||
selectPriceList,
|
||||
searchProduct,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -1,97 +1,46 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import tour from 'web_tour.tour'
|
||||
import wTourUtils from 'website.tour_utils';
|
||||
import wsTourUtils from 'website_sale.tour_utils';
|
||||
|
||||
tour.register('onsite_payment_tour', {
|
||||
test: true,
|
||||
url: '/shop'
|
||||
}, [ // first test : test whole onsite payment flow with physical products.
|
||||
{
|
||||
content: 'Select the first product',
|
||||
trigger: 'a:contains("Customizable Desk")',
|
||||
}, {
|
||||
content: 'Add the product to the cart',
|
||||
trigger: 'a:contains("ADD TO CART")'
|
||||
}, {
|
||||
content: 'Go to checkout page',
|
||||
trigger: 'button:contains("Proceed to Checkout")'
|
||||
}, {
|
||||
content: 'Go to payment page',
|
||||
trigger: 'a:contains("Process Checkout")'
|
||||
}, {
|
||||
content: 'Click on onsite delivery carrier',
|
||||
trigger: '.o_delivery_carrier_select:contains("On Site")'
|
||||
}, {
|
||||
content: 'Click on on site payment provider',
|
||||
trigger: '.o_payment_option_card:contains("Pay in store when picking the product")'
|
||||
}, {
|
||||
content: 'Click the pay button',
|
||||
trigger: 'button[name="o_payment_submit_button"]:visible:not(:disabled)'
|
||||
}, {
|
||||
content: 'Await the confirmation page',
|
||||
trigger: 'td:contains("Pay in store when picking the product")'
|
||||
}, {
|
||||
content: 'Head back to main page',
|
||||
trigger: '.nav-link:contains("Shop")'
|
||||
test: true,
|
||||
url: '/web',
|
||||
},
|
||||
[
|
||||
...wsTourUtils.addToCart({productName: 'Chair floor protection'}),
|
||||
wsTourUtils.goToCart(),
|
||||
wTourUtils.clickOnElement('Proceed to checkout', 'a:contains(Process Checkout)'),
|
||||
...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)'),
|
||||
{
|
||||
content: "Check if the payment is successful",
|
||||
trigger: 'p:contains(Your order has been saved. Please come to the store to pay for your products)',
|
||||
},
|
||||
|
||||
// Test multi products (Either physical or not)
|
||||
...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.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)'),
|
||||
{
|
||||
content: "Check if the payment is successful",
|
||||
trigger: 'p:contains(Your order has been saved. Please come to the store to pay for your products)',
|
||||
},
|
||||
|
||||
{ // Test multi products (Either physical or not)
|
||||
content: 'Select the first product',
|
||||
trigger: 'a:contains("Customizable Desk")',
|
||||
}, {
|
||||
content: 'Add the product to the cart',
|
||||
trigger: 'a:contains("ADD TO CART")'
|
||||
}, {
|
||||
content: 'Validate variant choice',
|
||||
trigger: 'button:contains("Continue Shopping")'
|
||||
}, {
|
||||
content: 'Head back to main page',
|
||||
trigger: '.nav-link:contains("Shop")'
|
||||
}, {
|
||||
content: 'Select the second product (Non physical)',
|
||||
trigger: 'a:contains("Warranty")',
|
||||
}, {
|
||||
content: 'Add the product to the cart',
|
||||
trigger: 'a:contains("ADD TO CART")'
|
||||
}, {
|
||||
content: 'Go to cart',
|
||||
trigger: '.nav-link[href="/shop/cart"]:contains("2")'
|
||||
}, {
|
||||
content: 'Go to payment page',
|
||||
trigger: 'a:contains("Process Checkout")'
|
||||
}, {
|
||||
content: 'Click on onsite delivery carrier',
|
||||
trigger: '.o_delivery_carrier_select:contains("On Site")'
|
||||
}, {
|
||||
content: 'Click on on site payment provider',
|
||||
trigger: '.o_payment_option_card:contains("Pay in store when picking the product")'
|
||||
}, {
|
||||
content: 'Click the pay button',
|
||||
trigger: 'button[name="o_payment_submit_button"]:visible:not(:disabled)'
|
||||
}, {
|
||||
content: 'Await the confirmation page',
|
||||
trigger: 'td:contains("Pay in store when picking the product")'
|
||||
}, {
|
||||
content: 'Head back to main page',
|
||||
trigger: '.nav-link:contains("Shop")'
|
||||
},
|
||||
// Test without any physical product (option pay on site should not appear)
|
||||
|
||||
{
|
||||
content: 'Select the (Non physical) product',
|
||||
trigger: 'a:contains("Warranty")',
|
||||
}, {
|
||||
content: 'Add the product to the cart',
|
||||
trigger: 'a:contains("ADD TO CART")'
|
||||
}, {
|
||||
content: 'Go to cart',
|
||||
trigger: '.nav-link[href="/shop/cart"]:contains("1")'
|
||||
}, {
|
||||
content: 'Go to payment page',
|
||||
trigger: 'a:contains("Process Checkout")'
|
||||
}, {
|
||||
content: 'Assert pay on site is NOT an option',
|
||||
trigger: 'body:not(:contains("Pay in store when picking the product"))'
|
||||
}
|
||||
]);
|
||||
// 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.fillAdressForm(),
|
||||
{
|
||||
content: 'Assert pay on site is NOT an option',
|
||||
trigger: 'body:not(:contains("Test Payment Provider"))',
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
@@ -6,12 +6,39 @@ from odoo.tests import HttpCase, tagged
|
||||
|
||||
@tagged('-at_install', 'post_install')
|
||||
class TestUi(HttpCase):
|
||||
def setUp(self):
|
||||
super(TestUi, self).setUp()
|
||||
# create a Chair floor protection product
|
||||
self.env['product.product'].create({
|
||||
'name': 'Chair floor protection',
|
||||
'type': 'consu',
|
||||
'website_published': True,
|
||||
'list_price': 1000,
|
||||
})
|
||||
# create a Customizable Desk product
|
||||
self.env['product.product'].create({
|
||||
'name': 'Customizable Desk',
|
||||
'type': 'consu',
|
||||
'website_published': True,
|
||||
'list_price': 1000,
|
||||
})
|
||||
# create a Warranty product
|
||||
self.env['product.product'].create({
|
||||
'name': 'Warranty',
|
||||
'type': 'service',
|
||||
'website_published': True,
|
||||
'list_price': 20,
|
||||
})
|
||||
|
||||
def test_onsite_payment_tour(self):
|
||||
# Make sure at least one onsite payment option exists.
|
||||
self.env['delivery.carrier'].create({
|
||||
'delivery_type': 'onsite',
|
||||
'is_published': True,
|
||||
'website_published': True,
|
||||
'name': 'Example shipping On Site',
|
||||
'product_id': self.env.ref('website_sale_picking.onsite_delivery_product').id
|
||||
'product_id': self.env.ref('website_sale_picking.onsite_delivery_product').id,
|
||||
})
|
||||
self.start_tour('/shop', 'onsite_payment_tour', login='admin')
|
||||
self.env.ref("website_sale_picking.payment_provider_onsite").is_published = True
|
||||
|
||||
self.start_tour('/shop', 'onsite_payment_tour')
|
||||
|
||||
Reference in New Issue
Block a user