[FIX] mail: fix new message chatwindow issue
Current behavior before PR: When looking for a user through the new message chat window, if there is already a chat open for this user, the new message window is still open on selecting the user. Desired behavior after PR is merged: when opening a chat from a new message, if the chat with this user is already open then it will close the new message chat window on selecting the user. LINKS: PR https://github.com/odoo/odoo/pull/65851 Task-2449118 closes odoo/odoo#66085 X-original-commit: 016dedf172f750a0fcb1138a798faf2a224d513e Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
@@ -378,6 +378,61 @@ QUnit.test('open chat from "new message" chat window should open chat in place o
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('new message chat window should close on selecting the user if chat with the user is already open', async function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
this.data['res.partner'].records.push({ id: 131, name: "Partner 131"});
|
||||
this.data['res.users'].records.push({ id: 12, partner_id: 131 });
|
||||
this.data['mail.channel'].records.push({
|
||||
channel_type: "chat",
|
||||
id: 20,
|
||||
is_minimized: true,
|
||||
members: [this.data.currentPartnerId, 131],
|
||||
name: "Partner 131",
|
||||
public: 'private',
|
||||
state: 'open',
|
||||
});
|
||||
const imSearchDef = makeDeferred();
|
||||
await this.start({
|
||||
async mockRPC(route, args) {
|
||||
const res = await this._super(...arguments);
|
||||
if (args.method === 'im_search') {
|
||||
imSearchDef.resolve();
|
||||
}
|
||||
return res;
|
||||
},
|
||||
});
|
||||
|
||||
// open "new message" chat window
|
||||
await afterNextRender(() => document.querySelector(`.o_MessagingMenu_toggler`).click());
|
||||
await afterNextRender(() => document.querySelector(`.o_MessagingMenu_newMessageButton`).click());
|
||||
|
||||
// search for a user in "new message" autocomplete
|
||||
document.execCommand('insertText', false, "131");
|
||||
document.querySelector(`.o_ChatWindow_newMessageFormInput`)
|
||||
.dispatchEvent(new window.KeyboardEvent('keydown'));
|
||||
document.querySelector(`.o_ChatWindow_newMessageFormInput`)
|
||||
.dispatchEvent(new window.KeyboardEvent('keyup'));
|
||||
// Wait for search RPC to be resolved. The following await lines are
|
||||
// necessary because autocomplete is an external lib therefore it is not
|
||||
// possible to use `afterNextRender`.
|
||||
await imSearchDef;
|
||||
await nextAnimationFrame();
|
||||
const link = document.querySelector('.ui-autocomplete .ui-menu-item a');
|
||||
|
||||
await afterNextRender(() => link.click());
|
||||
assert.containsNone(
|
||||
document.body,
|
||||
'.o_ChatWindow_newMessageFormInput',
|
||||
"'new message' chat window should not be there"
|
||||
);
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_ChatWindow',
|
||||
"should have only one chat window after selecting user whose chat is already open",
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('new message autocomplete should automatically select first result', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
|
||||
@@ -455,7 +455,10 @@ function factory(dependencies) {
|
||||
}),
|
||||
newMessageChatWindow: one2one('mail.chat_window', {
|
||||
compute: '_computeNewMessageChatWindow',
|
||||
dependencies: ['allOrderedThread'],
|
||||
dependencies: [
|
||||
'allOrdered',
|
||||
'allOrderedThread',
|
||||
],
|
||||
}),
|
||||
unreadHiddenConversationAmount: attr({
|
||||
compute: '_computeUnreadHiddenConversationAmount',
|
||||
|
||||
Reference in New Issue
Block a user