9b833a73256ba48c10cd4885914075a1fda147c4
[odoo/odoo.git] / addons / website_sale / static / src / js / website_sale_tour_buy.js
1 (function () {
2     'use strict';
3
4     openerp.Tour.register({
5         id:   'shop_buy_product',
6         name: "Try to buy products",
7         path: '/shop',
8         mode: 'test',
9         steps: [
10             {
11                 title:  "search ipod",
12                 element: 'form:has(input[name="search"]) a.a-submit',
13                 onload: function() {
14                     $('input[name="search"]').val("ipod");
15                 }
16             },
17             {
18                 title:     "select ipod",
19                 element:   '.oe_product_cart a:contains("iPod")',
20             },
21             {
22                 title:     "select ipod 32GB",
23                 waitFor:   '#product_detail',
24                 element:   'label:contains(32 GB) input',
25             },
26             {
27                 title:     "click on add to cart",
28                 waitFor:   'label:contains(32 GB) input[checked]',
29                 element:   'form[action^="/shop/cart/update"] .btn',
30             },
31             {
32                 title:     "add suggested",
33                 waitNot:   '#cart_products:contains("[A8767] Apple In-Ear Headphones")',
34                 element:   '.oe_cart a:contains("Add to Cart")',
35             },
36             {
37                 title:     "add one more iPod",
38                 waitFor:   '.my_cart_quantity:contains(2)',
39                 element:   '#cart_products tr:contains("32 GB") a.js_add_cart_json:eq(1)',
40             },
41             {
42                 title:     "remove Headphones",
43                 waitFor:   '#cart_products tr:contains("32 GB") input.js_quantity[value=2]',
44                 element:   '#cart_products tr:contains("Apple In-Ear Headphones") a.js_add_cart_json:first',
45             },
46             {
47                 title:     "set one iPod",
48                 waitNot:   '#cart_products tr:contains("Apple In-Ear Headphones")',
49                 element:   '#cart_products input.js_quantity',
50                 sampleText: '1',
51             },
52             {
53                 title:     "go to checkout",
54                 waitFor:   '#cart_products input.js_quantity[value=1]',
55                 element:   'a[href="/shop/checkout"]',
56             },
57             {
58                 title:     "test with input error",
59                 element:   'form[action="/shop/confirm_order"] .btn:contains("Confirm")',
60                 onload: function (tour) {
61                     $("input[name='phone']").val("");
62                 },
63             },
64             {
65                 title:     "test without input error",
66                 waitFor:   'form[action="/shop/confirm_order"] .has-error',
67                 element:   'form[action="/shop/confirm_order"] .btn:contains("Confirm")',
68                 onload: function (tour) {
69                     if ($("input[name='name']").val() === "")
70                         $("input[name='name']").val("website_sale-test-shoptest");
71                     if ($("input[name='email']").val() === "")
72                         $("input[name='email']").val("website_sale_test_shoptest@websitesaletest.optenerp.com");
73                     $("input[name='phone']").val("123");
74                     $("input[name='street']").val("123");
75                     $("input[name='city']").val("123");
76                     $("input[name='zip']").val("123");
77                     $("select[name='country_id']").val("21");
78                 },
79             },
80             {
81                 title:     "select payment",
82                 element:   '#payment_method label:has(img[title="Wire Transfer"]) input',
83             },
84             {
85                 title:     "Pay Now",
86                 waitFor:   '#payment_method label:has(input:checked):has(img[title="Wire Transfer"])',
87                 element:   '.oe_sale_acquirer_button .btn[type="submit"]:visible',
88             },
89             {
90                 title:     "finish",
91                 waitFor:   '.oe_website_sale:contains("Thank you for your order")',
92             }
93         ]
94     });
95
96 }());