[FIX] phantomjs test remove injection
authorAntony Lesuisse <al@openerp.com>
Sat, 28 Jun 2014 17:59:59 +0000 (19:59 +0200)
committerAntony Lesuisse <al@openerp.com>
Sat, 28 Jun 2014 17:59:59 +0000 (19:59 +0200)
It's now deprecated, assets bundles should be used instead.

addons/website_event_sale/tests/test_ui.py
addons/website_sale/static/src/js/website.tour.sale.js [deleted file]
addons/website_sale/static/src/js/website.tour.shop.js [deleted file]
addons/website_sale/static/src/js/website_sale_tour_buy.js [new file with mode: 0644]
addons/website_sale/static/src/js/website_sale_tour_shop.js [new file with mode: 0644]
addons/website_sale/tests/test_sale_process.py
addons/website_sale/views/templates.xml
addons/website_sale_options/tests/customize_test.py

index 28195e6..94395bb 100644 (file)
@@ -2,19 +2,15 @@ import os
 
 import openerp.tests
 
-inject = [
-    ("openerp.Tour", os.path.join(os.path.dirname(__file__), '../../web/static/src/js/tour.js')),
-]
-
 @openerp.tests.common.at_install(False)
 @openerp.tests.common.post_install(True)
 class TestUi(openerp.tests.HttpCase):
     def test_admin(self):
-        self.phantom_js("/", "openerp.Tour.run('event_buy_tickets', 'test')", "openerp.Tour.tours.event_buy_tickets", inject=inject)
+        self.phantom_js("/", "openerp.Tour.run('event_buy_tickets', 'test')", "openerp.Tour.tours.event_buy_tickets")
 
     def test_demo(self):
-        self.phantom_js("/", "openerp.Tour.run('event_buy_tickets', 'test')", "openerp.Tour.tours.event_buy_tickets", login="demo", password="demo", inject=inject);
+        self.phantom_js("/", "openerp.Tour.run('event_buy_tickets', 'test')", "openerp.Tour.tours.event_buy_tickets", login="demo", password="demo");
 
     def test_public(self):
-        self.phantom_js("/", "openerp.Tour.run('event_buy_tickets', 'test')", "openerp.Tour.tours.event_buy_tickets", login=None, inject=inject);
+        self.phantom_js("/", "openerp.Tour.run('event_buy_tickets', 'test')", "openerp.Tour.tours.event_buy_tickets", login=None);
 
diff --git a/addons/website_sale/static/src/js/website.tour.sale.js b/addons/website_sale/static/src/js/website.tour.sale.js
deleted file mode 100644 (file)
index a2278a2..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-(function () {
-    'use strict';
-
-    openerp.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 32GB",
-                waitFor:   '#product_detail',
-                element:   'label:contains(32 GB) input',
-            },
-            {
-                title:     "click on add to cart",
-                waitFor:   'label:contains(32 GB) input[checked]',
-                element:   'form[action="/shop/cart/update"] .btn',
-            },
-            {
-                title:     "add suggested",
-                waitNot:   '#cart_products:contains("[A8767] Apple In-Ear Headphones")',
-                element:   '.oe_cart a:contains("Add to Cart")',
-            },
-            {
-                title:     "add one more iPod",
-                waitFor:   '.my_cart_quantity:contains(2)',
-                element:   '#cart_products tr:contains("32 GB") a.js_add_cart_json:eq(1)',
-            },
-            {
-                title:     "remove Headphones",
-                waitFor:   '#cart_products tr:contains("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")',
-            }
-        ]
-    });
-
-}());
diff --git a/addons/website_sale/static/src/js/website.tour.shop.js b/addons/website_sale/static/src/js/website.tour.shop.js
deleted file mode 100644 (file)
index 9b3e5d2..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-(function () {
-    'use strict';
-
-    var _t = openerp._t;
-
-    openerp.Tour.register({
-        id: 'shop',
-        name: _t("Create a product"),
-        steps: [
-            {
-                title:     _t("Welcome to your shop"),
-                content:   _t("You successfully installed the e-commerce. This guide will help you to create your product and promote your sales."),
-                popover:   { next: _t("Start Tutorial"), end: _t("Skip It") },
-            },
-            {
-                element:   '#content-menu-button',
-                placement: 'left',
-                title:     _t("Create your first product"),
-                content:   _t("Click here to add a new product."),
-                popover:   { fixed: true },
-            },
-            {
-                element:   'a[data-action=new_product]',
-                placement: 'left',
-                title:     _t("Create a new product"),
-                content:   _t("Select 'New Product' to create it and manage its properties to boost your sales."),
-                popover:   { fixed: true },
-            },
-            {
-                element:   '.modal #editor_new_product input[type=text]',
-                sampleText: 'New Product',
-                placement: 'right',
-                title:     _t("Choose name"),
-                content:   _t("Enter a name for your new product then click 'Continue'."),
-            },
-            {
-                waitNot:   '.modal input[type=text]:not([value!=""])',
-                element:   '.modal button.btn-primary',
-                placement: 'right',
-                title:     _t("Create Product"),
-                content:   _t("Click <em>Continue</em> to create the product."),
-            },
-            {
-                waitFor:   'body:has(button[data-action=save]:visible):has(.js_sale)',
-                title:     _t("New product created"),
-                content:   _t("This page contains all the information related to the new product."),
-                popover:   { next: _t("Continue") },
-            },
-            {
-                element:   '.product_price .oe_currency_value:visible',
-                sampleText: '20.50',
-                placement: 'left',
-                title:     _t("Change the price"),
-                content:   _t("Edit the price of this product by clicking on the amount."),
-            },
-            {
-                waitNot:   '.product_price .oe_currency_value:visible:containsExact(1.00)',
-                element:   '#wrap img.product_detail_img',
-                placement: 'top',
-                title:     _t("Update image"),
-                content:   _t("Click here to set an image describing your product."),
-            },
-            {
-                element:   'img[alt=ipad]',
-                placement: 'top',
-                title:     _t("Select an Image"),
-                content:   _t("Let's select an ipad image."),
-            },
-            {
-                waitFor:   '.media_selected img[alt=ipad]',
-                element:   '.modal-content button.save',
-                placement: 'top',
-                title:     _t("Save this Image"),
-                content:   _t("Click on save to add the image to the product decsription."),
-            },
-            {
-                waitNot:   '.modal-content:visible',
-                element:   'button[data-action=snippet]',
-                placement: 'bottom',
-                title:     _t("Describe the Product"),
-                content:   _t("Insert blocks like text-image, or gallery to fully describe the product."),
-                popover:   { fixed: true },
-            },
-            {
-                snippet:   '#snippet_structure .oe_snippet:eq(7)',
-                placement: 'bottom',
-                title:     _t("Drag & Drop a block"),
-                content:   _t("Drag the 'Big Picture' block and drop it in your page."),
-                popover:   { fixed: true },
-            },
-            {
-                element:   'button[data-action=save]',
-                placement: 'right',
-                title:     _t("Save your modifications"),
-                content:   _t("Once you click on save, your product is updated."),
-                popover:   { fixed: true },
-            },
-            {
-                waitFor:   '#website-top-navbar:hidden',
-                element:   '.js_publish_management button.js_publish_btn.btn-danger',
-                placement: 'top',
-                title:     _t("Publish your product"),
-                content:   _t("Click to publish your product so your customers can see it."),
-            },
-            {
-                waitFor:   '.js_publish_management button.js_publish_btn.btn-success:visible',
-                title:     _t("Congratulations"),
-                content:   _t("Congratulations! You just created and published your first product."),
-                popover:   { next: _t("Close Tutorial") },
-            },
-        ]
-    });
-
-}());
diff --git a/addons/website_sale/static/src/js/website_sale_tour_buy.js b/addons/website_sale/static/src/js/website_sale_tour_buy.js
new file mode 100644 (file)
index 0000000..a2278a2
--- /dev/null
@@ -0,0 +1,89 @@
+(function () {
+    'use strict';
+
+    openerp.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 32GB",
+                waitFor:   '#product_detail',
+                element:   'label:contains(32 GB) input',
+            },
+            {
+                title:     "click on add to cart",
+                waitFor:   'label:contains(32 GB) input[checked]',
+                element:   'form[action="/shop/cart/update"] .btn',
+            },
+            {
+                title:     "add suggested",
+                waitNot:   '#cart_products:contains("[A8767] Apple In-Ear Headphones")',
+                element:   '.oe_cart a:contains("Add to Cart")',
+            },
+            {
+                title:     "add one more iPod",
+                waitFor:   '.my_cart_quantity:contains(2)',
+                element:   '#cart_products tr:contains("32 GB") a.js_add_cart_json:eq(1)',
+            },
+            {
+                title:     "remove Headphones",
+                waitFor:   '#cart_products tr:contains("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")',
+            }
+        ]
+    });
+
+}());
diff --git a/addons/website_sale/static/src/js/website_sale_tour_shop.js b/addons/website_sale/static/src/js/website_sale_tour_shop.js
new file mode 100644 (file)
index 0000000..9b3e5d2
--- /dev/null
@@ -0,0 +1,114 @@
+(function () {
+    'use strict';
+
+    var _t = openerp._t;
+
+    openerp.Tour.register({
+        id: 'shop',
+        name: _t("Create a product"),
+        steps: [
+            {
+                title:     _t("Welcome to your shop"),
+                content:   _t("You successfully installed the e-commerce. This guide will help you to create your product and promote your sales."),
+                popover:   { next: _t("Start Tutorial"), end: _t("Skip It") },
+            },
+            {
+                element:   '#content-menu-button',
+                placement: 'left',
+                title:     _t("Create your first product"),
+                content:   _t("Click here to add a new product."),
+                popover:   { fixed: true },
+            },
+            {
+                element:   'a[data-action=new_product]',
+                placement: 'left',
+                title:     _t("Create a new product"),
+                content:   _t("Select 'New Product' to create it and manage its properties to boost your sales."),
+                popover:   { fixed: true },
+            },
+            {
+                element:   '.modal #editor_new_product input[type=text]',
+                sampleText: 'New Product',
+                placement: 'right',
+                title:     _t("Choose name"),
+                content:   _t("Enter a name for your new product then click 'Continue'."),
+            },
+            {
+                waitNot:   '.modal input[type=text]:not([value!=""])',
+                element:   '.modal button.btn-primary',
+                placement: 'right',
+                title:     _t("Create Product"),
+                content:   _t("Click <em>Continue</em> to create the product."),
+            },
+            {
+                waitFor:   'body:has(button[data-action=save]:visible):has(.js_sale)',
+                title:     _t("New product created"),
+                content:   _t("This page contains all the information related to the new product."),
+                popover:   { next: _t("Continue") },
+            },
+            {
+                element:   '.product_price .oe_currency_value:visible',
+                sampleText: '20.50',
+                placement: 'left',
+                title:     _t("Change the price"),
+                content:   _t("Edit the price of this product by clicking on the amount."),
+            },
+            {
+                waitNot:   '.product_price .oe_currency_value:visible:containsExact(1.00)',
+                element:   '#wrap img.product_detail_img',
+                placement: 'top',
+                title:     _t("Update image"),
+                content:   _t("Click here to set an image describing your product."),
+            },
+            {
+                element:   'img[alt=ipad]',
+                placement: 'top',
+                title:     _t("Select an Image"),
+                content:   _t("Let's select an ipad image."),
+            },
+            {
+                waitFor:   '.media_selected img[alt=ipad]',
+                element:   '.modal-content button.save',
+                placement: 'top',
+                title:     _t("Save this Image"),
+                content:   _t("Click on save to add the image to the product decsription."),
+            },
+            {
+                waitNot:   '.modal-content:visible',
+                element:   'button[data-action=snippet]',
+                placement: 'bottom',
+                title:     _t("Describe the Product"),
+                content:   _t("Insert blocks like text-image, or gallery to fully describe the product."),
+                popover:   { fixed: true },
+            },
+            {
+                snippet:   '#snippet_structure .oe_snippet:eq(7)',
+                placement: 'bottom',
+                title:     _t("Drag & Drop a block"),
+                content:   _t("Drag the 'Big Picture' block and drop it in your page."),
+                popover:   { fixed: true },
+            },
+            {
+                element:   'button[data-action=save]',
+                placement: 'right',
+                title:     _t("Save your modifications"),
+                content:   _t("Once you click on save, your product is updated."),
+                popover:   { fixed: true },
+            },
+            {
+                waitFor:   '#website-top-navbar:hidden',
+                element:   '.js_publish_management button.js_publish_btn.btn-danger',
+                placement: 'top',
+                title:     _t("Publish your product"),
+                content:   _t("Click to publish your product so your customers can see it."),
+            },
+            {
+                waitFor:   '.js_publish_management button.js_publish_btn.btn-success:visible',
+                title:     _t("Congratulations"),
+                content:   _t("Congratulations! You just created and published your first product."),
+                popover:   { next: _t("Close Tutorial") },
+            },
+        ]
+    });
+
+}());
index 3f79ac0..d81d4d0 100644 (file)
@@ -2,10 +2,6 @@ import os
 
 import openerp.tests
 
-inject = [
-    ("openerp.Tour", os.path.join(os.path.dirname(__file__), '../../web/static/src/js/tour.js')),
-]
-
 @openerp.tests.common.at_install(False)
 @openerp.tests.common.post_install(True)
 class TestUi(openerp.tests.HttpCase):
@@ -13,10 +9,10 @@ class TestUi(openerp.tests.HttpCase):
         self.phantom_js("/", "openerp.Tour.run('shop', 'test')", "openerp.Tour.tours.shop", login="admin")
 
     def test_02_admin_checkout(self):
-        self.phantom_js("/", "openerp.Tour.run('shop_buy_product', 'test')", "openerp.Tour.tours.shop_buy_product", login="admin", inject=inject)
+        self.phantom_js("/", "openerp.Tour.run('shop_buy_product', 'test')", "openerp.Tour.tours.shop_buy_product", login="admin")
 
     def test_03_demo_checkout(self):
-        self.phantom_js("/", "openerp.Tour.run('shop_buy_product', 'test')", "openerp.Tour.tours.shop_buy_product", login="demo", inject=inject)
+        self.phantom_js("/", "openerp.Tour.run('shop_buy_product', 'test')", "openerp.Tour.tours.shop_buy_product", login="demo")
 
     def test_04_public_checkout(self):
-        self.phantom_js("/", "openerp.Tour.run('shop_buy_product', 'test')", "openerp.Tour.tours.shop_buy_product", inject=inject)
+        self.phantom_js("/", "openerp.Tour.run('shop_buy_product', 'test')", "openerp.Tour.tours.shop_buy_product")
index 262b289..2f7a248 100644 (file)
@@ -4,21 +4,21 @@
 
 <!-- Layout and common templates -->
 
-<template id="assets_editor" inherit_id="website.assets_editor" name="Shop Editor" groups="base.group_sale_manager">
-  <xpath expr="." position="inside">
-      <script type="text/javascript" src="/website_sale/static/src/js/website_sale.editor.js"></script>
-      <script type="text/javascript" src="/website_sale/static/src/js/website.tour.shop.js"></script>
-  </xpath>
-</template>
-
 <template id="assets_frontend" inherit_id="website.assets_frontend" name="Shop">
   <xpath expr="." position="inside">
-      <script type="text/javascript" src="/website_sale/static/src/js/website.tour.sale.js"></script>
-      <script type="text/javascript" src="/website_sale/static/src/js/website_sale.js"></script>
       <link rel='stylesheet' href='/website_sale/static/src/css/website_sale.css'/>
       <link rel='stylesheet' href='/website_sale/static/src/css/website_mail.css'/>
+      <script type="text/javascript" src="/website_sale/static/src/js/website_sale.js"></script>
       <script type="text/javascript" src="/website_sale/static/src/js/website_sale_payment.js"></script>
       <script type="text/javascript" src="/website_sale/static/src/js/website_sale_validate.js"></script>
+      <script type="text/javascript" src="/website_sale/static/src/js/website_sale_tour_buy.js"></script>
+  </xpath>
+</template>
+
+<template id="assets_editor" inherit_id="website.assets_editor" name="Shop Editor" groups="base.group_sale_manager">
+  <xpath expr="." position="inside">
+      <script type="text/javascript" src="/website_sale/static/src/js/website_sale.editor.js"></script>
+      <script type="text/javascript" src="/website_sale/static/src/js/website_sale_tour_shop.js"></script>
   </xpath>
 </template>
 
@@ -33,6 +33,7 @@
       </li>
   </xpath>
 </template>
+
 <template id="search" name="Search hidden fields">
   <t t-if="attrib_values">
     <t t-foreach="attrib_values" t-as="a">
index abec0be..a91435c 100644 (file)
@@ -2,12 +2,8 @@ import os
 
 import openerp.tests
 
-inject = [
-    ("openerp.Tour", os.path.join(os.path.dirname(__file__), '../../web/static/src/js/tour.js')),
-]
-
 @openerp.tests.common.at_install(False)
 @openerp.tests.common.post_install(True)
 class TestUi(openerp.tests.HttpCase):
     def test_01_admin_shop_tour(self):
-        self.phantom_js("/", "openerp.Tour.run('shop_customize', 'test')", "openerp.Tour.tours.shop_customize", login="admin", inject=inject)
+        self.phantom_js("/", "openerp.Tour.run('shop_customize', 'test')", "openerp.Tour.tours.shop_customize", login="admin")