summaryrefslogtreecommitdiff
path: root/addons/mail/static/tests/thread_window/hidden_thread_window_tests.js
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-06-27 20:45:52 +0200
committerChristophe Simonis <chs@odoo.com>2019-06-27 20:45:52 +0200
commit5e81b18e24a358b3f4145168f88614a9be37ac14 (patch)
tree198950ff1118ddd91ad296a8d27b861bf6c21d76 /addons/mail/static/tests/thread_window/hidden_thread_window_tests.js
parentc3a609eae4ff5396c1814228d3fc75623ab21b49 (diff)
parent0247d2f35fdeebdb48e8eafc2ae69d1675158303 (diff)
[MERGE] forward port branch saas-12.3 up to 0247d2f35fd
Diffstat (limited to 'addons/mail/static/tests/thread_window/hidden_thread_window_tests.js')
-rw-r--r--addons/mail/static/tests/thread_window/hidden_thread_window_tests.js88
1 files changed, 88 insertions, 0 deletions
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 691e37df362..078230e276a 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
@@ -229,6 +229,94 @@ QUnit.test('hidden thread windows dropdown when not enough horizontal space (ver
testUtils.mock.unpatch(this.services.mail_service);
});
+QUnit.test('receive message from hidden thread window', 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.
+ // This case occurs when the amount of available slots depends on
+ // whether the hidden button should be displayed or not
+ // Example:
+ // - global width of 400px
+ // - button width of 100px
+ // - thread width of 250px
+ //
+ // Without button: 1 thread window (250px < 800px)
+ // With button: 1 thread window (250px + 100px = 350px < 400px)
+ assert.expect(7);
+
+ testUtils.patch(this.services.mail_service, {
+ HIDDEN_THREAD_WINDOW_DROPDOWN_BUTTON_WIDTH: 100,
+ THREAD_WINDOW_WIDTH: 250,
+ _getGlobalWidth: function () { return 400; },
+ });
+
+ var channels = [{
+ id: 1,
+ channel_type: 'channel',
+ name: "channel" + 1,
+ }, {
+ id: 2,
+ channel_type: 'channel',
+ name: "channel" + 2,
+ }];
+
+ this.data.initMessaging = {
+ channel_slots: {
+ channel_channel: channels,
+ },
+ };
+
+ var parent = this.createParent({
+ data: this.data,
+ services: this.services,
+ });
+ await testUtils.nextTick();
+
+ // detach channel 2 first, so that chanel 1 is open and channel 2 is hidden
+ parent.call('mail_service', 'getChannel', 2).detach();
+ parent.call('mail_service', 'getChannel', 1).detach();
+ await testUtils.nextTick();
+
+ var $visibleThreadWindows = $('.o_thread_window:not(.o_thread_window_dropdown, .o_hidden)');
+
+ assert.strictEqual($visibleThreadWindows.length, 1,
+ "should have 1 thread windows visible (as many as available slots)");
+ assert.strictEqual($visibleThreadWindows.filter('[data-thread-id="1"]').length, 1,
+ "the thread window with ID 1 should be visible");
+ assert.strictEqual($('.o_thread_window.o_hidden[data-thread-id="2"]').length, 1,
+ "the thread window with ID 2 should be hidden");
+ assert.strictEqual(
+ $('.o_thread_window_dropdown .o_total_unread_counter').text().trim(),
+ "",
+ "should have no unread counter on hidden dropup menu");
+
+ // simulate receiving a message in channel ID 2
+ var messageData = {
+ author_id: [5, "Someone else"],
+ body: "<p>Test message</p>",
+ id: 1,
+ model: 'mail.channel',
+ res_id: 2,
+ channel_ids: [2],
+ };
+ var notification = [[false, 'mail.channel', 2], messageData];
+ parent.call('bus_service', 'trigger', 'notification', [notification]);
+ await testUtils.nextTick();
+
+ $visibleThreadWindows = $('.o_thread_window:not(.o_thread_window_dropdown, .o_hidden)');
+ assert.strictEqual($visibleThreadWindows.filter('[data-thread-id="1"]').length, 1,
+ "the thread window with ID 1 should stay visible");
+ assert.strictEqual($('.o_thread_window.o_hidden[data-thread-id="2"]').length, 1,
+ "the thread window with ID 2 should stay hidden");
+ assert.strictEqual(
+ $('.o_thread_window_dropdown .o_total_unread_counter').text().trim(),
+ "1",
+ "should have unread counter of 1 on hidden dropup menu");
+
+ parent.destroy();
+ testUtils.unpatch(this.services.mail_service);
+});
+
});
});
});