[ADD] website_sale: adds a complete ecommerce tour/flow

This commit adds `website_sale_tour` test which is testing the whole ecommerce
flow.

This tour will test b2b and b2c flow using public user, tests website sale
flows with tax included and tax excluded price. Also test address management.

Also, the signup URL needed to be modified as PhantomJS run all tour on domain
127.0.0.1 but ignup button has absolute URL.
Runbot stores next step to be executed on `localStorage` and due to domain
name change during tour execution, it will lose track and runbot will fail.

Closes: #24179
Task-1829827

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>


Co-authored-by: Ravi Gadhia <rga@odoo.com>
Co-authored-by: Mohammed Shekha <msh@openerp.com>
This commit is contained in:
Priyanka Kakadiya
2019-05-16 05:41:21 +00:00
committed by Mohammed Shekha
co-authored by Ravi Gadhia Mohammed Shekha
parent dd182c8eb3
commit 559bdc976e
4 changed files with 458 additions and 2 deletions
+5 -1
View File
@@ -94,7 +94,11 @@ class ResPartner(models.Model):
if fragment:
query['redirect'] = base + werkzeug.urls.url_encode(fragment)
res[partner.id] = werkzeug.urls.url_join(base_url, "/web/%s?%s" % (route, werkzeug.urls.url_encode(query)))
url = "/web/%s?%s" % (route, werkzeug.urls.url_encode(query))
if not self.env.context.get('relative_url'):
url = werkzeug.urls.url_join(base_url, url)
res[partner.id] = url
return res
@api.multi
@@ -0,0 +1,448 @@
odoo.define('website_sale_tour.tour', function (require) {
'use strict';
var ajax = require('web.ajax');
var tour = require("web_tour.tour");
var rpc = require("web.rpc");
tour.register('website_sale_tour', {
test: true,
url: '/',
}, [{
content: "Configuration Settings for 'Free Sign Up' and 'Tax-Excluded'",
trigger: '#wrapwrap',
run: function () {
var taxDef = $.Deferred();
ajax.jsonRpc('/web/dataset/call', 'call', {
model: 'product.template',
method: 'search',
args: [[['name', '=', 'Storage Box']]],
}).then(function (productId) {
return ajax.jsonRpc('/web/dataset/call', 'call', {
model: 'account.tax.group',
method: 'create',
args: [{
'name': 'Tax 15%',
}],
}).then(function (taxGroupId) {
return ajax.jsonRpc('/web/dataset/call', 'call', {
model: 'account.tax',
method: 'create',
args: [{
'name': 'Tax 15%',
'amount': 15,
'type_tax_use': 'sale',
'tax_group_id': taxGroupId,
}],
}).then(function (taxId) {
return ajax.jsonRpc('/web/dataset/call', 'call', {
model: 'product.template',
method: 'write',
args: [productId, {
'taxes_id': [[4, taxId]],
}],
}).then(function () {
taxDef.resolve();
});
});
});
});
var def1 = rpc.query({
model: 'res.config.settings',
method: 'create',
args: [{
'auth_signup_uninvited': 'b2c',
'show_line_subtotals_tax_selection': 'tax_excluded',
'group_show_line_subtotals_tax_excluded': true,
'group_show_line_subtotals_tax_included': false,
}],
});
var def2 = def1.then(function (resId) {
return rpc.query({
model: 'res.config.settings',
method: 'execute',
args: [[resId]],
});
});
return Promise.all([taxDef, def2]).then(function (res) {
window.location.href = '/web/session/logout?redirect=/shop?search=Storage Box';
});
},
},
// Testing b2c with Tax-Excluded Prices
{
content: "Open product page",
trigger: '.oe_product_cart a:contains("Storage Box")',
},
{
content: "Add one more storage box",
trigger: '.js_add_cart_json:eq(1)',
},
{
content: "Check b2b Tax-Excluded Prices",
trigger: '.product_price .oe_price .oe_currency_value:containsExact(79.00)',
run: function () {}, // it's a check
},
{
content: "Click on add to cart",
trigger: '#add_to_cart',
},
{
content: "Check for 2 products in cart and proceed to checkout",
extra_trigger: '#cart_products tr:contains("Storage Box") 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
},
{
content: "Fulfill billing address form",
trigger: 'select[name="country_id"]',
run: function () {
$('input[name="name"]').val('abc');
$('input[name="phone"]').val('99999999');
$('input[name="email"]').val('abc@odoo.com');
$('input[name="street"]').val('SO1 Billing Street, 33');
$('input[name="city"]').val('SO1BillingCity');
$('#country_id option:eq(1)').attr('selected', true);
},
},
{
content: "Shipping address is not same as billing address",
trigger: '#shipping_use_same',
},
{
content: "Click on next button",
trigger: '.oe_cart .btn:contains("Next")',
},
{
content: "Fulfill shipping address form",
trigger: 'select[name="country_id"]',
extra_trigger: 'h2:contains("Shipping Address")',
run: function () {
$('input[name="name"]').val('def');
$('input[name="phone"]').val('8888888888');
$('input[name="street"]').val('17, SO1 Shipping Road');
$('input[name="city"]').val('SO1ShippingCity');
$('#country_id option:eq(1)').attr('selected', true);
},
},
{
content: "Click on next button",
trigger: '.oe_cart .btn:contains("Next")',
},
{
content: "Check selected billing address is same as typed in previous step",
trigger: '#shipping_and_billing:contains(SO1 Billing Street, 33):contains(SO1BillingCity):contains(Afghanistan)',
run: function () {}, // it's a check
},
{
content: "Check selected shipping address is same as typed in previous step",
trigger: '#shipping_and_billing:contains(17, SO1 Shipping Road):contains(SO1ShippingCity):contains(Afghanistan)',
run: function () {}, // it's a check
},
{
content: "Click for edit address",
trigger: 'a:contains("Edit") i',
},
{
content: "Click for edit billing address",
trigger: '.js_edit_address:first',
},
{
content: "Change billing address form",
trigger: 'select[name="country_id"]',
extra_trigger: 'h2:contains("Your Address")',
run: function () {
$('input[name="name"]').val('abcd');
$('input[name="phone"]').val('11111111');
$('input[name="street"]').val('SO1 Billing Street Edited, 33');
$('input[name="city"]').val('SO1BillingCityEdited');
},
},
{
content: "Click on next button",
trigger: '.oe_cart .btn:contains("Next")',
},
{
content: "Confirm Address",
trigger: 'a.btn:contains("Confirm")',
},
{
content: "Check selected billing address is same as typed in previous step",
trigger: '#shipping_and_billing:contains(SO1 Billing Street Edited, 33):contains(SO1BillingCityEdited):contains(Afghanistan)',
run: function () {}, // it's a check
},
{
content: "Select `Wire Transfer` payment method",
trigger: '#payment_method label:contains("Wire Transfer")',
},
{
content: "Pay Now",
extra_trigger: '#payment_method label:contains("Wire Transfer") input:checked,#payment_method:not(:has("input:radio:visible"))',
trigger: 'button[id="o_payment_form_pay"]:visible:not(:disabled)',
},
{
content: "Sign up",
trigger: '.oe_cart a:contains("Sign Up")',
},
{
content: "Submit login",
trigger: '.oe_signup_form',
run: function () {
$('.oe_signup_form input[name="password"]').val("1admin@admin");
$('.oe_signup_form input[name="confirm_password"]').val("1admin@admin");
$('.oe_signup_form input[name="redirect"]').val("/my");
$('.oe_signup_form').submit();
},
},
{
content: "See Quotations",
trigger: '.o_portal_docs a:contains("Quotations")',
},
// Sign in as admin change config auth_signup -> b2b, sale_show_tax -> total and Logout
{
content: "Open Dropdown for logout",
trigger: '#top_menu li.dropdown:visible a:contains("abcd")',
},
{
content: "Logout",
trigger: '#o_logout:contains("Logout")',
},
{
content: "Sign in as admin",
trigger: '#top_menu li a b:contains("Sign in")',
},
{
content: "Submit login",
trigger: '.oe_login_form',
run: function () {
$('.oe_login_form input[name="login"]').val("admin");
$('.oe_login_form input[name="password"]').val("admin");
$('.oe_login_form input[name="redirect"]').val("/");
$('.oe_login_form').submit();
},
},
{
content: "Configuration Settings for 'Tax Included' and sign up 'On Invitation'",
extra_trigger: '.o_connected_user #wrapwrap',
trigger: '#wrapwrap',
run: function () {
var def1 = rpc.query({
model: 'res.config.settings',
method: 'create',
args: [{
'auth_signup_uninvited': 'b2b',
'show_line_subtotals_tax_selection': 'tax_included',
'group_show_line_subtotals_tax_excluded': false,
'group_show_line_subtotals_tax_included': true,
}],
});
var def2 = def1.then(function (resId) {
return rpc.query({
model: 'res.config.settings',
method: 'execute',
args: [[resId]],
});
});
def2.then(function () {
window.location.href = '/web/session/logout?redirect=/shop?search=Storage Box';
});
},
},
// Testing b2b with Tax-Included Prices
{
content: "Open product page",
trigger: '.oe_product_cart a:contains("Storage Box")',
},
{
content: "Add one more Storage Box",
trigger: '.js_add_cart_json:eq(1)',
},
{
content: "Check b2c Tax-Included Prices",
trigger: '.product_price .oe_price .oe_currency_value:containsExact(90.85)',
run: function () {}, // it's a check
},
{
content: "Click on add to cart",
trigger: '#add_to_cart',
},
{
content: "Check for 2 products in cart and proceed to checkout",
extra_trigger: '#cart_products tr:contains("Storage Box") 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
},
{
content: "Click on Login Button",
trigger: '.oe_cart a.btn:contains("Log In")',
},
{
content: "Submit login",
trigger: '.oe_login_form',
run: function () {
$('.oe_login_form input[name="login"]').val("abc@odoo.com");
$('.oe_login_form input[name="password"]').val("1admin@admin");
$('.oe_login_form').submit();
},
},
{
content: "Add new shipping address",
trigger: '.one_kanban form[action^="/shop/address"] .btn',
},
{
content: "Fulfill shipping address form",
trigger: 'select[name="country_id"]',
run: function () {
$('input[name="name"]').val('ghi');
$('input[name="phone"]').val('7777777777');
$('input[name="street"]').val('SO2New Shipping Street, 5');
$('input[name="city"]').val('SO2NewShipping');
$('#country_id option:eq(1)').attr('selected', true);
},
},
{
content: "Click on next button",
trigger: '.oe_cart .btn:contains("Next")',
},
{
content: "Select `Wire Transfer` payment method",
trigger: '#payment_method label:contains("Wire Transfer")',
},
{
content: "Pay Now",
extra_trigger: '#payment_method label:contains("Wire Transfer") input:checked,#payment_method:not(:has("input:radio:visible"))',
trigger: 'button[id="o_payment_form_pay"]:visible:not(:disabled)',
},
{
content: "Open Dropdown for See quotation",
extra_trigger: '.oe_cart .oe_website_sale_tx_status',
trigger: '#top_menu li.dropdown:visible a:contains("abc")',
},
{
content: "My account",
extra_trigger: '#top_menu li.dropdown .js_usermenu.show',
trigger: '#top_menu .dropdown-menu a[href="/my/home"]:visible',
},
{
content: "See Quotations",
trigger: '.o_portal_docs a:contains("Quotations") .badge:containsExact(2)',
},
// enable extra step on website checkout and check extra step on checkout process
{
content: "Open Dropdown for logout",
trigger: '#top_menu li.dropdown:visible a:contains("abc")',
},
{
content: "Logout",
trigger: '#o_logout:contains("Logout")',
},
{
content: "Sign in as admin",
trigger: '#top_menu li a b:contains("Sign in")',
},
{
content: "Submit login",
trigger: '.oe_login_form',
run: function () {
$('.oe_login_form input[name="login"]').val("admin");
$('.oe_login_form input[name="password"]').val("admin");
$('.oe_login_form input[name="redirect"]').val("/shop/cart");
$('.oe_login_form').submit();
},
},
{
content: "Open Customize menu",
trigger: '.o_menu_sections a:contains("Customize")',
},
{
content: "Enable Extra step",
trigger: 'a.dropdown-item label:contains("Extra Step Option")',
},
{
content: "Open Dropdown for logout",
extra_trigger: '.progress-wizard-step:contains("Extra Info")',
trigger: '#top_menu li.dropdown:visible a:contains("Mitchell Admin")',
},
{
content: "Logout",
trigger: '#o_logout:contains("Logout")',
},
{
content: "Sign in as abc",
trigger: '#top_menu li a b:contains("Sign in")',
},
{
content: "Submit login",
trigger: '.oe_login_form',
run: function () {
$('.oe_login_form input[name="login"]').val("abc@odoo.com");
$('.oe_login_form input[name="password"]').val("1admin@admin");
$('.oe_login_form input[name="redirect"]').val("/shop?search=Storage Box");
$('.oe_login_form').submit();
},
},
{
content: "Open product page",
trigger: '.oe_product_cart a:contains("Storage Box")',
},
{
content: "Click on add to cart",
trigger: '#add_to_cart',
},
{
content: "Proceed to checkout",
trigger: 'a[href*="/shop/checkout"]',
},
{
content: "Click on next button",
trigger: '.oe_cart .btn:contains("Next")',
},
{
content: "Check selected billing address is same as typed in previous step",
trigger: '#shipping_and_billing:contains(SO1 Billing Street Edited, 33):contains(SO1BillingCityEdited):contains(Afghanistan)',
run: function () {}, // it's a check
},
{
content: "Check selected shipping address is same as typed in previous step",
trigger: '#shipping_and_billing:contains(SO2New Shipping Street, 5):contains(SO2NewShipping):contains(Afghanistan)',
run: function () {}, // it's a check
},
{
content: "Select `Wire Transfer` payment method",
trigger: '#payment_method label:contains("Wire Transfer")',
},
{
content: "Pay Now",
extra_trigger: '#payment_method label:contains("Wire Transfer") input:checked,#payment_method:not(:has("input:radio:visible"))',
trigger: 'button[id="o_payment_form_pay"]:visible',
}]);
});
@@ -14,4 +14,7 @@ class TestUi(odoo.tests.HttpCase):
def test_03_demo_checkout(self):
self.start_tour("/", 'shop_buy_product', login="demo")
def test_04_admin_website_sale_tour(self):
self.start_tour("/", 'website_sale_tour', login="admin")
# TO DO - add public test with new address when convert to web.tour format.
+2 -1
View File
@@ -35,6 +35,7 @@
<script type="text/javascript" src="/website_sale/static/src/js/website_sale_tour_shop_deleted_archived_variants.js"></script>
<script type="text/javascript" src="/website_sale/static/src/js/website_sale_tour_shop_list_view_b2c.js"></script>
<script type="text/javascript" src="/website_sale/static/src/js/website_sale_tour_shop_no_variant_attribute.js"></script>
<script type="text/javascript" src="/website_sale/static/src/js/website_sale_tour.js"></script>
</xpath>
</template>
@@ -1471,7 +1472,7 @@
</t>
<t t-if="request.env['ir.config_parameter'].sudo().get_param('auth_signup.invitation_scope', 'b2b') == 'b2c' and request.website.is_public_user()">
<p class="alert alert-info mt-3" role="status">
<a role="button" t-att-href='order.partner_id.signup_prepare() and order.partner_id.signup_url' class='btn btn-primary'>Sign Up</a>
<a role="button" t-att-href='order.partner_id.signup_prepare() and order.partner_id.with_context(relative_url=True).signup_url' class='btn btn-primary'>Sign Up</a>
to follow your order.
</p>
</t>