diff options
| author | Martin Trigaux <mat@odoo.com> | 2019-07-24 07:36:59 +0000 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2019-07-24 10:32:23 +0000 |
| commit | a98427834e00380e2e63e08668f5c2b069e3c2ea (patch) | |
| tree | fbefd4a26124efbaf5e6b4bdbf58ec570014c896 /addons/mail/static/tests/thread_window/basic_thread_window_tests.js | |
| parent | 4e6ee3ac97041653ff15a77abd77084dc0c9f525 (diff) | |
| parent | 860ab5a1c28ba85d7a193d68cfbbb1063bbf0651 (diff) | |
[MERGE] Forward port of saas-12.2 to saas-12.3 up to 860ab5a1c28ba
closes odoo/odoo#35119
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
Diffstat (limited to 'addons/mail/static/tests/thread_window/basic_thread_window_tests.js')
| -rw-r--r-- | addons/mail/static/tests/thread_window/basic_thread_window_tests.js | 113 |
1 files changed, 113 insertions, 0 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 d5af9cf5357..7c3cfbdc793 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 @@ -726,6 +726,119 @@ QUnit.test('no out-of-office status in thread window', async function (assert) { parent.destroy(); }); +QUnit.test('auto-update out-of-office info on im_status change', async function (assert) { + assert.expect(5); + + var imStatusDefs = [testUtils.makeTestPromise(), testUtils.makeTestPromise()]; + var channelInfoDefs = [testUtils.makeTestPromise(), testUtils.makeTestPromise()]; + var timeoutMock = mailTestUtils.patchMailTimeouts(); + var step = 0; + + this.data = { + 'mail.message': { + fields: {}, + records: [], + }, + initMessaging: { + channel_slots: { + channel_channel: [{ + id: 1, + name: "DM", + channel_type: "chat", + message_unread_counter: 0, + direct_partner: [{ + id: 666, + name: 'DemoUser1', + im_status: 'online', + }], + }], + }, + }, + }; + + var parent = this.createParent({ + data: this.data, + services: this.services, + mockRPC: function (route, args) { + if (route === '/longpolling/im_status') { + step++; + if (step === 1) { + imStatusDefs[0].resolve(); + return Promise.resolve([ + { + id: 666, + im_status: 'leave', + }, + ]); + } else if (step === 2) { + imStatusDefs[1].resolve(); + return Promise.resolve([ + { + id: 666, + im_status: 'online', + }, + ]); + } + } + if (args.method === 'channel_info') { + if (step === 1) { + channelInfoDefs[0].resolve(); + return Promise.resolve([{ + id: 1, + direct_partner: [{ + out_of_office_message: "Leave me alone", + out_of_office_date_end: false, + }], + }]); + } + else if (step === 2) { + channelInfoDefs[1].resolve(); + return Promise.resolve([{ + id: 1, + direct_partner: [{ + out_of_office_message: false, + out_of_office_date_end: false, + }], + }]); + } + } + 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(); + + assert.containsNone($, '.o_out_of_office', + "should contain no out of office section on chat window initially"); + + timeoutMock.addTime(51*1000); // wait for next im status fetch + + await Promise.all([imStatusDefs[0], channelInfoDefs[0]]); + await testUtils.nextTick(); + assert.containsOnce($, '.o_out_of_office', + "should contain out of office section on chat window"); + assert.containsOnce($, '.o_out_of_office > .o_out_of_office_text', + "should contain out of office text on chat window"); + assert.ok( + $('.o_out_of_office > .o_out_of_office_text') + .text() + .replace(/\s/g, "") + .indexOf("Leavemealone") !== -1, + "should contain out of office text on chat window"); + timeoutMock.addTime(51*1000); // wait for next im status fetch + + await Promise.all([imStatusDefs[1], channelInfoDefs[1]]); + await testUtils.nextTick(); + assert.containsNone($, '.o_out_of_office', + "should no longer contain out of office section on chat window"); + + timeoutMock.runPendingTimeouts(); + parent.destroy(); +}); + }); }); }); |
