[ADD] website: test login, backend, go back, branding, edit, logout
authorChristophe Matthieu <chm@openerp.com>
Fri, 7 Feb 2014 12:52:31 +0000 (13:52 +0100)
committerChristophe Matthieu <chm@openerp.com>
Fri, 7 Feb 2014 12:52:31 +0000 (13:52 +0100)
bzr revid: chm@openerp.com-20140207125231-3zd0i1axdwuht5g4

addons/website/static/src/js/website.tour.test.admin.js [new file with mode: 0644]
addons/website/tests/test_ui.py
addons/website/tests/ui_suite/login_test.js [new file with mode: 0644]
addons/website/tests/ui_suite/ui_test_runner.js
addons/website/views/website_templates.xml
addons/website_sale/views/website_sale.xml

diff --git a/addons/website/static/src/js/website.tour.test.admin.js b/addons/website/static/src/js/website.tour.test.admin.js
new file mode 100644 (file)
index 0000000..8107818
--- /dev/null
@@ -0,0 +1,106 @@
+(function () {
+    'use strict';
+
+    var website = openerp.website;
+
+    website.Tour.LoginEdit = website.Tour.extend({
+        id: 'login_edit',
+        name: "Try to log as admin and check editor",
+        path: '/',
+        init: function () {
+            var self = this;
+            self.steps = [
+                {
+                    title:     "click login",
+                    element:   '#top_menu a[href*="/web/login"]',
+                },
+                {
+                    title:     "insert login",
+                    element:   '.oe_login_form input[name="login"]',
+                    sampleText: typeof user !== "undefined" ? user : "admin",
+                },
+                {
+                    title:     "insert password",
+                    waitFor:   '.oe_login_form input[name="login"][value!=""]',
+                    element:   '.oe_login_form input[name="password"]',
+                    sampleText: typeof password !== "undefined" ? password : "admin",
+                },
+                {
+                    title:     "select 2 Standard tickets",
+                    waitFor:   '.oe_login_form input[name="password"][value!=""]',
+                    element:   '.oe_login_form button',
+                },
+                {
+                    title:     "go back to website from backend",
+                    element:   'a[data-action-model="ir.actions.act_url"]:contains("Website")',
+                },
+                {
+                    title:     'try to edit',
+                    waitNot:   '#wrap .carousel',
+                    element:   'button[data-action=edit]:visible',
+                },
+                {
+                    title:     'check edit mode',
+                    waitFor:   'button[data-action=save]:visible',
+                },
+                {
+                    title:     'check branding',
+                    waitFor:   '#wrap[data-oe-model="ir.ui.view"]',
+                },
+                {
+                    title:     'check rte',
+                    waitFor:   '#oe_rte_toolbar',
+                },
+                {
+                    title:     'check insert block button',
+                    element:   '[data-action="snippet"]:visible',
+                },
+                {
+                    title:     'add snippets',
+                    snippet:   'carousel',
+                },
+                {
+                    title:     'try to save',
+                    waitFor:   '.oe_overlay_options .oe_options:visible',
+                    element:   'button[data-action=save]:visible',
+                },
+                {
+                    title:     'check saved',
+                    waitFor:   '#wrap div.carousel',
+                    element:   'button[data-action=edit]:visible',
+                },
+                {
+                    title:      'try to re-edit',
+                    waitFor:    'button[data-action=save]:visible',
+                    element:    '#wrap .carousel',
+                },
+                {
+                    title:      'remove snippet',
+                    element:    '.oe_snippet_remove',
+                },
+                {
+                    title:     'try to re-save',
+                    waitNot:   '#wrap .carousel',
+                    element:   'button[data-action=save]:visible',
+                },
+                {
+                    title:     "click admin",
+                    waitFor:   'button[data-action=edit]:visible',
+                    element:   'a:contains("Administrator")',
+                },
+                {
+                    title:     "click logout",
+                    element:   '#top_menu a[href*="/logout"]',
+                },
+                {
+                    title:     "check logout",
+                    waitFor:   '#top_menu a[href*="/web/login"]',
+                },
+            ];
+            return this._super();
+        },
+    });
+    // for test without editor bar
+    website.Tour.add(website.Tour.LoginEdit);
+
+}());
index 3c30dc8..d6f9b67 100644 (file)
@@ -150,6 +150,7 @@ def full_path(pyfile, filename):
 
 def load_tests(loader, base, _):
     base.addTest(WebsiteUiSuite(full_path(__file__, 'dummy_test.js'), {}, 5.0))
+    base.addTest(WebsiteUiSuite(full_path(__file__, 'login_test.js'), {'path': '/', 'user': None}, 60.0))
     base.addTest(WebsiteUiSuite(full_path(__file__, 'simple_dom_test.js'), {'redirect': '/page/website.homepage'}, 60.0))
     base.addTest(WebsiteUiSuite(full_path(__file__, 'homepage_test.js'), {'redirect': '/page/website.homepage'}, 60.0))
     return base
diff --git a/addons/website/tests/ui_suite/login_test.js b/addons/website/tests/ui_suite/login_test.js
new file mode 100644 (file)
index 0000000..f4413d7
--- /dev/null
@@ -0,0 +1,12 @@
+var testRunner = require('./ui_test_runner.js');
+
+testRunner.run(
+        function onload (page, timeout, options) {
+            page.evaluate(function (user, password) {
+                window.password = password;
+                window.user = user;
+            }, options.user, options.password);
+        },
+        [   "./../../../website/static/src/js/website.tour.test.js",
+            "./../../../website/static/src/js/website.tour.test.admin.js"]
+    );
\ No newline at end of file
index 08fb399..745adc1 100644 (file)
@@ -72,7 +72,7 @@ function run (test, onload, inject) {
 
     page.onCallback = function(data) {
         if (data.event && data.event === 'start') {
-            test(page, timeout);
+            if (test) test(page, timeout, options);
         }
     };
     page.onLoadFinished = function(status) {
@@ -88,7 +88,7 @@ function run (test, onload, inject) {
                     }
                 }
             }
-            if (onload) onload(page, timeout);
+            if (onload) onload(page, timeout, options);
         }
     };
     
index abe1431..bf61f64 100644 (file)
 <template id="debugger" inherit_option_id="website.layout" name="Debugger &amp; Tests">
     <xpath expr='//t[@name="layout_head"]' position="after">
         <script type="text/javascript" src="/website/static/src/js/website.tour.test.js"></script>
-    </xpath>
-</template>
-
-<template id="debugger" inherit_option_id="website.layout" name="Debugger &amp; Tests">
-    <xpath expr='//t[@name="layout_head"]' position="after">
-        <script type="text/javascript" src="/website/static/src/js/website.tour.test.js"></script>
+        <script type="text/javascript" src="/website/static/src/js/website.tour.test.admin.js"></script>
     </xpath>
 </template>
 
index b609348..bd51d35 100644 (file)
@@ -6,7 +6,6 @@
 
 <template id="debugger" inherit_id="website.debugger" name="Event Debugger">
     <xpath expr="//script[last()]" position="after">
-        <script type="text/javascript" src="/website_sale/static/src/js/website.tour.sale.customize.js"></script>
         <script type="text/javascript" src="/website_sale/static/src/js/website.tour.sale.js"></script>
     </xpath>
 </template>