summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/components/chat_window_manager
diff options
context:
space:
mode:
authorXavier Dubuc <xdu@odoo.com>2020-10-02 09:42:58 +0000
committerXavier Dubuc <xdu@odoo.com>2020-10-06 13:06:04 +0000
commit9dbec7af98d5fe547b76d0cb7bc11348b60a5285 (patch)
tree1e0a44dc1fe91ee019c95b4727448308c698399f /addons/mail/static/src/components/chat_window_manager
parentbafb2dfa54ab2e06e1c56fdadf918139e62eaa91 (diff)
[IMP] mail: test new message separator in some edge cases
task-2348620 closes odoo/odoo#59279 X-original-commit: 53ed641a60e6d572a12d96406b64af5b55fe177e Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components/chat_window_manager')
-rw-r--r--addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js110
1 files changed, 110 insertions, 0 deletions
diff --git a/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js b/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js
index d29730626b0..1a261265dc7 100644
--- a/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js
+++ b/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js
@@ -1868,6 +1868,116 @@ QUnit.test('chat window does not fetch messages if hidden', async function (asse
);
});
+QUnit.test('new message separator is shown in a chat window of a chat on receiving new message', async function (assert) {
+ assert.expect(6);
+
+ this.data['res.partner'].records.push({ id: 10, name: "Demo" });
+ this.data['res.users'].records.push({
+ id: 42,
+ name: "Foreigner user",
+ partner_id: 10,
+ });
+ this.data['mail.channel'].records = [
+ {
+ id: 10,
+ channel_type: "chat",
+ is_minimized: true,
+ is_pinned: false,
+ members: [this.data.currentPartnerId, 10],
+ message_unread_counter: 0,
+ uuid: 'channel-10-uuid',
+ },
+ ];
+ await this.start({
+ mockRPC(route, args) {
+ if (args.method === 'channel_fold') {
+ const channel_uuid = args.kwargs.uuid;
+ assert.strictEqual(channel_uuid, 'channel-10-uuid', "chat window fold state should have been sent to server");
+ assert.step(`rpc:channel_fold:${channel_uuid}`);
+ }
+ return this._super(...arguments);
+ },
+ });
+
+ // simulate receiving a message
+ await afterNextRender(async () => this.env.services.rpc({
+ route: '/mail/chat_post',
+ params: {
+ context: {
+ mockedUserId: 42,
+ },
+ uuid: 'channel-10-uuid',
+ message_content: "hu",
+ },
+ }));
+ assert.containsOnce(
+ document.body,
+ '.o_ChatWindow',
+ "a chat window should be visible after receiving a new message from a chat"
+ );
+ assert.containsOnce(
+ document.body,
+ '.o_Message',
+ "chat window should have a single message (the newly received one)"
+ );
+ assert.containsOnce(
+ document.body,
+ '.o_MessageList_separatorNewMessages',
+ "should display 'new messages' separator in the conversation, from reception of new messages"
+ );
+ assert.verifySteps(
+ ['rpc:channel_fold:channel-10-uuid'],
+ "fold state of chat window of chat should have been updated to server"
+ );
+});
+
+QUnit.test('focusing a chat window of a chat should make new message separator disappear [REQUIRE FOCUS]', async function (assert) {
+ assert.expect(2);
+
+ this.data['res.partner'].records.push({ id: 10, name: "Demo" });
+ this.data['res.users'].records.push({
+ id: 42,
+ name: "Foreigner user",
+ partner_id: 10,
+ });
+ this.data['mail.channel'].records = [
+ {
+ id: 10,
+ channel_type: "chat",
+ is_minimized: true,
+ is_pinned: false,
+ members: [this.data.currentPartnerId, 10],
+ message_unread_counter: 0,
+ uuid: 'channel-10-uuid',
+ },
+ ];
+ await this.start();
+
+ // simulate receiving a message
+ await afterNextRender(async () => this.env.services.rpc({
+ route: '/mail/chat_post',
+ params: {
+ context: {
+ mockedUserId: 42,
+ },
+ uuid: 'channel-10-uuid',
+ message_content: "hu",
+ },
+ }));
+ assert.containsOnce(
+ document.body,
+ '.o_MessageList_separatorNewMessages',
+ "should display 'new messages' separator in the conversation, from reception of new messages"
+ );
+
+ await afterNextRender(() => document.querySelector('.o_ComposerTextInput_textarea').focus());
+ assert.containsNone(
+ document.body,
+ '.o_MessageList_separatorNewMessages',
+ "new message separator should no longer be shown, after focus on composer text input of chat window"
+ );
+});
+
});
});
});