summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/chrome
diff options
context:
space:
mode:
authorLucas Lefèvre <lul@odoo.com>2020-02-28 11:25:41 +0000
committerLucas Lefèvre <lul@odoo.com>2020-03-03 11:01:03 +0000
commitb7d1db596bf2dcbf5d95d7258d9a2978bc0003f8 (patch)
tree23827e84f2bc40d4261dcfb326d507a723b47ec2 /addons/web/static/tests/chrome
parent4f602d31b4062723149989142bcc0926f2c76160 (diff)
[FIX] web: Call on_attach_callback on systray widgets
Currently, the method `on_attach_callback` is never called on any Widget in the systray. Calling `on_attach_callback` is required if any systray widget uses an OWL component via the ComponentWrapper. Without the callback, the component is never considered mounted to the DOM and no event handler is triggered. closes odoo/odoo#46566 Related: odoo/enterprise#8887 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Diffstat (limited to 'addons/web/static/tests/chrome')
-rw-r--r--addons/web/static/tests/chrome/menu_tests.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/addons/web/static/tests/chrome/menu_tests.js b/addons/web/static/tests/chrome/menu_tests.js
new file mode 100644
index 00000000000..c7ce40b16c2
--- /dev/null
+++ b/addons/web/static/tests/chrome/menu_tests.js
@@ -0,0 +1,47 @@
+odoo.define('web.menu_tests', function (require) {
+ "use strict";
+
+ const testUtils = require('web.test_utils');
+ const Menu = require('web.Menu');
+ const SystrayMenu = require('web.SystrayMenu');
+ const Widget = require('web.Widget');
+
+
+ QUnit.module('chrome', {}, function () {
+ QUnit.module('Menu');
+
+ QUnit.test('Systray on_attach_callback is called', async function (assert) {
+ assert.expect(4);
+
+ const parent = testUtils.createParent({});
+
+ // Add some widgets to the systray
+ const Widget1 = Widget.extend({
+ on_attach_callback: () => assert.step('on_attach_callback widget1')
+ });
+ const Widget2 = Widget.extend({
+ on_attach_callback: () => assert.step('on_attach_callback widget2')
+ });
+ SystrayMenu.Items = [Widget1, Widget2]
+
+ testUtils.mock.patch(SystrayMenu, {
+ on_attach_callback: function () {
+ assert.step('on_attach_callback systray');
+ this._super(...arguments);
+ }
+ });
+
+ const menu = new Menu(parent, {children: []});
+ await menu.appendTo($('#qunit-fixture'));
+
+ assert.verifySteps([
+ 'on_attach_callback systray',
+ 'on_attach_callback widget1',
+ 'on_attach_callback widget2',
+ ]);
+ testUtils.mock.unpatch(SystrayMenu);
+ parent.destroy();
+ });
+ });
+
+});