Merge branch 'upstream/saas-5' into saas-5
[odoo/odoo.git] / addons / website_sale / static / src / js / website.tour.sale.js
1 (function () {
2     'use strict';
3
4     var website = openerp.website;
5
6     website.Tour.register({
7         id:   'shop_customize',
8         name: "Customize the page and search a product",
9         path: '/shop',
10         mode: 'test',
11         steps: [
12             {
13                 title:     "open customize menu",
14                 element:   '#customize-menu-button',
15             },
16             {
17                 title:     "click on 'Product Attribute's Filters'",
18                 element:   "#customize-menu a:contains(Product Attribute's Filters)",
19             },
20             {
21                 title:     "select product attribute memory 16 GB",
22                 element:   'form.js_attributes label:contains(16 GB) input:not(:checked)',
23             },
24             {
25                 title:     "check the selection",
26                 waitFor:   'form.js_attributes label:contains(16 GB) input:checked',
27             },
28             {
29                 title:     "select ipod",
30                 waitNot:   '.oe_website_sale .oe_product_cart:eq(2)',
31                 element:   '.oe_product_cart a:contains("iPod")',
32             },
33             {
34                 title:     "finish",
35                 waitFor:   'form[action="/shop/cart/update"] label:contains(32 Go) input',
36             }
37         ]
38     });
39
40     website.Tour.register({
41         id:   'shop_buy_product',
42         name: "Try to buy products",
43         path: '/shop',
44         mode: 'test',
45         steps: [
46             {
47                 title:     "select ipod",
48                 element:   '.oe_product_cart a:contains("iPod")',
49             },
50             {
51                 title:     "select ipod 32GB",
52                 waitFor:   '#product_detail',
53                 element:   'label:contains(32 GB) input',
54             },
55             {
56                 title:     "click on add to cart",
57                 waitFor:   'label:contains(32 GB) input[checked]',
58                 element:   'form[action="/shop/cart/update"] .btn',
59             },
60             {
61                 title:     "add suggested",
62                 waitNot:   '#cart_products:contains("[A8767] Apple In-Ear Headphones")',
63                 element:   'form[action="/shop/cart/update"] .btn-link:contains("Add to Cart")',
64             },
65             {
66                 title:     "add one more iPod",
67                 waitFor:   '.my_cart_quantity:contains(2)',
68                 element:   '#cart_products tr:contains("32 GB") a.js_add_cart_json:eq(1)',
69             },
70             {
71                 title:     "remove Headphones",
72                 waitFor:   '#cart_products tr:contains("32 GB") input.js_quantity[value=2]',
73                 element:   '#cart_products tr:contains("Apple In-Ear Headphones") a.js_add_cart_json:first',
74             },
75             {
76                 title:     "set one iPod",
77                 waitNot:   '#cart_products tr:contains("Apple In-Ear Headphones")',
78                 element:   '#cart_products input.js_quantity',
79                 sampleText: '1',
80             },
81             {
82                 title:     "go to checkout",
83                 waitFor:   '#cart_products input.js_quantity[value=1]',
84                 element:   'a[href="/shop/checkout"]',
85             },
86             {
87                 title:     "test with input error",
88                 element:   'form[action="/shop/confirm_order"] .btn:contains("Confirm")',
89                 onload: function (tour) {
90                     $("input[name='phone']").val("");
91                 },
92             },
93             {
94                 title:     "test without input error",
95                 waitFor:   'form[action="/shop/confirm_order"] .has-error',
96                 element:   'form[action="/shop/confirm_order"] .btn:contains("Confirm")',
97                 onload: function (tour) {
98                     if ($("input[name='name']").val() === "")
99                         $("input[name='name']").val("website_sale-test-shoptest");
100                     if ($("input[name='email']").val() === "")
101                         $("input[name='email']").val("website_sale_test_shoptest@websitesaletest.optenerp.com");
102                     $("input[name='phone']").val("123");
103                     $("input[name='street']").val("123");
104                     $("input[name='city']").val("123");
105                     $("input[name='zip']").val("123");
106                     $("select[name='country_id']").val("21");
107                 },
108             },
109             {
110                 title:     "select payment",
111                 element:   '#payment_method label:has(img[title="Wire Transfer"]) input',
112             },
113             {
114                 title:     "Pay Now",
115                 waitFor:   '#payment_method label:has(input:checked):has(img[title="Wire Transfer"])',
116                 element:   '.oe_sale_acquirer_button .btn[type="submit"]:visible',
117             },
118             {
119                 title:     "finish",
120                 waitFor:   '.oe_website_sale:contains("Thank you for your order")',
121             }
122         ]
123     });
124
125 }());