From 5db5f8e98119d5a8094e73099a23b12e27f07513 Mon Sep 17 00:00:00 2001 From: Romain Derie Date: Fri, 15 Dec 2017 16:05:02 +0100 Subject: [PATCH 1/3] [IMP] sale_coupon, website_sale_coupon: add tests Commit a42c27f99e0061b7c4f recently fixed some bugs on sale_coupon. This commit add some tests to be sure theses bugs are fixed and won't appear again. This closes #1744 --- static/src/js/website_sale_coupon.test.js | 120 ++++++++++++++++++++++ tests/__init__.py | 1 + tests/test_shop_sale_coupon.py | 11 ++ views/website_sale_templates.xml | 10 ++ 4 files changed, 142 insertions(+) create mode 100644 static/src/js/website_sale_coupon.test.js create mode 100644 tests/__init__.py create mode 100644 tests/test_shop_sale_coupon.py diff --git a/static/src/js/website_sale_coupon.test.js b/static/src/js/website_sale_coupon.test.js new file mode 100644 index 00000000000..1ce783c54c0 --- /dev/null +++ b/static/src/js/website_sale_coupon.test.js @@ -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 'Coupon Code'", + trigger: "#customize-menu a:contains(Coupon 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 'Coupon Code'", + trigger: "#customize-menu a:contains(Coupon 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 +