Merge lp:~openerp-dev/openerp-web/trunk-test-ui-al into lp:openerp-web

Proposed by Christophe Matthieu (OpenERP)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openerp-web/trunk-test-ui-al
Merge into: lp:openerp-web
Diff against target: 157 lines (+46/-7)
3 files modified
addons/web/static/src/js/chrome.js (+38/-5)
addons/web/static/src/xml/base.xml (+2/-2)
addons/web_tests/tests/test_ui.py (+6/-0)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/trunk-test-ui-al
Reviewer Review Type Date Requested Status
OpenERP R&D Web Team Pending
Review via email: mp+218301@code.launchpad.net
To post a comment you must log in.
4003. By Christophe Matthieu (OpenERP)

[MERGE] from trunk

Unmerged revisions

4003. By Christophe Matthieu (OpenERP)

[MERGE] from trunk

4002. By Antony Lesuisse (OpenERP)

[IMP] web_tests click_all_menu_items disable act_urls

4001. By Antony Lesuisse (OpenERP)

[MERGE] trunk

4000. By Antony Lesuisse (OpenERP)

[IMP] web_tests test ui click all menu items

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/web/static/src/js/chrome.js'
--- addons/web/static/src/js/chrome.js 2014-04-23 12:37:35 +0000
+++ addons/web/static/src/js/chrome.js 2014-05-06 09:32:41 +0000
@@ -269,6 +269,12 @@
269 buttons[_t("Ok")] = function() {269 buttons[_t("Ok")] = function() {
270 this.parents('.modal').modal('hide');270 this.parents('.modal').modal('hide');
271 };271 };
272 if (typeof window.callPhantom === 'function') {
273 console.log(error.type + " " + error.message);
274 console.log(error.data.debug);
275 console.log(window.location);
276 console.log("error");
277 }
272 new instance.web.Dialog(this, {278 new instance.web.Dialog(this, {
273 title: "OpenERP " + _.str.capitalize(error.type),279 title: "OpenERP " + _.str.capitalize(error.type),
274 buttons: buttons280 buttons: buttons
@@ -605,7 +611,6 @@
605};611};
606instance.web.client_actions.add("logout", "instance.web.logout");612instance.web.client_actions.add("logout", "instance.web.logout");
607613
608
609/**614/**
610 * Redirect to url by replacing window.location615 * Redirect to url by replacing window.location
611 * If wait is true, sleep 1s and wait for the server i.e. after a restart.616 * If wait is true, sleep 1s and wait for the server i.e. after a restart.
@@ -722,12 +727,13 @@
722727
723instance.web.Menu = instance.web.Widget.extend({728instance.web.Menu = instance.web.Widget.extend({
724 template: 'Menu',729 template: 'Menu',
725 init: function() {730 init: function(parent) {
726 var self = this;731 var self = this;
727 this._super.apply(this, arguments);732 this._super.apply(this, arguments);
733 this.client = parent;
728 this.has_been_loaded = $.Deferred();734 this.has_been_loaded = $.Deferred();
729 this.maximum_visible_links = 'auto'; // # of menu to show. 0 = do not crop, 'auto' = algo735 this.maximum_visible_links = 'auto'; // # of menu to show. 0 = do not crop, 'auto' = algo
730 this.data = {data:{children:[]}};736 this.data = {children:[]};
731 this.on("menu_loaded", this, function (menu_data) {737 this.on("menu_loaded", this, function (menu_data) {
732 self.reflow();738 self.reflow();
733 // launch the fetch of needaction counters, asynchronous739 // launch the fetch of needaction counters, asynchronous
@@ -755,7 +761,7 @@
755 },761 },
756 menu_loaded: function(data) {762 menu_loaded: function(data) {
757 var self = this;763 var self = this;
758 this.data = {data: data};764 this.data = data;
759 this.renderElement();765 this.renderElement();
760 this.$secondary_menus.html(QWeb.render("Menu.secondary", { widget : this }));766 this.$secondary_menus.html(QWeb.render("Menu.secondary", { widget : this }));
761 this.$el.on('click', 'a[data-menu]', this.on_top_menu_click);767 this.$el.on('click', 'a[data-menu]', this.on_top_menu_click);
@@ -907,6 +913,7 @@
907 }, $item);913 }, $item);
908 }914 }
909 this.open_menu(id);915 this.open_menu(id);
916 return action_id;
910 },917 },
911 do_reload_needaction: function () {918 do_reload_needaction: function () {
912 var self = this;919 var self = this;
@@ -925,7 +932,7 @@
925 var self = this;932 var self = this;
926 var id = $(ev.currentTarget).data('menu');933 var id = $(ev.currentTarget).data('menu');
927 var menu_ids = [id];934 var menu_ids = [id];
928 var menu = _.filter(this.data.data.children, function (menu) {return menu.id == id;})[0];935 var menu = _.filter(this.data.children, function (menu) {return menu.id == id;})[0];
929 function add_menu_ids (menu) {936 function add_menu_ids (menu) {
930 if (menu.children) {937 if (menu.children) {
931 _.each(menu.children, function (menu) {938 _.each(menu.children, function (menu) {
@@ -945,6 +952,27 @@
945 var needaction = $(ev.target).is('div#menu_counter');952 var needaction = $(ev.target).is('div#menu_counter');
946 this.menu_click($(ev.currentTarget).data('menu'), needaction);953 this.menu_click($(ev.currentTarget).data('menu'), needaction);
947 },954 },
955 /**
956 * open all action and wait result for each menu
957 * log if action failed or is resolved
958 */
959 click_all_menu_items: function(index) {
960 var self = this;
961 index = index || 0;
962 // disable act_url
963 self.client.action_manager.ir_actions_act_url = function() { return $.when()};
964 if(index < self.data.all_menu_ids.length) {
965 var item = self.data.all_menu_ids[index];
966 self.menu_click(item, null);
967 self.client.menu_action_def.done(function() {
968 self.click_all_menu_items(index + 1);
969 }).fail(function () {
970 console.log("error menu item: " + item);
971 });
972 } else {
973 console.log("ok");
974 }
975 }
948});976});
949977
950instance.web.UserMenu = instance.web.Widget.extend({978instance.web.UserMenu = instance.web.Widget.extend({
@@ -1140,6 +1168,7 @@
1140 }1168 }
1141 this._current_state = null;1169 this._current_state = null;
1142 this.menu_dm = new instance.web.DropMisordered();1170 this.menu_dm = new instance.web.DropMisordered();
1171 this.menu_action_def = $.when();
1143 this.action_mutex = new $.Mutex();1172 this.action_mutex = new $.Mutex();
1144 this.set('title_part', {"zopenerp": "OpenERP"});1173 this.set('title_part', {"zopenerp": "OpenERP"});
1145 },1174 },
@@ -1358,6 +1387,7 @@
1358 },1387 },
1359 on_menu_action: function(options) {1388 on_menu_action: function(options) {
1360 var self = this;1389 var self = this;
1390 this.menu_action_def = $.Deferred();
1361 return this.menu_dm.add(this.rpc("/web/action/load", { action_id: options.action_id }))1391 return this.menu_dm.add(this.rpc("/web/action/load", { action_id: options.action_id }))
1362 .then(function (result) {1392 .then(function (result) {
1363 return self.action_mutex.exec(function() {1393 return self.action_mutex.exec(function() {
@@ -1373,6 +1403,9 @@
1373 action_menu_id: self.menu.current_menu,1403 action_menu_id: self.menu.current_menu,
1374 })).fail(function() {1404 })).fail(function() {
1375 self.menu.open_menu(options.previous_menu_id);1405 self.menu.open_menu(options.previous_menu_id);
1406 self.menu_action_def.reject();
1407 }).done(function() {
1408 self.menu_action_def.resolve();
1376 }).always(function() {1409 }).always(function() {
1377 completed.resolve();1410 completed.resolve();
1378 });1411 });
13791412
=== modified file 'addons/web/static/src/xml/base.xml'
--- addons/web/static/src/xml/base.xml 2014-05-02 12:33:55 +0000
+++ addons/web/static/src/xml/base.xml 2014-05-06 09:32:41 +0000
@@ -343,7 +343,7 @@
343343
344<t t-name="Menu">344<t t-name="Menu">
345 <ul class="nav navbar-nav navbar-left" t-if="widget.data">345 <ul class="nav navbar-nav navbar-left" t-if="widget.data">
346 <li t-foreach="widget.data.data.children" t-as="menu">346 <li t-foreach="widget.data.children" t-as="menu">
347 <t t-call="Menu.link"/>347 <t t-call="Menu.link"/>
348 </li>348 </li>
349 <li id="menu_more_container" class="dropdown" style="display: none;">349 <li id="menu_more_container" class="dropdown" style="display: none;">
@@ -353,7 +353,7 @@
353 </ul>353 </ul>
354</t>354</t>
355<t t-name="Menu.secondary">355<t t-name="Menu.secondary">
356 <div t-foreach="widget.data.data.children" t-as="menu" style="display: none" class="oe_secondary_menu" t-att-data-menu-parent="menu.id">356 <div t-foreach="widget.data.children" t-as="menu" style="display: none" class="oe_secondary_menu" t-att-data-menu-parent="menu.id">
357 <t t-foreach="menu.children" t-as="menu">357 <t t-foreach="menu.children" t-as="menu">
358 <div class="oe_secondary_menu_section">358 <div class="oe_secondary_menu_section">
359 <t t-esc="menu.name"/>359 <t t-esc="menu.name"/>
360360
=== modified file 'addons/web_tests/tests/test_ui.py'
--- addons/web_tests/tests/test_ui.py 2014-04-30 07:15:41 +0000
+++ addons/web_tests/tests/test_ui.py 2014-05-06 09:32:41 +0000
@@ -13,4 +13,10 @@
13 def test_04_js_admin(self):13 def test_04_js_admin(self):
14 self.phantom_js('/web',"console.log('ok')","openerp.client.action_manager.inner_widget.views.form", login='admin')14 self.phantom_js('/web',"console.log('ok')","openerp.client.action_manager.inner_widget.views.form", login='admin')
1515
16@openerp.tests.common.at_install(False)
17@openerp.tests.common.post_install(True)
18class TestMenuItems(openerp.tests.HttpCase):
19 def test_01_menuitems(self):
20 self.phantom_js('/web?debug',"openerp.client.menu.click_all_menu_items()","openerp.client.action_manager.inner_widget", login='admin')
21
16# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:22# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: