From af26c704697df86b98dd9d03b7edba7302342b64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Tue, 24 Sep 2019 08:21:24 +0000 Subject: [PATCH] [FIX] mail: remove "Please wait..." in Discuss when ready MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Revision on https://github.com/odoo/odoo/commit/9a66619db33fca5f0cb81d9f6bfeb0fb0290cf68 Commit above improved webclient loading by not having to wait for the RPC `/mail/init_messaging`. It introduced an issue in which Discuss app was indefinitely showing "Please wait...". This commit fixes this issue. closes odoo/odoo#37337 Signed-off-by: Alexandre Kühn (aku) --- addons/mail/static/src/js/discuss.js | 2 +- addons/mail/static/tests/discuss_tests.js | 55 ++++++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) 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);