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
1=== modified file 'addons/web/static/src/js/chrome.js'
2--- addons/web/static/src/js/chrome.js 2014-04-23 12:37:35 +0000
3+++ addons/web/static/src/js/chrome.js 2014-05-06 09:32:41 +0000
4@@ -269,6 +269,12 @@
5 buttons[_t("Ok")] = function() {
6 this.parents('.modal').modal('hide');
7 };
8+ if (typeof window.callPhantom === 'function') {
9+ console.log(error.type + " " + error.message);
10+ console.log(error.data.debug);
11+ console.log(window.location);
12+ console.log("error");
13+ }
14 new instance.web.Dialog(this, {
15 title: "OpenERP " + _.str.capitalize(error.type),
16 buttons: buttons
17@@ -605,7 +611,6 @@
18 };
19 instance.web.client_actions.add("logout", "instance.web.logout");
20
21-
22 /**
23 * Redirect to url by replacing window.location
24 * If wait is true, sleep 1s and wait for the server i.e. after a restart.
25@@ -722,12 +727,13 @@
26
27 instance.web.Menu = instance.web.Widget.extend({
28 template: 'Menu',
29- init: function() {
30+ init: function(parent) {
31 var self = this;
32 this._super.apply(this, arguments);
33+ this.client = parent;
34 this.has_been_loaded = $.Deferred();
35 this.maximum_visible_links = 'auto'; // # of menu to show. 0 = do not crop, 'auto' = algo
36- this.data = {data:{children:[]}};
37+ this.data = {children:[]};
38 this.on("menu_loaded", this, function (menu_data) {
39 self.reflow();
40 // launch the fetch of needaction counters, asynchronous
41@@ -755,7 +761,7 @@
42 },
43 menu_loaded: function(data) {
44 var self = this;
45- this.data = {data: data};
46+ this.data = data;
47 this.renderElement();
48 this.$secondary_menus.html(QWeb.render("Menu.secondary", { widget : this }));
49 this.$el.on('click', 'a[data-menu]', this.on_top_menu_click);
50@@ -907,6 +913,7 @@
51 }, $item);
52 }
53 this.open_menu(id);
54+ return action_id;
55 },
56 do_reload_needaction: function () {
57 var self = this;
58@@ -925,7 +932,7 @@
59 var self = this;
60 var id = $(ev.currentTarget).data('menu');
61 var menu_ids = [id];
62- var menu = _.filter(this.data.data.children, function (menu) {return menu.id == id;})[0];
63+ var menu = _.filter(this.data.children, function (menu) {return menu.id == id;})[0];
64 function add_menu_ids (menu) {
65 if (menu.children) {
66 _.each(menu.children, function (menu) {
67@@ -945,6 +952,27 @@
68 var needaction = $(ev.target).is('div#menu_counter');
69 this.menu_click($(ev.currentTarget).data('menu'), needaction);
70 },
71+ /**
72+ * open all action and wait result for each menu
73+ * log if action failed or is resolved
74+ */
75+ click_all_menu_items: function(index) {
76+ var self = this;
77+ index = index || 0;
78+ // disable act_url
79+ self.client.action_manager.ir_actions_act_url = function() { return $.when()};
80+ if(index < self.data.all_menu_ids.length) {
81+ var item = self.data.all_menu_ids[index];
82+ self.menu_click(item, null);
83+ self.client.menu_action_def.done(function() {
84+ self.click_all_menu_items(index + 1);
85+ }).fail(function () {
86+ console.log("error menu item: " + item);
87+ });
88+ } else {
89+ console.log("ok");
90+ }
91+ }
92 });
93
94 instance.web.UserMenu = instance.web.Widget.extend({
95@@ -1140,6 +1168,7 @@
96 }
97 this._current_state = null;
98 this.menu_dm = new instance.web.DropMisordered();
99+ this.menu_action_def = $.when();
100 this.action_mutex = new $.Mutex();
101 this.set('title_part', {"zopenerp": "OpenERP"});
102 },
103@@ -1358,6 +1387,7 @@
104 },
105 on_menu_action: function(options) {
106 var self = this;
107+ this.menu_action_def = $.Deferred();
108 return this.menu_dm.add(this.rpc("/web/action/load", { action_id: options.action_id }))
109 .then(function (result) {
110 return self.action_mutex.exec(function() {
111@@ -1373,6 +1403,9 @@
112 action_menu_id: self.menu.current_menu,
113 })).fail(function() {
114 self.menu.open_menu(options.previous_menu_id);
115+ self.menu_action_def.reject();
116+ }).done(function() {
117+ self.menu_action_def.resolve();
118 }).always(function() {
119 completed.resolve();
120 });
121
122=== modified file 'addons/web/static/src/xml/base.xml'
123--- addons/web/static/src/xml/base.xml 2014-05-02 12:33:55 +0000
124+++ addons/web/static/src/xml/base.xml 2014-05-06 09:32:41 +0000
125@@ -343,7 +343,7 @@
126
127 <t t-name="Menu">
128 <ul class="nav navbar-nav navbar-left" t-if="widget.data">
129- <li t-foreach="widget.data.data.children" t-as="menu">
130+ <li t-foreach="widget.data.children" t-as="menu">
131 <t t-call="Menu.link"/>
132 </li>
133 <li id="menu_more_container" class="dropdown" style="display: none;">
134@@ -353,7 +353,7 @@
135 </ul>
136 </t>
137 <t t-name="Menu.secondary">
138- <div t-foreach="widget.data.data.children" t-as="menu" style="display: none" class="oe_secondary_menu" t-att-data-menu-parent="menu.id">
139+ <div t-foreach="widget.data.children" t-as="menu" style="display: none" class="oe_secondary_menu" t-att-data-menu-parent="menu.id">
140 <t t-foreach="menu.children" t-as="menu">
141 <div class="oe_secondary_menu_section">
142 <t t-esc="menu.name"/>
143
144=== modified file 'addons/web_tests/tests/test_ui.py'
145--- addons/web_tests/tests/test_ui.py 2014-04-30 07:15:41 +0000
146+++ addons/web_tests/tests/test_ui.py 2014-05-06 09:32:41 +0000
147@@ -13,4 +13,10 @@
148 def test_04_js_admin(self):
149 self.phantom_js('/web',"console.log('ok')","openerp.client.action_manager.inner_widget.views.form", login='admin')
150
151+@openerp.tests.common.at_install(False)
152+@openerp.tests.common.post_install(True)
153+class TestMenuItems(openerp.tests.HttpCase):
154+ def test_01_menuitems(self):
155+ self.phantom_js('/web?debug',"openerp.client.menu.click_all_menu_items()","openerp.client.action_manager.inner_widget", login='admin')
156+
157 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: