[MERGE] forward port branch 11.0 up to 10886317711
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
odoo.define('website_sale_coupon.test', function (require) {
|
||||
'use strict';
|
||||
|
||||
require("website_sale.tour");
|
||||
var tour = require("web_tour.tour");
|
||||
var base = require("web_editor.base");
|
||||
|
||||
tour.register('shop_sale_coupon', {
|
||||
test: true,
|
||||
url: '/shop',
|
||||
wait_for: base.ready()
|
||||
},
|
||||
[
|
||||
/* 1. Buy 1 iPad Mini, enable coupon code & insert 10% code */
|
||||
{
|
||||
content: "type iPad Mini in search",
|
||||
trigger: 'form input[name="search"]',
|
||||
run: "text iPad Mini",
|
||||
},
|
||||
{
|
||||
content: "start search",
|
||||
trigger: 'form:has(input[name="search"]) .oe_search_button',
|
||||
},
|
||||
{
|
||||
content: "select iPad Mini",
|
||||
extra_trigger: '.oe_website_sale_search', // 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:contains("iPad Mini")',
|
||||
},
|
||||
{
|
||||
content: "add 3 iPad Mini into cart",
|
||||
trigger: '#product_details input[name="add_qty"]',
|
||||
run: "text 3",
|
||||
},
|
||||
{
|
||||
content: "click on 'Add to Cart' button",
|
||||
trigger: "a:contains(Add to Cart)",
|
||||
},
|
||||
{
|
||||
content: "open customize menu",
|
||||
extra_trigger: '.oe_website_sale .oe_cart',
|
||||
trigger: '#customize-menu > a',
|
||||
},
|
||||
{
|
||||
content: "click on 'Promo Code'",
|
||||
trigger: "#customize-menu a:contains(Promo Code)",
|
||||
},
|
||||
{
|
||||
content: "insert promo code '10pc'",
|
||||
extra_trigger: 'form[name="coupon_code"]',
|
||||
trigger: 'form[name="coupon_code"] input[name="promo"]',
|
||||
run: "text 10pc",
|
||||
},
|
||||
{
|
||||
content: "validate the coupon",
|
||||
trigger: 'form[name="coupon_code"] .a-submit',
|
||||
},
|
||||
{
|
||||
content: "check reward product",
|
||||
trigger: '.reward_product:contains("10.0 % discount on total amount")',
|
||||
run: function () {}, // it's a check
|
||||
},
|
||||
/* 2. Add some iPad to get a free one, play with quantity */
|
||||
{
|
||||
content: "add more iPad Mini into cart",
|
||||
trigger: '#cart_products input.js_quantity',
|
||||
run: "text 4",
|
||||
},
|
||||
{
|
||||
content: "check reduction amount got recomputed",
|
||||
extra_trigger: '.oe_currency_value:contains("96.00")', // For some reason, "-96.00" won't work
|
||||
trigger: '.reward_product:contains("Free Product - iPad Mini")',
|
||||
run: function () {}, // it's a check
|
||||
},
|
||||
{
|
||||
content: "remove one iPad from cart",
|
||||
trigger: '#cart_products a.js_add_cart_json:first',
|
||||
},
|
||||
{
|
||||
content: "check free product is removed",
|
||||
trigger: '#wrap:not(:has(.reward_product:contains("Free Product - iPad Mini")))',
|
||||
run: function () {}, // it's a check
|
||||
},
|
||||
/* 3. Empty cart and disable coupon */
|
||||
{
|
||||
content: "remove iPad Mini from cart",
|
||||
trigger: '#cart_products input.js_quantity:first',
|
||||
run: "text 0",
|
||||
},
|
||||
{
|
||||
content: "check cart is empty",
|
||||
trigger: '#wrap:not(:has(#cart_products))',
|
||||
run: function () {}, // it's a check
|
||||
},
|
||||
/* 4. Disabled coupon box */
|
||||
{
|
||||
content: "open customize menu",
|
||||
extra_trigger: '.oe_website_sale .oe_cart',
|
||||
trigger: '#customize-menu > a',
|
||||
},
|
||||
{
|
||||
content: "click on 'Promo Code'",
|
||||
trigger: "#customize-menu a:contains(Promo Code)",
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
//Check if website_sale_options is installed since its adding an extra step to add to cart
|
||||
if ('website_sale_options.website_sale' in odoo.__DEBUG__.services) {
|
||||
var steps = tour.tours.shop_sale_coupon.steps;
|
||||
for (var k=0; k<steps.length; k++) {
|
||||
if (steps[k].content === "click on 'Add to Cart' button") {
|
||||
steps.splice(k+1, 0, {
|
||||
content: "click in modal on 'Proceed to Checkout' button",
|
||||
trigger: 'a:contains("Proceed to Checkout")',
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
from . import test_shop_sale_coupon
|
||||
@@ -0,0 +1,11 @@
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
import odoo.tests
|
||||
|
||||
class TestUi(odoo.tests.HttpCase):
|
||||
|
||||
post_install = True
|
||||
at_install = False
|
||||
|
||||
def test_01_admin_shop_sale_coupon_tour(self):
|
||||
self.phantom_js("/", "odoo.__DEBUG__.services['web_tour.tour'].run('shop_sale_coupon')", "odoo.__DEBUG__.services['web_tour.tour'].tours.shop_sale_coupon.ready", login="admin")
|
||||
@@ -1,10 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<template id="assets_frontend" inherit_id="website.assets_frontend" name="Shop Sale Coupon">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/website_sale_coupon/static/src/js/website_sale_coupon.test.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
<template id="website_sale_coupon_cart_hide_qty" inherit_id="website_sale.cart_lines" active="True">
|
||||
<xpath expr="//td[hasclass('td-qty')]/div" position="attributes">
|
||||
<attribute name="t-att-style">line.is_reward_line and "display:none;"</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//table[@id='cart_products']/tbody//tr//td[hasclass('td-product_name')]//div" position="attributes">
|
||||
<!-- Can't xpath "//table[@id='cart_products']/tbody//tr" since optional_product already xpath that one.
|
||||
There will be the same xpath attribute class on the same element. Last installed module will only be taken into account -->
|
||||
<attribute name="t-att-class">'reward_product' if line.is_reward_line else None</attribute>
|
||||
</xpath>
|
||||
<xpath expr="//td[hasclass('td-qty')]/div" position="after">
|
||||
<t t-if="line.is_reward_line">
|
||||
<span class="js_quantity text-muted" t-esc="int(line.product_uom_qty)"/>
|
||||
|
||||
Reference in New Issue
Block a user