| 1 |
import { rpc } from "@web/core/network/rpc"; |
| 2 |
import { registry } from "@web/core/registry"; |
| 3 |
import * as tourUtils from '@website_sale/js/tours/tour_utils'; |
| 4 |
|
| 5 |
registry.category("web_tour.tours").add('shop_sale_loyalty', { |
| 6 |
url: '/shop?search=Small%20Cabinet', |
| 7 |
steps: () => [ |
| 8 |
|
| 9 |
{ |
| 10 |
trigger: ".oe_search_found:not(:visible)", |
| 11 |
}, |
| 12 |
{ |
| 13 |
content: "select Small Cabinet", |
| 14 |
trigger: '.oe_product_cart a:contains("Small Cabinet")', |
| 15 |
run: "click", |
| 16 |
expectUnloadPage: true, |
| 17 |
}, |
| 18 |
{ |
| 19 |
content: "add 2 Small Cabinet into cart", |
| 20 |
trigger: '#product_details input[name="add_qty"]', |
| 21 |
run: "edit 2", |
| 22 |
}, |
| 23 |
{ |
| 24 |
content: "click on 'Add to Cart' button", |
| 25 |
trigger: "a:contains(Add to cart)", |
| 26 |
run: "click", |
| 27 |
}, |
| 28 |
tourUtils.goToCart({quantity: 2}), |
| 29 |
{ |
| 30 |
trigger: 'form[name="coupon_code"]', |
| 31 |
}, |
| 32 |
{ |
| 33 |
content: "insert promo code 'testcode'", |
| 34 |
trigger: 'form[name="coupon_code"] input[name="promo"]', |
| 35 |
run: "edit testcode", |
| 36 |
}, |
| 37 |
{ |
| 38 |
content: "validate the coupon", |
| 39 |
trigger: 'form[name="coupon_code"] button[type="submit"]', |
| 40 |
run: "click", |
| 41 |
expectUnloadPage: true, |
| 42 |
}, |
| 43 |
{ |
| 44 |
content: "check reward product", |
| 45 |
trigger: 'div>h6:contains("10.0% discount on total amount")', |
| 46 |
}, |
| 47 |
{ |
| 48 |
content: "check loyalty points", |
| 49 |
trigger: '.oe_website_sale_gift_card strong[name="o_loyalty_points"]:contains("372.03")', |
| 50 |
}, |
| 51 |
|
| 52 |
{ |
| 53 |
content: "go to shop", |
| 54 |
trigger: 'div>h6:contains("10.0% discount on total amount")', |
| 55 |
run: function () { |
| 56 |
rpc('/web/dataset/call_kw/account.tax/create', { |
| 57 |
model: 'account.tax', |
| 58 |
method: 'create', |
| 59 |
args: [{ |
| 60 |
'name':'15% tax incl ' + new Date().getTime(), |
| 61 |
'amount': 15, |
| 62 |
}], |
| 63 |
kwargs: {}, |
| 64 |
}).then(function (tax_id) { |
| 65 |
rpc('/web/dataset/call_kw/product.template/create', { |
| 66 |
model: 'product.template', |
| 67 |
method: 'create', |
| 68 |
args: [{ |
| 69 |
'name': 'Taxed Product', |
| 70 |
'taxes_id': [([6, false, [tax_id]])], |
| 71 |
'list_price': 100, |
| 72 |
'website_published': true, |
| 73 |
}], |
| 74 |
kwargs: {}, |
| 75 |
}).then(function (data) { |
| 76 |
location.href = '/shop'; |
| 77 |
}); |
| 78 |
}); |
| 79 |
}, |
| 80 |
expectUnloadPage: true, |
| 81 |
}, |
| 82 |
...tourUtils.addToCart({ productName: "Taxed Product", expectUnloadPage: true }), |
| 83 |
tourUtils.goToCart({quantity: 3}), |
| 84 |
{ |
| 85 |
trigger: ".oe_currency_value:contains(/74.00/):not(div[name='o_cart_total'])", |
| 86 |
}, |
| 87 |
{ |
| 88 |
content: "check reduction amount got recomputed and merged both discount lines into one only", |
| 89 |
trigger: '.oe_website_sale .oe_cart', |
| 90 |
}, |
| 91 |
|
| 92 |
{ |
| 93 |
content: "add one Small Cabinet", |
| 94 |
trigger: '#cart_products input.js_quantity', |
| 95 |
run: "edit 3 && click body", |
| 96 |
}, |
| 97 |
{ |
| 98 |
content: "check reduction amount got recomputed when changing qty", |
| 99 |
trigger: '.oe_currency_value:contains("- 106.00")', |
| 100 |
}, |
| 101 |
{ |
| 102 |
content: "add more Small Cabinet into cart", |
| 103 |
trigger: '#cart_products input.js_quantity', |
| 104 |
run: "edit 4 && click body", |
| 105 |
}, |
| 106 |
{ |
| 107 |
content: "check free product is added", |
| 108 |
trigger: '#wrap:has(div h6:contains("Free Product - Small Cabinet"))', |
| 109 |
}, |
| 110 |
{ |
| 111 |
content: "remove one cabinet from cart", |
| 112 |
trigger: '#cart_products input.js_quantity[value="4"]', |
| 113 |
run: "edit 3 && click body", |
| 114 |
}, |
| 115 |
{ |
| 116 |
content: "check free product is removed", |
| 117 |
trigger: '#wrap:not(:has(div h6:contains("Free Product - Small Cabinet")))', |
| 118 |
}, |
| 119 |
|
| 120 |
{ |
| 121 |
content: "go to checkout", |
| 122 |
trigger: 'a[href="/shop/checkout?try_skip_step=true"]', |
| 123 |
run: "click", |
| 124 |
expectUnloadPage: true, |
| 125 |
}, |
| 126 |
...tourUtils.assertCartAmounts({ |
| 127 |
total: '967.50', |
| 128 |
}), |
| 129 |
] |
| 130 |
}); |