@@ -261,7 +328,7 @@
-
+
diff --git a/addons/mail/static/tests/discuss_mobile_tests.js b/addons/mail/static/tests/discuss_mobile_tests.js
index 82bcad30fe0..a0b9383ea45 100644
--- a/addons/mail/static/tests/discuss_mobile_tests.js
+++ b/addons/mail/static/tests/discuss_mobile_tests.js
@@ -47,9 +47,9 @@ QUnit.test('mobile basic rendering', function (assert) {
"should be in inbox");
// move to DMs tab
- discuss.$('.o_mail_mobile_tab[data-type=dm]').click();
- assert.ok(discuss.$('.o_mail_mobile_tab[data-type=dm]').hasClass('active'),
- "should be in DMs tab");
+ discuss.$('.o_mail_mobile_tab[data-type=dm_chat]').click();
+ assert.ok(discuss.$('.o_mail_mobile_tab[data-type=dm_chat]').hasClass('active'),
+ "should be in DMs chat tab");
assert.strictEqual(discuss.$('.o_mail_discuss_content .o_mail_no_content').length, 0,
"should display the no content message");
$('.o_mail_discuss_button_dm').click(); // click to add a channel
diff --git a/addons/mail/static/tests/discuss_moderation_tests.js b/addons/mail/static/tests/discuss_moderation_tests.js
index e324decba8c..505cb22aed4 100644
--- a/addons/mail/static/tests/discuss_moderation_tests.js
+++ b/addons/mail/static/tests/discuss_moderation_tests.js
@@ -6,7 +6,7 @@ var mailTestUtils = require('mail.testUtils');
var createDiscuss = mailTestUtils.createDiscuss;
QUnit.module('mail', {}, function () {
-QUnit.module('Discuss moderation', {
+QUnit.module('Discuss (Moderation)', {
beforeEach: function () {
// patch _.debounce and _.throttle to be fast and synchronous
this.underscoreDebounce = _.debounce;
@@ -196,7 +196,7 @@ QUnit.test('moderator: moderated channel with pending moderation message', funct
assert.strictEqual($(moderateAllSelector + '[data-decision="accept"]').length, 1,
"there should one moderate button to accept messages pending moderation");
assert.strictEqual($(moderateAllSelector + '[data-decision="accept"]').attr('style'),
- 'display: none;', 'the moderate button "Accept" should be invisible by default');
+ 'display: none', 'the moderate button "Accept" should be invisible by default');
assert.strictEqual($(moderateAllSelector + '[data-decision="reject"]').length, 1,
"there should one moderate button to reject messages pending moderation");
assert.strictEqual($(moderateAllSelector + '[data-decision="reject"]').attr('style'),
@@ -217,11 +217,11 @@ QUnit.test('moderator: moderated channel with pending moderation message', funct
"the 'Unselect All' button should not be disabled");
// check moderate all buttons updated (visible)
assert.strictEqual($(moderateAllSelector + '[data-decision="accept"]').attr('style'),
- 'display: inline-block;', 'the moderate button "Accept" should become visible');
+ 'display: inline-block', 'the moderate button "Accept" should become visible');
assert.strictEqual($(moderateAllSelector + '[data-decision="reject"]').attr('style'),
- 'display: inline-block;', 'the moderate button "Reject" should become visible');
+ 'display: inline-block', 'the moderate button "Reject" should become visible');
assert.strictEqual($(moderateAllSelector + '[data-decision="discard"]').attr('style'),
- 'display: inline-block;', 'the moderate button "Discard" should become visible');
+ 'display: inline-block', 'the moderate button "Discard" should become visible');
// 2. go to channel 'general'
discuss.$('.o_mail_discuss_item[data-thread-id="1"]').click();
diff --git a/addons/mail/static/tests/discuss_tests.js b/addons/mail/static/tests/discuss_tests.js
index 57a8c00ab26..6f605d24680 100644
--- a/addons/mail/static/tests/discuss_tests.js
+++ b/addons/mail/static/tests/discuss_tests.js
@@ -11,7 +11,6 @@ var testUtils = require('web.test_utils');
var createDiscuss = mailTestUtils.createDiscuss;
QUnit.module('mail', {}, function () {
-
QUnit.module('Discuss', {
beforeEach: function () {
// patch _.debounce and _.throttle to be fast and synchronous
@@ -181,7 +180,7 @@ QUnit.test('@ mention in channel', function (assert) {
body: args.kwargs.body,
channel_ids: [1],
};
- var notification = [[false, 'mail.channel'], data];
+ var notification = [[false, 'mail.channel', 1], data];
objectDiscuss.call('bus_service', 'trigger', 'notification', [notification]);
receiveMessageDef.resolve();
return $.when(42);
@@ -204,7 +203,6 @@ QUnit.test('@ mention in channel', function (assert) {
var $input = discuss.$('textarea.o_composer_text_field').first();
assert.ok($input.length, "should display a composer input");
- // Simulate '@' typed by user with mocked Window.getSelection
// Note: focus is needed in order to trigger rpc 'channel_fetch_listeners'
$input.focus();
$input.val("@");
@@ -309,7 +307,6 @@ QUnit.test('@ mention in channel', function (assert) {
assert.strictEqual(discuss.$('.o_thread_message_content a').text(),
"@Admin", "should have correct mention link in the message content");
- // Restore window.getSelection
discuss.destroy();
done();
});
@@ -360,7 +357,7 @@ QUnit.test('no crash focusout emoji button', function (assert) {
});
QUnit.test('older messages are loaded on scroll', function (assert) {
- assert.expect(3);
+ assert.expect(10);
var done = assert.async();
var fetchCount = 0;
@@ -394,10 +391,15 @@ QUnit.test('older messages are loaded on scroll', function (assert) {
services: this.services,
mockRPC: function (route, args) {
if (args.method === 'message_fetch') {
+ assert.step(args.method);
fetchCount++;
// 1st fetch: inbox initial fetch
// 2nd fetch: general initial fetch
// 3rd fetch: general load more
+ if (fetchCount === 1) {
+ assert.strictEqual(args.kwargs.limit, 30,
+ "should ask to fetch 30 messages at most");
+ }
if (fetchCount === 3) {
loadMoreDef.resolve();
}
@@ -405,6 +407,10 @@ QUnit.test('older messages are loaded on scroll', function (assert) {
return this._super.apply(this, arguments);
},
}).then(function (discuss) {
+
+ assert.verifySteps(['message_fetch'],
+ "should fetch messages once for needaction messages (Inbox)");
+
var $general = discuss.$('.o_mail_discuss_item[data-thread-id=1]');
assert.strictEqual($general.length, 1,
"should have a channel item with id 1");
@@ -412,6 +418,9 @@ QUnit.test('older messages are loaded on scroll', function (assert) {
// switch to 'general'
$general.click();
+ assert.verifySteps(['message_fetch', 'message_fetch'],
+ "should fetch a second time for general channel messages (30 last messages)");
+
assert.strictEqual(discuss.$('.o_thread_message').length, 30,
"should display the 30 messages");
@@ -421,6 +430,8 @@ QUnit.test('older messages are loaded on scroll', function (assert) {
loadMoreDef
.then(concurrency.delay.bind(concurrency, 0))
.then(function () {
+ assert.verifySteps(['message_fetch', 'message_fetch', 'message_fetch'],
+ "should fetch a third time for general channel messages (5 remaining messages)");
assert.strictEqual(discuss.$('.o_thread_message').length, 35,
"all messages should now be loaded");
@@ -621,7 +632,6 @@ QUnit.test('confirm dialog when administrator leave (not chat) channel', functio
discuss.destroy();
done();
});
-
});
QUnit.test('convert emoji sources to unicodes on message_post', function (assert) {
@@ -657,7 +667,7 @@ QUnit.test('convert emoji sources to unicodes on message_post', function (assert
body: args.kwargs.body,
channel_ids: [1],
};
- var notification = [[false, 'mail.channel'], data];
+ var notification = [[false, 'mail.channel', 1], data];
objectDiscuss.call('bus_service', 'trigger', 'notification', [notification]);
receiveMessageDef.resolve();
return $.when(42);
@@ -691,6 +701,6 @@ QUnit.test('convert emoji sources to unicodes on message_post', function (assert
});
});
});
-});
});
+});
diff --git a/addons/mail/static/tests/document_thread_window_tests.js b/addons/mail/static/tests/document_thread_window_tests.js
index 14d50d593ba..ec6f97f0b49 100644
--- a/addons/mail/static/tests/document_thread_window_tests.js
+++ b/addons/mail/static/tests/document_thread_window_tests.js
@@ -8,7 +8,7 @@ var testUtils = require('web.test_utils');
QUnit.module('mail', {}, function () {
-QUnit.module('DocumentThreadWindow', {
+QUnit.module('ThreadWindow (Document Thread)', {
beforeEach: function () {
var partnerID = 44;
this.data = {
diff --git a/addons/mail/static/tests/helpers/mock_server.js b/addons/mail/static/tests/helpers/mock_server.js
index 16b588b07ec..cff4917465a 100644
--- a/addons/mail/static/tests/helpers/mock_server.js
+++ b/addons/mail/static/tests/helpers/mock_server.js
@@ -155,6 +155,9 @@ MockServer.include({
if (args.method === 'channel_fetch_preview') {
return $.when(this._mockChannelFetchPreview(args));
}
+ if (args.method === 'channel_minimize') {
+ return $.when();
+ }
if (args.method === 'channel_seen') {
return $.when();
}
@@ -173,7 +176,7 @@ MockServer.include({
if (args.method === 'moderate') {
return $.when(this._mockModerate(args));
}
- if (args.method === 'channel_minimize') {
+ if (args.method === 'set_message_done') {
return $.when();
}
return this._super(route, args);
diff --git a/addons/mail/static/tests/helpers/test_utils.js b/addons/mail/static/tests/helpers/test_utils.js
index a6b0b67a037..033866522e6 100644
--- a/addons/mail/static/tests/helpers/test_utils.js
+++ b/addons/mail/static/tests/helpers/test_utils.js
@@ -6,7 +6,6 @@ var BusService = require('bus.BusService');
var Discuss = require('mail.Discuss');
var MailService = require('mail.Service');
-var AbstractService = require('web.AbstractService');
var AbstractStorageService = require('web.AbstractStorageService');
var Class = require('web.Class');
var ControlPanel = require('web.ControlPanel');
@@ -67,6 +66,7 @@ var MockMailService = Class.extend({
return BusService.extend({
_poll: function () {}, // Do nothing
isOdooFocused: function () { return true; },
+ updateOption: function () {},
});
},
mail_service: function () {
diff --git a/addons/mail/static/tests/thread_window_tests.js b/addons/mail/static/tests/thread_window_tests.js
index a10bed3f1b0..d8faa8d6a37 100644
--- a/addons/mail/static/tests/thread_window_tests.js
+++ b/addons/mail/static/tests/thread_window_tests.js
@@ -8,9 +8,14 @@ var testUtils = require('web.test_utils');
var Widget = require('web.Widget');
QUnit.module('mail', {
- beforeEach: function () {
+ beforeEach: function (assert) {
var self = this;
+ this.BEFORE_EACH_ASSERTIONS_NUM = 1;
+
+ assert.strictEqual($('.o_thread_window').length, 0,
+ "should have no thread windows open before the test");
+
// define channel to link to chat window
this.data = {
'mail.message': {
@@ -34,6 +39,8 @@ QUnit.module('mail', {
var widget = new Widget();
// in non-debug mode, append thread windows in qunit-fixture
+ // note that it does not hide thread window because it uses fixed
+ // position, and qunit-fixture uses absolute...
if (params.debug) {
self.services.mail_service.prototype.THREAD_WINDOW_APPENDTO = 'body';
} else {
@@ -50,10 +57,9 @@ QUnit.module('mail', {
},
}, function () {
- QUnit.module('thread_window');
-
+ QUnit.module('ThreadWindow');
QUnit.test('close thread window using ESCAPE key', function (assert) {
- assert.expect(5);
+ assert.expect(5 + this.BEFORE_EACH_ASSERTIONS_NUM);
var parent = this.createParent({
data: this.data,
@@ -91,7 +97,7 @@ QUnit.module('mail', {
});
QUnit.test('thread window\'s input can still be focused when the UI is blocked', function (assert) {
- assert.expect(2);
+ assert.expect(2 + this.BEFORE_EACH_ASSERTIONS_NUM);
var parent = this.createParent({
data: this.data,
@@ -124,7 +130,7 @@ QUnit.module('mail', {
});
QUnit.test('emoji popover should open correctly in thread windows', function (assert) {
- assert.expect(1);
+ assert.expect(1 + this.BEFORE_EACH_ASSERTIONS_NUM);
var parent = this.createParent({
data: this.data,
@@ -147,5 +153,6 @@ QUnit.module('mail', {
done();
}, 0);
});
+
});
});
diff --git a/addons/mail/views/mail_templates.xml b/addons/mail/views/mail_templates.xml
index 36899afcdb2..bda7c071a0c 100644
--- a/addons/mail/views/mail_templates.xml
+++ b/addons/mail/views/mail_templates.xml
@@ -24,13 +24,17 @@
-
+
+
+
+
-
+
+
+
-