[IMP] website_sale_options: convert tours to use web_tour.tour

This commit is contained in:
Christophe Matthieu
2016-08-30 13:54:28 +02:00
committed by qsm-odoo
parent dff1b6cc03
commit c41e85ae12
2 changed files with 57 additions and 59 deletions
@@ -1,101 +1,98 @@
odoo.define('website_sale.test', function (require) {
'use strict';
var core = require('web.core');
var Tour = require('web.Tour');
require("website_sale.tour");
var tour = require("web_tour.tour");
var _t = core._t;
var steps = Tour.tours.shop_buy_product.steps;
var steps = tour.tours.shop_buy_product.steps;
for (var k=0; k<steps.length; k++) {
if (steps[k].title === "click on add to cart") {
if (steps[k].content === "click on add to cart") {
steps.splice(k+1, 0, {
title: _t("click in modal on 'Proceed to checkout' button"),
element: '.modal a:contains("Proceed to checkout")',
content: "click in modal on 'Proceed to checkout' button",
trigger: 'a:contains("Proceed to checkout")',
});
break;
}
}
Tour.register({
id: 'shop_customize',
name: "Customize the page and search a product",
path: '/shop',
mode: 'test',
steps: [
tour.register('shop_customize', { test: true, url: '/shop' },
[
{
title: "open customize menu",
element: '#customize-menu-button',
wait: 250
content: "open customize menu",
trigger: '#customize-menu-button',
},
{
title: "click on 'Product Attribute's Filters'",
element: "#customize-menu a:contains(Product Attribute's Filters)",
content: "click on 'Product Attribute's Filters'",
trigger: "#customize-menu a:contains(Product Attribute's Filters)",
},
{
title: "select product attribute memory 16 GB",
waitNot: '#customize-menu:visible .dropdown-menu:visible',
element: 'form.js_attributes label:contains(16 GB) input:not(:checked)',
content: "select product attribute memory 16 GB",
extra_trigger: 'body:not(:has(#customize-menu:visible .dropdown-menu:visible))',
trigger: 'form.js_attributes label:contains(16 GB) input:not(:checked)',
},
{
title: "check the selection",
waitFor: 'form.js_attributes label:contains(16 GB) input:checked',
content: "check the selection",
trigger: 'form.js_attributes label:contains(16 GB) input:checked',
run: function () {}, // it's a check
},
{
title: "select iPad",
waitNot: '.oe_website_sale .oe_product_cart:eq(2)',
element: '.oe_product_cart a:contains("iPad")',
content: "select iPad",
extra_trigger: 'body:not(:has(.oe_website_sale .oe_product_cart:eq(2)))',
trigger: '.oe_product_cart a:contains("iPad")',
},
{
title: "click on 'Add to Cart' button",
element: "a:contains(Add to Cart)",
content: "click on 'Add to Cart' button",
trigger: "a:contains(Add to Cart)",
},
{
title: "add an optional Warranty",
element: ".js_product:contains(Warranty) a:contains(Add to Cart)",
content: "add an optional Warranty",
trigger: ".js_product:contains(Warranty) a:contains(Add to Cart)",
},
{
title: "click in modal on 'Proceed to checkout' button",
waitFor: '.js_product:contains(Warranty) a:contains(Add to Cart):hidden',
element: '.modal-dialog a:contains("Proceed to checkout")',
content: "click in modal on 'Proceed to checkout' button",
extra_trigger: 'body:has(.js_product:contains(Warranty) a:contains(Add to Cart):hidden)',
trigger: '.modal-dialog a:contains("Proceed to checkout")',
},
{
title: "check quantity",
waitFor: '.my_cart_quantity:containsExact(2)',
content: "check quantity",
trigger: '.my_cart_quantity:containsExact(2)',
run: function () {}, // it's a check
},
{
title: "check optional product",
waitFor: '.optional_product',
content: "check optional product",
trigger: '.optional_product',
run: function () {}, // it's a check
},
{
title: "remove iPad from cart",
element: '#cart_products a.js_add_cart_json:first',
content: "remove iPad from cart",
trigger: '#cart_products a.js_add_cart_json:first',
},
{
title: "check optional product is removed",
waitNot: '.optional_product',
content: "check optional product is removed",
trigger: '#wrap:not(:has(.optional_product))',
run: function () {}, // it's a check
},
{
title: "click on shop",
element: "a:contains(Continue Shopping)",
waitNot: '#products_grid_before .js_attributes',
content: "click on shop",
trigger: "a:contains(Continue Shopping)",
extra_trigger: 'body:not(:has(#products_grid_before .js_attributes))',
},
{
title: "open customize menu bis",
waitFor: '#products_grid_before .js_attributes',
element: '#customize-menu-button',
wait: 250
content: "open customize menu bis",
extra_trigger: '#products_grid_before .js_attributes',
trigger: '#customize-menu-button',
},
{
title: "remove 'Product Attribute's Filters'",
element: "#customize-menu a:contains(Product Attribute's Filters):has(input:checked)",
content: "remove 'Product Attribute's Filters'",
trigger: "#customize-menu a:contains(Product Attribute's Filters):has(input:checked)",
},
{
title: "finish",
waitNot: '#products_grid_before .js_attributes',
waitFor: 'li:has(.my_cart_quantity):hidden',
content: "finish",
extra_trigger: 'body:not(:has(#products_grid_before .js_attributes))',
trigger: '#wrap:not(:has(li:has(.my_cart_quantity):visible))',
run: function () {}, // it's a check
},
]
});
);
});
@@ -2,9 +2,10 @@
import odoo.tests
@odoo.tests.common.at_install(False)
@odoo.tests.common.post_install(True)
class TestUi(odoo.tests.HttpCase):
post_install = True
at_install = False
def test_01_admin_shop_customize_tour(self):
self.phantom_js("/", "odoo.__DEBUG__.services['web.Tour'].run('shop_customize', 'test')", "odoo.__DEBUG__.services['web.Tour'].tours.shop_customize", login="admin")
self.phantom_js("/", "odoo.__DEBUG__.services['web_tour.tour'].run('shop_customize')", "odoo.__DEBUG__.services['web_tour.tour'].tours.shop_customize.ready", login="admin")