summaryrefslogtreecommitdiff
path: root/addons/mail/static/tests/thread_window
diff options
context:
space:
mode:
authorVincent Schippefilt <vsc@odoo.com>2019-03-06 14:02:19 +0100
committerAaron Bohy <aab@odoo.com>2019-03-06 20:07:17 +0100
commit1ae64793fa489b2c1d07408cd9671bc7126f78fa (patch)
tree23d908222f4e705b908dd23ef3823c26daf3baf0 /addons/mail/static/tests/thread_window
parentaa900d976f6fbb10f3940639b4d918d31a7556ca (diff)
[REF] mail: adapt code after jQuery update
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
Diffstat (limited to 'addons/mail/static/tests/thread_window')
-rw-r--r--addons/mail/static/tests/thread_window/basic_thread_window_tests.js109
-rw-r--r--addons/mail/static/tests/thread_window/blank_thread_window_tests.js85
-rw-r--r--addons/mail/static/tests/thread_window/hidden_thread_window_tests.js15
-rw-r--r--addons/mail/static/tests/thread_window/moderation_thread_window_tests.js5
-rw-r--r--addons/mail/static/tests/thread_window/typing_thread_window_tests.js13
5 files changed, 138 insertions, 89 deletions
diff --git a/addons/mail/static/tests/thread_window/basic_thread_window_tests.js b/addons/mail/static/tests/thread_window/basic_thread_window_tests.js
index 5a0bc62f880..d5af9cf5357 100644
--- a/addons/mail/static/tests/thread_window/basic_thread_window_tests.js
+++ b/addons/mail/static/tests/thread_window/basic_thread_window_tests.js
@@ -55,7 +55,7 @@ QUnit.module('Basic', {
},
});
-QUnit.test('basic rendering thread window', function (assert) {
+QUnit.test('basic rendering thread window', async function (assert) {
assert.expect(10);
var parent = this.createParent({
@@ -63,9 +63,13 @@ QUnit.test('basic rendering thread window', function (assert) {
services: this.services,
});
+ await testUtils.nextTick();
// detach channel 1, so that it opens corresponding thread window.
- parent.call('mail_service', 'getChannel', 1).detach();
+ var result = parent.call('mail_service', 'getChannel', 1);
+ await testUtils.nextTick();
+ result.detach();
+ await testUtils.nextTick();
var $threadWindow = $('.o_thread_window');
assert.strictEqual($threadWindow.length, 1,
"thread window should be open");
@@ -98,7 +102,7 @@ QUnit.test('basic rendering thread window', function (assert) {
parent.destroy();
});
-QUnit.test('close thread window using ESCAPE key', function (assert) {
+QUnit.test('close thread window using ESCAPE key', async function (assert) {
assert.expect(5);
var parent = this.createParent({
@@ -107,28 +111,31 @@ QUnit.test('close thread window using ESCAPE key', function (assert) {
mockRPC: function (route, args) {
if (args.method === 'channel_fold') {
assert.ok(true, "should call channel_fold");
- return $.when();
+ return Promise.resolve();
}
return this._super.apply(this, arguments);
},
});
+ await testUtils.nextTick();
// get channel instance to link to thread window
var channel = parent.call('mail_service', 'getChannel', 1);
+ await testUtils.nextTick();
assert.ok(channel, "there should exist a channel locally with ID 1");
channel.detach();
+ await testUtils.nextTick();
assert.strictEqual($('.o_thread_window').length, 1,
"there should be a thread window that is opened");
// focus on the thread window and press ESCAPE
- testUtils.dom.click($('.o_thread_window .o_composer_text_field'));
+ await testUtils.dom.click($('.o_thread_window .o_composer_text_field'));
assert.strictEqual(document.activeElement,
$('.o_thread_window .o_composer_text_field')[0],
"thread window's input should now be focused");
var upKeyEvent = $.Event( "keyup", { which: 27 });
- $('.o_thread_window .o_composer_text_field').trigger(upKeyEvent);
+ await testUtils.dom.triggerEvents($('.o_thread_window .o_composer_text_field'), [upKeyEvent]);
assert.strictEqual($('.o_thread_window').length, 0,
"the thread window should be closed");
@@ -136,7 +143,7 @@ QUnit.test('close thread window using ESCAPE key', function (assert) {
parent.destroy();
});
-QUnit.test('thread window\'s input can still be focused when the UI is blocked', function (assert) {
+QUnit.test('thread window\'s input can still be focused when the UI is blocked', async function (assert) {
assert.expect(2);
var parent = this.createParent({
@@ -147,11 +154,13 @@ QUnit.test('thread window\'s input can still be focused when the UI is blocked',
var $dom = $('#qunit-fixture');
// get channel instance to link to thread window
+ await testUtils.nextTick();
var channel = parent.call('mail_service', 'getChannel', 1);
+ await testUtils.nextTick();
channel.detach();
-
+ await testUtils.nextTick();
var $input = $('<input/>', {type: 'text'}).appendTo($dom);
- testUtils.dom.click($input.focus());
+ await testUtils.dom.click($input.focus());
assert.strictEqual(document.activeElement, $input[0],
"fake input should be focused");
@@ -160,16 +169,17 @@ QUnit.test('thread window\'s input can still be focused when the UI is blocked',
// makes no sense, this test is just about
// making sure that the code which forces the
// focus on click is not removed
- testUtils.dom.click($('.o_thread_window .o_composer_text_field'));
+ await testUtils.dom.click($('.o_thread_window .o_composer_text_field'));
assert.strictEqual(document.activeElement,
$('.o_thread_window .o_composer_text_field')[0],
"thread window's input should now be focused");
framework.unblockUI();
parent.destroy();
+ $input.remove();
});
-QUnit.test('emoji popover should open correctly in thread windows', function (assert) {
+QUnit.test('emoji popover should open correctly in thread windows', async function (assert) {
assert.expect(1);
var parent = this.createParent({
@@ -178,23 +188,20 @@ QUnit.test('emoji popover should open correctly in thread windows', function (as
});
// get channel instance to link to thread window
+ await testUtils.nextTick();
var channel = parent.call('mail_service', 'getChannel', 1);
+ await testUtils.nextTick();
channel.detach();
-
+ await testUtils.nextTick();
var $emojiButton = $('.o_composer_button_emoji');
- testUtils.dom.click($emojiButton.trigger('focusin').focus());
+ await testUtils.dom.click($emojiButton.trigger('focusin').focus());
var $popover = $('.o_mail_emoji_container');
- var done = assert.async();
- // Async is needed as the popover focusout hiding is deferred
- setTimeout(function () {
- assert.ok($popover.is(':visible'), "emoji popover should have stayed opened");
- parent.destroy();
- done();
- }, 0);
+ assert.ok($popover.is(':visible'), "emoji popover should have stayed opened");
+ parent.destroy();
});
-QUnit.test('do not increase unread counter when receiving message with myself as author', function (assert) {
+QUnit.test('do not increase unread counter when receiving message with myself as author', async function (assert) {
assert.expect(4);
var parent = this.createParent({
@@ -204,9 +211,11 @@ QUnit.test('do not increase unread counter when receiving message with myself as
});
// get channel instance to link to thread window
+ await testUtils.nextTick();
var channel = parent.call('mail_service', 'getChannel', 1);
+ await testUtils.nextTick();
channel.detach();
-
+ await testUtils.nextTick();
var threadWindowHeaderText = $('.o_thread_window_header').text().replace(/\s/g, "");
assert.strictEqual(threadWindowHeaderText, "#general",
@@ -226,6 +235,7 @@ QUnit.test('do not increase unread counter when receiving message with myself as
var notification = [[false, 'mail.channel', 1], messageData];
parent.call('bus_service', 'trigger', 'notification', [notification]);
+ await testUtils.nextTick();
threadWindowHeaderText = $('.o_thread_window_header').text().replace(/\s/g, "");
assert.strictEqual(threadWindowHeaderText, "#general",
@@ -236,7 +246,7 @@ QUnit.test('do not increase unread counter when receiving message with myself as
parent.destroy();
});
-QUnit.test('do not increment unread counter with focus on thread window', function (assert) {
+QUnit.test('do not increment unread counter with focus on thread window', async function (assert) {
// 'hard' focus means that the user has clicked on the thread window in
// order to set the focus on it.
assert.expect(2);
@@ -248,14 +258,17 @@ QUnit.test('do not increment unread counter with focus on thread window', functi
});
// get channel instance to link to thread window
+ await testUtils.nextTick();
var channel = parent.call('mail_service', 'getChannel', 1);
+ await testUtils.nextTick();
channel.detach();
+ await testUtils.nextTick();
assert.strictEqual(channel.getUnreadCounter(), 0,
"thread should have unread counter to 0 initially");
// hard focus on thread window composer
- testUtils.dom.click($('.o_composer_text_field'));
+ await testUtils.dom.click($('.o_composer_text_field'));
// simulate receiving message from someone else
var messageData = {
@@ -268,6 +281,7 @@ QUnit.test('do not increment unread counter with focus on thread window', functi
};
var notification = [[false, 'mail.channel', 1], messageData];
parent.call('bus_service', 'trigger', 'notification', [notification]);
+ await testUtils.nextTick();
assert.strictEqual(channel.getUnreadCounter(), 0,
"thread should not have incremented its unread counter after receiving the message");
@@ -275,7 +289,7 @@ QUnit.test('do not increment unread counter with focus on thread window', functi
parent.destroy();
});
-QUnit.test('do not mark as read the newly open thread window from received message', function (assert) {
+QUnit.test('do not mark as read the newly open thread window from received message', async function (assert) {
assert.expect(5);
this.data['mail.channel'] = {
@@ -315,7 +329,7 @@ QUnit.test('do not mark as read the newly open thread window from received messa
if (args.method === 'channel_join_and_get_info') {
this.data['mail.channel'].records[0].state = 'open';
this.data['mail.channel'].records[0].is_minimized = true;
- return $.when(this.data['mail.channel'].records[0]);
+ return Promise.resolve(this.data['mail.channel'].records[0]);
}
return this._super.apply(this, arguments);
},
@@ -338,7 +352,7 @@ QUnit.test('do not mark as read the newly open thread window from received messa
// a new message from a new channel.
this.data['mail.channel'].records[0].message_unread_counter++;
parent.call('bus_service', 'trigger', 'notification', [notification]);
-
+ await testUtils.nextTick();
var $threadWindow = $('.o_thread_window');
assert.strictEqual($threadWindow.length, 1,
"a thread window should be open after receiving a new message on a new DM chat");
@@ -347,14 +361,14 @@ QUnit.test('do not mark as read the newly open thread window from received messa
assert.strictEqual($threadWindow.find('.o_thread_window_title').text().replace(/\s/g, ''), '#DM(1)',
"open DM chat window should have one unread message");
- testUtils.dom.click($threadWindow.find('.o_thread_composer'));
+ await testUtils.dom.click($threadWindow.find('.o_thread_composer'));
assert.strictEqual($threadWindow.find('.o_thread_window_title').text().replace(/\s/g, ''), '#DM',
"open DM chat window should have message marked as read on composer focus");
parent.destroy();
});
-QUnit.test('show document link of message linked to a document', function (assert) {
+QUnit.test('show document link of message linked to a document', async function (assert) {
assert.expect(6);
this.data['mail.channel'] = {
@@ -410,8 +424,11 @@ QUnit.test('show document link of message linked to a document', function (asser
"no thread window should be open initially");
// get channel instance to link to thread window
+ await testUtils.nextTick();
var channel = parent.call('mail_service', 'getChannel', 2);
+ await testUtils.nextTick();
channel.detach();
+ await testUtils.nextTick();
var $threadWindow = $('.o_thread_window');
assert.strictEqual($threadWindow.length, 1,
@@ -429,7 +446,7 @@ QUnit.test('show document link of message linked to a document', function (asser
parent.destroy();
});
-QUnit.test('do not autofocus chat window on receiving new direct message', function (assert) {
+QUnit.test('do not autofocus chat window on receiving new direct message', async function (assert) {
// Receiving a message doesn't make other input loose focus
assert.expect(3);
@@ -473,7 +490,7 @@ QUnit.test('do not autofocus chat window on receiving new direct message', funct
}],
};
- var form = testUtils.createView({
+ var form = await testUtils.createView({
View: FormView,
model: 'partner',
data: this.data,
@@ -487,7 +504,7 @@ QUnit.test('do not autofocus chat window on receiving new direct message', funct
},
mockRPC: function (route, args) {
if (args.method === 'channel_join_and_get_info') {
- return $.when(this.data['mail.channel'].records[0]);
+ return Promise.resolve(this.data['mail.channel'].records[0]);
}
return this._super.apply(this, arguments);
}
@@ -512,7 +529,7 @@ QUnit.test('do not autofocus chat window on receiving new direct message', funct
this.data['mail.message'].records.push(messageData);
var notification = [[false, 'mail.channel', 2], messageData];
form.call('bus_service', 'trigger', 'notification', [notification]);
-
+ await testUtils.nextTick();
assert.ok($('.o_thread_window.o_in_home_menu').length,
'Chat window is opened');
@@ -522,7 +539,7 @@ QUnit.test('do not autofocus chat window on receiving new direct message', funct
form.destroy();
});
-QUnit.test('do not auto-focus chat window on receiving new message from new DM', function (assert) {
+QUnit.test('do not auto-focus chat window on receiving new message from new DM', async function (assert) {
assert.expect(10);
var self = this;
@@ -564,7 +581,7 @@ QUnit.test('do not auto-focus chat window on receiving new message from new DM',
session: { partner_id: 3 },
mockRPC: function (route, args) {
if (args.method === 'channel_join_and_get_info') {
- return $.when(_.extend({}, self.data['mail.channel'].records[0], { info: 'join' }));
+ return Promise.resolve(_.extend({}, self.data['mail.channel'].records[0], { info: 'join' }));
}
if (args.method === 'channel_minimize') {
_.extend(self.data['mail.channel'].records[0], {
@@ -594,6 +611,7 @@ QUnit.test('do not auto-focus chat window on receiving new message from new DM',
this.data['mail.message'].records.push(messageData);
var notification = [[false, 'mail.channel', 2], messageData];
parent.call('bus_service', 'trigger', 'notification', [notification]);
+ await testUtils.nextTick();
assert.strictEqual($('.o_thread_window').length, 1,
"should have DM window open");
@@ -610,6 +628,7 @@ QUnit.test('do not auto-focus chat window on receiving new message from new DM',
});
notification = [[false, 'res.partner', 3], dmInfo];
parent.call('bus_service', 'trigger', 'notification', [notification]);
+ await testUtils.nextTick();
assert.strictEqual($('.o_thread_window').length, 1,
"should still have DM window open after receiving DM info from polling");
@@ -621,6 +640,7 @@ QUnit.test('do not auto-focus chat window on receiving new message from new DM',
// simulate receiving detached DM notification (cross-tab synchronization)
notification = [[false, 'res.partner', 3], self.data['mail.channel'].records[0]];
parent.call('bus_service', 'trigger', 'notification', [notification]);
+ await testUtils.nextTick();
assert.strictEqual($('.o_thread_window').length, 1,
"should still have DM open after receiving detached info from polling");
@@ -632,7 +652,7 @@ QUnit.test('do not auto-focus chat window on receiving new message from new DM',
parent.destroy();
});
-QUnit.test('out-of-office status in thread window', function (assert) {
+QUnit.test('out-of-office status in thread window', async function (assert) {
assert.expect(1);
this.data = {
'mail.message': {
@@ -655,8 +675,13 @@ QUnit.test('out-of-office status in thread window', function (assert) {
data: this.data,
services: this.services,
});
+ await testUtils.nextTick();
+
// detach channel 1, so that it opens corresponding thread window.
- parent.call('mail_service', 'getChannel', 1).detach();
+ var channel = parent.call('mail_service', 'getChannel', 1);
+ await testUtils.nextTick();
+ channel.detach();
+ await testUtils.nextTick();
var $threadWindow = $('.o_thread_window');
assert.containsOnce($threadWindow, '.o_out_of_office_text');
@@ -664,7 +689,7 @@ QUnit.test('out-of-office status in thread window', function (assert) {
parent.destroy();
});
-QUnit.test('no out-of-office status in thread window', function (assert) {
+QUnit.test('no out-of-office status in thread window', async function (assert) {
assert.expect(1);
this.data = {
'mail.message': {
@@ -687,11 +712,17 @@ QUnit.test('no out-of-office status in thread window', function (assert) {
data: this.data,
services: this.services,
});
+ await testUtils.nextTick();
+
// detach channel 1, so that it opens corresponding thread window.
- parent.call('mail_service', 'getChannel', 1).detach();
+ var channel = parent.call('mail_service', 'getChannel', 1);
+ await testUtils.nextTick();
+ channel.detach();
+ await testUtils.nextTick();
var $threadWindow = $('.o_thread_window');
assert.containsNone($threadWindow, '.o_out_of_office_text');
+
parent.destroy();
});
diff --git a/addons/mail/static/tests/thread_window/blank_thread_window_tests.js b/addons/mail/static/tests/thread_window/blank_thread_window_tests.js
index 4f103f71163..4a24a80d4c3 100644
--- a/addons/mail/static/tests/thread_window/blank_thread_window_tests.js
+++ b/addons/mail/static/tests/thread_window/blank_thread_window_tests.js
@@ -53,8 +53,8 @@ QUnit.module('Blank', {
* functions end.
*
* @param {Object} params
- * @param {$.Deferred} params.selectDef
- * @param {$.Deferred} params.sourceDef
+ * @param {Promise} params.selectDef
+ * @param {Promise} params.sourceDef
*/
this.patchAutocomplete = function (params) {
var selectDef = params.selectDef;
@@ -87,7 +87,7 @@ QUnit.module('Blank', {
},
});
-QUnit.test('basic rendering blank thread window', function (assert) {
+QUnit.test('basic rendering blank thread window', async function (assert) {
assert.expect(5);
var parent = this.createParent({
@@ -97,7 +97,7 @@ QUnit.test('basic rendering blank thread window', function (assert) {
// open blank thread window
parent.call('mail_service', 'openBlankThreadWindow');
-
+ await testUtils.nextMicrotaskTick();
assert.strictEqual($('.o_thread_window').length, 1,
"should have a thread window open");
assert.strictEqual($('.o_thread_window_title').text().trim(),
@@ -114,7 +114,7 @@ QUnit.test('basic rendering blank thread window', function (assert) {
parent.destroy();
});
-QUnit.test('close blank thread window', function (assert) {
+QUnit.test('close blank thread window', async function (assert) {
assert.expect(1);
var parent = this.createParent({
@@ -124,8 +124,9 @@ QUnit.test('close blank thread window', function (assert) {
// open blank thread window
parent.call('mail_service', 'openBlankThreadWindow');
+ await testUtils.nextMicrotaskTick();
- testUtils.dom.click($('.o_thread_window_close'));
+ await testUtils.dom.click($('.o_thread_window_close'));
assert.strictEqual($('.o_thread_window').length, 0,
"blank thread window should be closed");
@@ -133,10 +134,10 @@ QUnit.test('close blank thread window', function (assert) {
parent.destroy();
});
-QUnit.test('fold blank thread window', function (assert) {
+QUnit.test('fold blank thread window', async function (assert) {
// This test requires full height of thread windows when they are open.
// (e.g. 400px)
- assert.expect(2);
+ assert.expect(3);
var parent = this.createParent({
data: this.data,
@@ -153,34 +154,37 @@ QUnit.test('fold blank thread window', function (assert) {
// Open blank thread window
parent.call('mail_service', 'openBlankThreadWindow');
+ await testUtils.nextTick();
+
+ assert.containsOnce(document.body, '.o_thread_window');
assert.strictEqual($('.o_thread_window').css('height'), HEIGHT_OPEN,
"blank thread window should be open");
if ($('.o_thread_window').css('height') !== HEIGHT_OPEN) {
console.warn('Assertion above may fail due to too narrow height of browser');
}
- testUtils.dom.click($('.o_thread_window_title'));
+ await testUtils.dom.click($('.o_thread_window_title'));
assert.strictEqual($('.o_thread_window').css('height'), HEIGHT_FOLDED,
- "blank thread window should be open");
+ "blank thread window should be folded");
parent.destroy();
testUtils.mock.unpatch(AbstractThreadWindow);
});
-QUnit.test('open new DM chat from blank thread window', function (assert) {
+QUnit.test('open new DM chat from blank thread window', async function (assert) {
assert.expect(6);
var done = assert.async();
var self = this;
- var selectDef = $.Deferred();
- var sourceDef = $.Deferred();
+ var selectDef = testUtils.makeTestPromise();
+ var sourceDef = testUtils.makeTestPromise();
this.patchAutocomplete({
selectDef: selectDef,
sourceDef: sourceDef,
});
- var def = $.Deferred();
+ var def = testUtils.makeTestPromise();
this.data['res.partner'] = {
fields: {},
@@ -193,13 +197,13 @@ QUnit.test('open new DM chat from blank thread window', function (assert) {
mockRPC: function (route, args) {
if (args.method === 'im_search') {
def.resolve();
- return $.when([
+ return Promise.resolve([
{ id: 1, name: 'DemoUser1' },
{ id: 2, name: 'DemoUser2', }
]);
}
if (args.method === 'channel_get_and_minimize') {
- return $.when({
+ return Promise.resolve({
channel_type: 'chat',
direct_partner: [{ id: args.args[0][0], name: 'DemoUser1', im_status: '' }],
id: 50,
@@ -213,19 +217,20 @@ QUnit.test('open new DM chat from blank thread window', function (assert) {
// open blank thread window
parent.call('mail_service', 'openBlankThreadWindow');
-
- $('.o_thread_search_input input').val("D").trigger('keydown');
-
- $.when(sourceDef, def).then(function () {
- assert.strictEqual($('.ui-menu-item a').length, 2,
- "should suggest 2 partners for DM");
- assert.strictEqual($('.ui-menu-item a').eq(0).text(), "DemoUser1",
- "first suggestion should be 'DemoUser1'");
- assert.strictEqual($('.ui-menu-item a').eq(1).text(), "DemoUser2",
- "second suggestion should be 'DemoUser2'");
-
- testUtils.dom.click($('.ui-menu-item a').eq(0));
- });
+ await testUtils.nextMicrotaskTick();
+ await testUtils.fields.editAndTrigger($('.o_thread_search_input input'), 'D', 'keydown');
+ await testUtils.nextTick();
+ await Promise.all([sourceDef, def]);
+ await testUtils.nextTick();
+ assert.strictEqual($('.ui-menu-item a').length, 2,
+ "should suggest 2 partners for DM");
+ assert.strictEqual($('.ui-menu-item a').eq(0).text(), "DemoUser1",
+ "first suggestion should be 'DemoUser1'");
+ assert.strictEqual($('.ui-menu-item a').eq(1).text(), "DemoUser2",
+ "second suggestion should be 'DemoUser2'");
+
+ await testUtils.dom.clickFirst($('.ui-menu-item a'),{allowInvisible:true});
+ await testUtils.nextTick();
selectDef.then(function () {
assert.strictEqual($('.o_thread_window').length, 1,
"should be a single window");
@@ -240,22 +245,22 @@ QUnit.test('open new DM chat from blank thread window', function (assert) {
});
});
-QUnit.test('open already detached DM chat from blank thread window', function (assert) {
+QUnit.test('open already detached DM chat from blank thread window', async function (assert) {
// when opening an already detach DM chat from the blank thread window,
// the blank thread window should disappear
assert.expect(6);
var done = assert.async();
var self = this;
- var selectDef = $.Deferred();
- var sourceDef = $.Deferred();
+ var selectDef = testUtils.makeTestPromise();
+ var sourceDef = testUtils.makeTestPromise();
this.patchAutocomplete({
selectDef: selectDef,
sourceDef: sourceDef,
});
- var def = $.Deferred();
+ var def = testUtils.makeTestPromise();
this.data['res.partner'] = {
fields: {},
@@ -275,7 +280,7 @@ QUnit.test('open already detached DM chat from blank thread window', function (a
mockRPC: function (route, args) {
if (args.method === 'im_search') {
def.resolve();
- return $.when([
+ return Promise.resolve([
{ id: 1, name: 'DemoUser1' },
]);
}
@@ -283,6 +288,7 @@ QUnit.test('open already detached DM chat from blank thread window', function (a
},
});
+ await testUtils.nextTick();
assert.strictEqual($('.o_thread_window').length, 1,
"should be a single window");
assert.strictEqual($('.o_thread_window_title').text().trim(), "DemoUser1",
@@ -292,15 +298,16 @@ QUnit.test('open already detached DM chat from blank thread window', function (a
// open blank thread window
parent.call('mail_service', 'openBlankThreadWindow');
-
+ await testUtils.nextMicrotaskTick();
assert.strictEqual($('.o_thread_window').length, 2,
"should have two thread windows open");
+ await testUtils.fields.editAndTrigger($('.o_thread_search_input input'), 'D', 'keydown');
- $('.o_thread_search_input input').val("D").trigger('keydown');
- $.when(sourceDef, def).then(function () {
- testUtils.dom.click($('.ui-menu-item a').eq(0));
- });
+ await Promise.all([sourceDef, def]);
+ await testUtils.nextTick();
+ await testUtils.dom.click($('.ui-menu-item a'),{allowInvisible:true});
+ await testUtils.nextTick();
selectDef.then(function () {
assert.strictEqual($('.o_thread_window').length, 1,
"should now have a single thread window open");
diff --git a/addons/mail/static/tests/thread_window/hidden_thread_window_tests.js b/addons/mail/static/tests/thread_window/hidden_thread_window_tests.js
index b87dbe0f794..691e37df362 100644
--- a/addons/mail/static/tests/thread_window/hidden_thread_window_tests.js
+++ b/addons/mail/static/tests/thread_window/hidden_thread_window_tests.js
@@ -48,12 +48,15 @@ QUnit.module('Hidden', {
};
},
afterEach: function () {
+ // remove thread window dropup appended by mail service
+ var $target = $(this.services.mail_service.prototype.THREAD_WINDOW_APPENDTO);
+ $target.find('.o_thread_window_dropdown').remove();
// reset thread window append to body
this.services.mail_service.prototype.THREAD_WINDOW_APPENDTO = 'body';
},
});
-QUnit.test('hidden thread windows dropdown when not enough horizontal space (version 1)', function (assert) {
+QUnit.test('hidden thread windows dropdown when not enough horizontal space (version 1)', async function (assert) {
// This test has hard-set global width, so that it does not depend on
// the width of the screen: at most 2 thread windows visible at the
// same time, and additional thread windows are in hidden while and
@@ -87,9 +90,10 @@ QUnit.test('hidden thread windows dropdown when not enough horizontal space (ver
data: this.data,
services: this.services,
});
-
+ await testUtils.nextTick();
parent.call('mail_service', 'getChannel', 0).detach();
parent.call('mail_service', 'getChannel', 1).detach();
+ await testUtils.nextTick();
var $visibleThreadWindows = $('.o_thread_window:not(.o_thread_window_dropdown, .o_hidden)');
@@ -106,6 +110,7 @@ QUnit.test('hidden thread windows dropdown when not enough horizontal space (ver
// detach a channel so that it exceeds available slots
parent.call('mail_service', 'getChannel', 2).detach();
+ await testUtils.nextTick();
// update list of visible thread windows
$visibleThreadWindows = $('.o_thread_window:not(.o_thread_window_dropdown, .o_hidden)');
@@ -131,7 +136,7 @@ QUnit.test('hidden thread windows dropdown when not enough horizontal space (ver
testUtils.mock.unpatch(this.services.mail_service);
});
-QUnit.test('hidden thread windows dropdown when not enough horizontal space (version 2)', function (assert) {
+QUnit.test('hidden thread windows dropdown when not enough horizontal space (version 2)', async function (assert) {
// This is almost the same test as the one before, except there are
// at most 3 thread windows visible, and 2 thread windows are visible
// when it shows the 'hidden thread window' button.
@@ -171,10 +176,11 @@ QUnit.test('hidden thread windows dropdown when not enough horizontal space (ver
data: this.data,
services: this.services,
});
-
+ await testUtils.nextTick();
parent.call('mail_service', 'getChannel', 0).detach();
parent.call('mail_service', 'getChannel', 1).detach();
parent.call('mail_service', 'getChannel', 2).detach();
+ await testUtils.nextTick();
var $visibleThreadWindows = $('.o_thread_window:not(.o_thread_window_dropdown, .o_hidden)');
@@ -193,6 +199,7 @@ QUnit.test('hidden thread windows dropdown when not enough horizontal space (ver
// detach a channel so that it exceeds available slots
parent.call('mail_service', 'getChannel', 3).detach();
+ await testUtils.nextTick();
// update list of visible thread windows
$visibleThreadWindows = $('.o_thread_window:not(.o_thread_window_dropdown, .o_hidden)');
diff --git a/addons/mail/static/tests/thread_window/moderation_thread_window_tests.js b/addons/mail/static/tests/thread_window/moderation_thread_window_tests.js
index b35405a2243..732a5fe7938 100644
--- a/addons/mail/static/tests/thread_window/moderation_thread_window_tests.js
+++ b/addons/mail/static/tests/thread_window/moderation_thread_window_tests.js
@@ -84,7 +84,7 @@ QUnit.module('Moderation', {
},
});
-QUnit.test('moderator: moderated channel with pending moderation message', function (assert) {
+QUnit.test('moderator: moderated channel with pending moderation message', async function (assert) {
assert.expect(5);
this.data.initMessaging = {
@@ -114,9 +114,10 @@ QUnit.test('moderator: moderated channel with pending moderation message', funct
data: this.data,
services: this.services,
});
-
+ await testUtils.nextTick();
// detach channel 1, so that it opens corresponding thread window.
parent.call('mail_service', 'getChannel', 1).detach();
+ await testUtils.nextTick();
assert.strictEqual($('.o_thread_message ').length, 1,
"should display a message in the thread window");
diff --git a/addons/mail/static/tests/thread_window/typing_thread_window_tests.js b/addons/mail/static/tests/thread_window/typing_thread_window_tests.js
index 549cfdb7184..be2bd4beec8 100644
--- a/addons/mail/static/tests/thread_window/typing_thread_window_tests.js
+++ b/addons/mail/static/tests/thread_window/typing_thread_window_tests.js
@@ -40,7 +40,7 @@ QUnit.module('Typing', {
* @param {integer} params.partnerID
* @param {Widget} params.widget a widget that can call the bus_service
*/
- this.simulateIsTyping = function (params) {
+ this.simulateIsTyping = async function (params) {
var typingData = {
info: 'typing_status',
partner_id: params.partnerID,
@@ -48,6 +48,7 @@ QUnit.module('Typing', {
};
var notification = [[false, 'mail.channel', params.channelID], typingData];
params.widget.call('bus_service', 'trigger', 'notification', [notification]);
+ await testUtils.nextMicrotaskTick();
};
this.createParent = function (params) {
@@ -72,7 +73,7 @@ QUnit.module('Typing', {
},
});
-QUnit.test('receive typing notification', function (assert) {
+QUnit.test('receive typing notification', async function (assert) {
assert.expect(4);
var parent = this.createParent({
@@ -82,22 +83,24 @@ QUnit.test('receive typing notification', function (assert) {
// when receiving an 'is typing' notification, fetch the list of
// members of this channel if we haven't done yet.
if (args.method === 'channel_fetch_listeners') {
- return $.when([
+ return Promise.resolve([
{ id: 42, name: "Someone" },
]);
}
return this._super.apply(this, arguments);
},
});
+ await testUtils.nextTick();
// detach channel 1, so that it opens corresponding thread window.
parent.call('mail_service', 'getChannel', 1).detach();
+ await testUtils.nextTick();
var $threadWindow = $('.o_thread_window');
assert.containsNone($threadWindow, '.o_mail_thread_typing_icon',
"should not display an icon that someone is typing something on this thread");
- this.simulateIsTyping({
+ await this.simulateIsTyping({
channelID: 1,
isTyping: true,
partnerID: 42,
@@ -110,7 +113,7 @@ QUnit.test('receive typing notification', function (assert) {
"Someone is typing...",
"should display someone is typing something on hover of this icon");
- this.simulateIsTyping({
+ await this.simulateIsTyping({
channelID: 1,
isTyping: false,
partnerID: 42,