diff --git a/addons/mail/static/src/js/discuss.js b/addons/mail/static/src/js/discuss.js index 483a1e99d29..fa4eb62256d 100644 --- a/addons/mail/static/src/js/discuss.js +++ b/addons/mail/static/src/js/discuss.js @@ -506,6 +506,7 @@ var Discuss = AbstractAction.extend({ */ _initRender: function () { var self = this; + this.$('.o_mail_discuss_loading').remove(); this._basicComposer = new BasicComposer(this, { mentionPartnersRestricted: true, showTyping: true, @@ -1420,7 +1421,6 @@ var Discuss = AbstractAction.extend({ if (!this._isStarted) { return; } - this.$('.o_mail_discuss_loading').remove(); this._initRender(); }, /** diff --git a/addons/mail/static/tests/discuss_tests.js b/addons/mail/static/tests/discuss_tests.js index 54477874f44..7b18996b831 100644 --- a/addons/mail/static/tests/discuss_tests.js +++ b/addons/mail/static/tests/discuss_tests.js @@ -1,9 +1,9 @@ odoo.define('mail.discuss_test', function (require) { "use strict"; +const Discuss = require('mail.Discuss'); var mailTestUtils = require('mail.testUtils'); -var concurrency = require('web.concurrency'); var testUtils = require('web.test_utils'); var createDiscuss = mailTestUtils.createDiscuss; @@ -165,6 +165,59 @@ QUnit.test('messaging not ready', async function (assert) { discuss.destroy(); }); +QUnit.test('messaging initially ready', async function (assert) { + assert.expect(7); + + const startDiscussProm = testUtils.makeTestPromise(); + + testUtils.mock.patch(Discuss, { + /** + * @override + */ + async start() { + const _super = this._super.bind(this, ...arguments); // due to limitation of class.js + assert.step('discuss:starting'); + await startDiscussProm; + assert.step('discuss:started'); + return _super(); + }, + }); + + const discussProm = createDiscuss({ + id: 1, + context: {}, + params: {}, + data: this.data, + services: this.services, + mockRPC(route) { + if (route === '/mail/init_messaging') { + assert.step(route); + } + return this._super(...arguments); + } + }); + await testUtils.nextTick(); + assert.verifySteps([ + '/mail/init_messaging', + 'discuss:starting', + ]); + + startDiscussProm.resolve(); + await testUtils.nextTick(); + assert.verifySteps(['discuss:started']); + const discuss = await discussProm; + assert.ok( + discuss.el, + "discuss should be rendered"); + assert.containsNone( + discuss, + '.o_mail_discuss_loading', + "should not display sidebar or content is loading (messaging is ready)"); + + testUtils.mock.unpatch(Discuss); + discuss.destroy(); +}); + QUnit.test('searchview options visibility', async function (assert) { assert.expect(5);