Skip to content
Snippets Groups Projects
website.tour.sale.js 3.67 KiB
(function () {
    'use strict';

    var website = openerp.website;

    website.Tour.register({
        id:   'shop_buy_product',
        name: "Try to buy products",
        path: '/shop',
        mode: 'test',
        steps: [
            {
                title:     "select ipod",
                element:   '.oe_product_cart a:contains("iPod")',
            },
            {
                title:     "select ipod 32Go",
                element:   'input[name="product_id"]:not([checked])',
            },
            {
                title:     "click on add to cart",
                waitFor:   'input[name="product_id"]:eq(1)[checked]',
                element:   'form[action="/shop/cart/update"] .btn',
            },
            {
                title:     "add suggested",
                waitNot:   '#cart_products:contains("[A8767] Apple In-Ear Headphones")',
                element:   'form[action="/shop/cart/update"] .btn-link:contains("Add to Cart")',
            },
            {
                title:     "add one more iPod",
                waitFor:   '.my_cart_quantity:contains(2)',
                element:   '#cart_products tr:contains("iPod - 32 Gb") a.js_add_cart_json:eq(1)',
            },
            {
                title:     "remove Headphones",
                waitFor:   '#cart_products tr:contains("iPod - 32 Gb") input.js_quantity[value=2]',
                element:   '#cart_products tr:contains("Apple In-Ear Headphones") a.js_add_cart_json:first',
            },
            {
                title:     "set one iPod",
                waitNot:   '#cart_products tr:contains("Apple In-Ear Headphones")',
                element:   '#cart_products input.js_quantity',
                sampleText: '1',
            },
            {
                title:     "go to checkout",
                waitFor:   '#cart_products input.js_quantity[value=1]',
                element:   'a[href="/shop/checkout"]',
            },
            {
                title:     "test with input error",
                element:   'form[action="/shop/confirm_order"] .btn:contains("Confirm")',
                onload: function (tour) {
                    $("input[name='phone']").val("");
                },
            },
            {
                title:     "test without input error",
                waitFor:   'form[action="/shop/confirm_order"] .has-error',
                element:   'form[action="/shop/confirm_order"] .btn:contains("Confirm")',
                onload: function (tour) {
                    if ($("input[name='name']").val() === "")
                        $("input[name='name']").val("website_sale-test-shoptest");
                    if ($("input[name='email']").val() === "")
                        $("input[name='email']").val("website_sale_test_shoptest@websitesaletest.optenerp.com");
                    $("input[name='phone']").val("123");
                    $("input[name='street']").val("123");
                    $("input[name='city']").val("123");
                    $("input[name='zip']").val("123");
                    $("select[name='country_id']").val("21");
                },
            },
            {
                title:     "select payment",
                element:   '#payment_method label:has(img[title="Wire Transfer"]) input',
            },
            {
                title:     "Pay Now",
                waitFor:   '#payment_method label:has(input:checked):has(img[title="Wire Transfer"])',
                element:   '.oe_sale_acquirer_button .btn[type="submit"]:visible',
            },
            {
                title:     "finish",
                waitFor:   '.oe_website_sale:contains("Thank you for your order")',
            }
        ]
    });

}());