[IMP] mail, *: access messaging without env in tests

* = hr_holidays, im_livechat

Part of task-2582313
This commit is contained in:
Sébastien Theys
2021-08-18 14:56:50 +00:00
parent 97a8d725e4
commit 876e7ec581
17 changed files with 112 additions and 107 deletions
@@ -72,7 +72,7 @@ QUnit.test('out of office message on direct chat with out of office partner', as
"should have an out of office alert on thread view"
);
const formattedDate = returningDate.toDate().toLocaleDateString(
this.env.messaging.locale.language.replace(/_/g, '-'),
this.messaging.locale.language.replace(/_/g, '-'),
{ day: 'numeric', month: 'short' }
);
assert.ok(
@@ -67,8 +67,8 @@ QUnit.test('livechat: public website visitor is typing', async function (assert)
const typingData = {
info: 'typing_status',
is_typing: true,
partner_id: this.env.messaging.publicPartners[0].id,
partner_name: this.env.messaging.publicPartners[0].name,
partner_id: this.messaging.publicPartners[0].id,
partner_name: this.messaging.publicPartners[0].name,
};
const notification = [[false, 'mail.channel', 20], typingData];
this.widget.call('bus_service', 'trigger', 'notification', [notification]);
@@ -63,8 +63,8 @@ QUnit.test('receive visitor typing status "is typing"', async function (assert)
const typingData = {
info: 'typing_status',
is_typing: true,
partner_id: this.env.messaging.publicPartners[0].id,
partner_name: this.env.messaging.publicPartners[0].name,
partner_id: this.messaging.publicPartners[0].id,
partner_name: this.messaging.publicPartners[0].name,
};
const notification = [[false, 'mail.channel', 20], typingData];
this.widget.call('bus_service', 'trigger', 'notification', [notification]);
@@ -947,10 +947,10 @@ QUnit.test('chat window: composer state conservation on toggle discuss', async f
"composer should have 2 total attachments after adding 2 attachments"
);
await afterNextRender(() => this.env.messaging.discuss.update({ isOpen: true }));
await afterNextRender(() => this.messaging.discuss.update({ isOpen: true }));
assert.containsNone(document.body, '.o_ChatWindow', "should not have any chat window after opening discuss");
await afterNextRender(() => this.env.messaging.discuss.update({ isOpen: false }));
await afterNextRender(() => this.messaging.discuss.update({ isOpen: false }));
assert.strictEqual(
document.querySelector(`.o_ComposerTextInput_textarea`).value,
"XDU for the win !",
@@ -1008,12 +1008,12 @@ QUnit.test('chat window: scroll conservation on toggle discuss', async function
},
});
await afterNextRender(() => this.env.messaging.discuss.update({ isOpen: true }));
await afterNextRender(() => this.messaging.discuss.update({ isOpen: true }));
assert.containsNone(document.body, '.o_ChatWindow', "should not have any chat window after opening discuss");
await this.afterEvent({
eventName: 'o-component-message-list-scrolled',
func: () => this.env.messaging.discuss.update({ isOpen: false }),
func: () => this.messaging.discuss.update({ isOpen: false }),
message: "should wait until channel 20 restored its scroll to 142 after closing discuss",
predicate: ({ scrollTop, thread }) => {
return (
@@ -1932,10 +1932,10 @@ QUnit.test('chat window: composer state conservation on toggle discuss when fold
// fold chat window
await afterNextRender(() => document.querySelector('.o_ChatWindow_header').click());
await afterNextRender(() => this.env.messaging.discuss.update({ isOpen: true }));
await afterNextRender(() => this.messaging.discuss.update({ isOpen: true }));
assert.containsNone(document.body, '.o_ChatWindow', "should not have any chat window after opening discuss");
await afterNextRender(() => this.env.messaging.discuss.update({ isOpen: false }));
await afterNextRender(() => this.messaging.discuss.update({ isOpen: false }));
// unfold chat window
await afterNextRender(() => document.querySelector('.o_ChatWindow_header').click());
assert.strictEqual(
@@ -1996,10 +1996,10 @@ QUnit.test('chat window with a thread: keep scroll position in message list on t
});
// fold chat window
await afterNextRender(() => document.querySelector('.o_ChatWindow_header').click());
await afterNextRender(() => this.env.messaging.discuss.update({ isOpen: true }));
await afterNextRender(() => this.messaging.discuss.update({ isOpen: true }));
assert.containsNone(document.body, '.o_ChatWindow', "should not have any chat window after opening discuss");
await afterNextRender(() => this.env.messaging.discuss.update({ isOpen: false }));
await afterNextRender(() => this.messaging.discuss.update({ isOpen: false }));
// unfold chat window
await this.afterEvent({
eventName: 'o-component-message-list-scrolled',
@@ -38,7 +38,7 @@ QUnit.test('sidebar: pinned channel 1: init with one pinned channel', async func
await this.start();
assert.containsOnce(
document.body,
`.o_Discuss_thread[data-thread-local-id="${this.env.messaging.inbox.localId}"]`,
`.o_Discuss_thread[data-thread-local-id="${this.messaging.inbox.localId}"]`,
"The Inbox is opened in discuss"
);
assert.containsOnce(
@@ -148,7 +148,7 @@ QUnit.test('sidebar: unpin channel from bus', async function (assert) {
assert.containsOnce(
document.body,
`.o_Discuss_thread[data-thread-local-id="${this.env.messaging.inbox.localId}"]`,
`.o_Discuss_thread[data-thread-local-id="${this.messaging.inbox.localId}"]`,
"The Inbox is opened in discuss"
);
assert.containsOnce(
@@ -172,7 +172,7 @@ QUnit.test('sidebar: unpin channel from bus', async function (assert) {
// (e.g. from user interaction from another device or browser tab)
await afterNextRender(() => {
const notif = [
["dbName", 'res.partner', this.env.messaging.currentPartner.id],
["dbName", 'res.partner', this.messaging.currentPartner.id],
{
channel_type: 'channel',
id: 20,
@@ -144,7 +144,7 @@ QUnit.test('basic rendering: sidebar', async function (assert) {
document.querySelectorAll(`
.o_DiscussSidebar_groupMailbox
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
`).length,
1,
@@ -154,7 +154,7 @@ QUnit.test('basic rendering: sidebar', async function (assert) {
document.querySelectorAll(`
.o_DiscussSidebar_groupMailbox
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
`).length,
1,
@@ -164,7 +164,7 @@ QUnit.test('basic rendering: sidebar', async function (assert) {
document.querySelectorAll(`
.o_DiscussSidebar_groupMailbox
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.history.localId
this.messaging.history.localId
}"]
`).length,
1,
@@ -250,7 +250,7 @@ QUnit.test('sidebar: basic mailbox rendering', async function (assert) {
const inbox = document.querySelector(`
.o_DiscussSidebar_groupMailbox
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
`);
assert.strictEqual(
@@ -281,7 +281,7 @@ QUnit.test('sidebar: basic mailbox rendering', async function (assert) {
assert.strictEqual(
document.querySelectorAll(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
.o_DiscussSidebarItem_counter
`).length,
@@ -297,7 +297,7 @@ QUnit.test('sidebar: default active inbox', async function (assert) {
const inbox = document.querySelector(`
.o_DiscussSidebar_groupMailbox
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
`);
assert.ok(
@@ -315,7 +315,7 @@ QUnit.test('sidebar: change item', async function (assert) {
assert.ok(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
.o_DiscussSidebarItem_activeIndicator
`).classList.contains('o-item-active'),
@@ -324,7 +324,7 @@ QUnit.test('sidebar: change item', async function (assert) {
assert.notOk(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
.o_DiscussSidebarItem_activeIndicator
`).classList.contains('o-item-active'),
@@ -334,14 +334,14 @@ QUnit.test('sidebar: change item', async function (assert) {
await afterNextRender(() =>
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
`).click()
);
assert.notOk(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
.o_DiscussSidebarItem_activeIndicator
`).classList.contains('o-item-active'),
@@ -350,7 +350,7 @@ QUnit.test('sidebar: change item', async function (assert) {
assert.ok(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
.o_DiscussSidebarItem_activeIndicator
`).classList.contains('o-item-active'),
@@ -366,7 +366,7 @@ QUnit.test('sidebar: inbox with counter', async function (assert) {
assert.strictEqual(
document.querySelectorAll(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
.o_DiscussSidebarItem_counter
`).length,
@@ -376,7 +376,7 @@ QUnit.test('sidebar: inbox with counter', async function (assert) {
assert.strictEqual(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
.o_DiscussSidebarItem_counter
`).textContent,
@@ -955,7 +955,7 @@ QUnit.test('default thread rendering', async function (assert) {
assert.strictEqual(
document.querySelectorAll(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
`).length,
1,
@@ -964,7 +964,7 @@ QUnit.test('default thread rendering', async function (assert) {
assert.strictEqual(
document.querySelectorAll(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
`).length,
1,
@@ -973,7 +973,7 @@ QUnit.test('default thread rendering', async function (assert) {
assert.strictEqual(
document.querySelectorAll(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.history.localId
this.messaging.history.localId
}"]
`).length,
1,
@@ -994,7 +994,7 @@ QUnit.test('default thread rendering', async function (assert) {
assert.ok(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
`).classList.contains('o-active'),
"inbox mailbox should be active thread"
@@ -1016,14 +1016,14 @@ QUnit.test('default thread rendering', async function (assert) {
await afterNextRender(() =>
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
`).click()
);
assert.ok(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
`).classList.contains('o-active'),
"starred mailbox should be active thread"
@@ -1045,14 +1045,14 @@ QUnit.test('default thread rendering', async function (assert) {
await afterNextRender(() =>
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.history.localId
this.messaging.history.localId
}"]
`).click()
);
assert.ok(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.history.localId
this.messaging.history.localId
}"]
`).classList.contains('o-active'),
"history mailbox should be active thread"
@@ -1142,7 +1142,7 @@ QUnit.test('default select thread in discuss params', async function (assert) {
assert.ok(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
.o_DiscussSidebarItem_activeIndicator
`).classList.contains('o-item-active'),
@@ -1163,7 +1163,7 @@ QUnit.test('auto-select thread in discuss context', async function (assert) {
assert.ok(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
.o_DiscussSidebarItem_activeIndicator
`).classList.contains('o-item-active'),
@@ -2323,7 +2323,7 @@ QUnit.test('basic top bar rendering', async function (assert) {
await afterNextRender(() =>
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
`).click()
);
@@ -2412,7 +2412,7 @@ QUnit.test('inbox: mark all messages as read', async function (assert) {
assert.strictEqual(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
.o_DiscussSidebarItem_counter
`).textContent,
@@ -2447,7 +2447,7 @@ QUnit.test('inbox: mark all messages as read', async function (assert) {
assert.strictEqual(
document.querySelectorAll(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
.o_DiscussSidebarItem_counter
`).length,
@@ -2497,7 +2497,7 @@ QUnit.test('starred: unstar all', async function (assert) {
assert.strictEqual(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
.o_DiscussSidebarItem_counter
`).textContent,
@@ -2519,7 +2519,7 @@ QUnit.test('starred: unstar all', async function (assert) {
assert.strictEqual(
document.querySelectorAll(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
.o_DiscussSidebarItem_counter
`).length,
@@ -2571,7 +2571,7 @@ QUnit.test('toggle_star message', async function (assert) {
assert.strictEqual(
document.querySelectorAll(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
.o_DiscussSidebarItem_counter
`).length,
@@ -2599,7 +2599,7 @@ QUnit.test('toggle_star message', async function (assert) {
assert.strictEqual(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
.o_DiscussSidebarItem_counter
`).textContent,
@@ -2622,7 +2622,7 @@ QUnit.test('toggle_star message', async function (assert) {
assert.strictEqual(
document.querySelectorAll(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.starred.localId
this.messaging.starred.localId
}"]
.o_DiscussSidebarItem_counter
`).length,
@@ -3109,7 +3109,7 @@ QUnit.test('receive new needaction messages', async function (assert) {
assert.ok(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
`),
"should have inbox in sidebar"
@@ -3117,7 +3117,7 @@ QUnit.test('receive new needaction messages', async function (assert) {
assert.ok(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
`).classList.contains('o-active'),
"inbox should be current discuss thread"
@@ -3125,7 +3125,7 @@ QUnit.test('receive new needaction messages', async function (assert) {
assert.notOk(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
.o_DiscussSidebarItem_counter
`),
@@ -3152,7 +3152,7 @@ QUnit.test('receive new needaction messages', async function (assert) {
assert.ok(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
.o_DiscussSidebarItem_counter
`),
@@ -3161,7 +3161,7 @@ QUnit.test('receive new needaction messages', async function (assert) {
assert.strictEqual(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
.o_DiscussSidebarItem_counter
`).textContent,
@@ -3194,7 +3194,7 @@ QUnit.test('receive new needaction messages', async function (assert) {
assert.strictEqual(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
.o_DiscussSidebarItem_counter
`).textContent,
@@ -3404,7 +3404,7 @@ QUnit.test('messages marked as read move to "History" mailbox', async function (
assert.ok(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.history.localId
this.messaging.history.localId
}"]
`).classList.contains('o-active'),
"history mailbox should be active thread"
@@ -3418,14 +3418,14 @@ QUnit.test('messages marked as read move to "History" mailbox', async function (
await afterNextRender(() =>
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
`).click()
);
assert.ok(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
`).classList.contains('o-active'),
"inbox mailbox should be active thread"
@@ -3447,7 +3447,7 @@ QUnit.test('messages marked as read move to "History" mailbox', async function (
assert.ok(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
`).classList.contains('o-active'),
"inbox mailbox should still be active after mark as read"
@@ -3461,14 +3461,14 @@ QUnit.test('messages marked as read move to "History" mailbox', async function (
await afterNextRender(() =>
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.history.localId
this.messaging.history.localId
}"]
`).click()
);
assert.ok(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.history.localId
this.messaging.history.localId
}"]
`).classList.contains('o-active'),
"history mailbox should be active"
@@ -3522,7 +3522,7 @@ QUnit.test('mark a single message as read should only move this message to "Hist
assert.hasClass(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.history.localId
this.messaging.history.localId
}"]
`),
'o-active',
@@ -3537,14 +3537,14 @@ QUnit.test('mark a single message as read should only move this message to "Hist
await afterNextRender(() =>
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
`).click()
);
assert.hasClass(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]
`),
'o-active',
@@ -3580,14 +3580,14 @@ QUnit.test('mark a single message as read should only move this message to "Hist
await afterNextRender(() =>
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.history.localId
this.messaging.history.localId
}"]
`).click()
);
assert.hasClass(
document.querySelector(`
.o_DiscussSidebar_item[data-thread-local-id="${
this.env.messaging.history.localId
this.messaging.history.localId
}"]
`),
'o-active',
@@ -3659,7 +3659,7 @@ QUnit.test('all messages in "Inbox" in "History" after marked all as read', asyn
func: () => {
document.querySelector(`
.o_DiscussSidebarItem[data-thread-local-id="${
this.env.messaging.history.localId
this.messaging.history.localId
}"]
`).click();
},
@@ -62,20 +62,20 @@ QUnit.test('select another mailbox', async function (assert) {
);
assert.strictEqual(
document.querySelector('.o_Discuss_thread').dataset.threadLocalId,
this.env.messaging.inbox.localId,
this.messaging.inbox.localId,
"inbox mailbox should be opened initially"
);
assert.containsOnce(
document.body,
`.o_DiscussMobileMailboxSelection_button[
data-mailbox-local-id="${this.env.messaging.starred.localId}"
data-mailbox-local-id="${this.messaging.starred.localId}"
]`,
"should have a button to open starred mailbox"
);
await afterNextRender(() =>
document.querySelector(`.o_DiscussMobileMailboxSelection_button[
data-mailbox-local-id="${this.env.messaging.starred.localId}"]
data-mailbox-local-id="${this.messaging.starred.localId}"]
`).click()
);
assert.containsOnce(
@@ -85,7 +85,7 @@ QUnit.test('select another mailbox', async function (assert) {
);
assert.strictEqual(
document.querySelector('.o_Discuss_thread').dataset.threadLocalId,
this.env.messaging.starred.localId,
this.messaging.starred.localId,
"starred mailbox should be opened after clicking on it"
);
});
@@ -115,7 +115,7 @@ QUnit.test('auto-select "Inbox" when discuss had channel as active thread', asyn
);
assert.hasClass(
document.querySelector(`.o_DiscussMobileMailboxSelection_button[data-mailbox-local-id="${
this.env.messaging.inbox.localId
this.messaging.inbox.localId
}"]`),
'o-active',
"'Inbox' mailbox should be auto-selected after click on mailbox tab"
@@ -176,7 +176,7 @@ QUnit.test('click on partner follower details', async function (assert) {
isEditable: true,
partner: insert({
email: "bla@bla.bla",
id: this.env.messaging.currentPartner.id,
id: this.messaging.currentPartner.id,
name: "François Perusse",
}),
});
@@ -282,7 +282,7 @@ QUnit.test('edit follower and close subtype dialog', async function (assert) {
isEditable: true,
partner: insert({
email: "bla@bla.bla",
id: this.env.messaging.currentPartner.id,
id: this.messaging.currentPartner.id,
name: "François Perusse",
}),
});
@@ -240,7 +240,7 @@ QUnit.test('click on remove follower', async function (assert) {
assert.step('message_unsubscribe');
assert.deepEqual(
args.args,
[[100], [self.env.messaging.currentPartner.id]],
[[100], [self.messaging.currentPartner.id]],
"message_unsubscribe should be called with right argument"
);
}
@@ -258,7 +258,7 @@ QUnit.test('click on remove follower', async function (assert) {
isEditable: true,
partner: insert({
email: "bla@bla.bla",
id: this.env.messaging.currentPartner.id,
id: this.messaging.currentPartner.id,
name: "François Perusse",
}),
});
@@ -285,7 +285,7 @@ QUnit.test("'channel_fetch' notification received is correctly handled", async f
});
await this.start();
const currentPartner = this.env.models['mail.partner'].insert({
id: this.env.messaging.currentPartner.id,
id: this.messaging.currentPartner.id,
display_name: "Demo User",
});
const thread = this.env.models['mail.thread'].findFromIdentifyingData({
@@ -351,7 +351,7 @@ QUnit.test("'channel_seen' notification received is correctly handled", async fu
});
await this.start();
const currentPartner = this.env.models['mail.partner'].insert({
id: this.env.messaging.currentPartner.id,
id: this.messaging.currentPartner.id,
display_name: "Demo User",
});
const thread = this.env.models['mail.thread'].findFromIdentifyingData({
@@ -416,7 +416,7 @@ QUnit.test("'channel_fetch' notification then 'channel_seen' received are corre
});
await this.start();
const currentPartner = this.env.models['mail.partner'].insert({
id: this.env.messaging.currentPartner.id,
id: this.messaging.currentPartner.id,
display_name: "Demo User",
});
const thread = this.env.models['mail.thread'].findFromIdentifyingData({
@@ -499,7 +499,7 @@ QUnit.test('do not show messaging seen indicator if not authored by me', async f
{
channelId: 11,
lastFetchedMessage: insert({ id: 100 }),
partnerId: this.env.messaging.currentPartner.id,
partnerId: this.messaging.currentPartner.id,
},
{
channelId: 11,
@@ -538,7 +538,7 @@ QUnit.test('do not show messaging seen indicator if before last seen by all mess
await this.start();
const currentPartner = this.env.models['mail.partner'].insert({
id: this.env.messaging.currentPartner.id,
id: this.messaging.currentPartner.id,
display_name: "Demo User",
});
const thread = this.env.models['mail.thread'].create({
@@ -570,7 +570,7 @@ QUnit.test('do not show messaging seen indicator if before last seen by all mess
{
channelId: 11,
lastSeenMessage: link(lastSeenMessage),
partnerId: this.env.messaging.currentPartner.id,
partnerId: this.messaging.currentPartner.id,
},
{
channelId: 11,
@@ -604,7 +604,7 @@ QUnit.test('only show messaging seen indicator if authored by me, after last see
await this.start();
const currentPartner = this.env.models['mail.partner'].insert({
id: this.env.messaging.currentPartner.id,
id: this.messaging.currentPartner.id,
display_name: "Demo User"
});
const thread = this.env.models['mail.thread'].create({
@@ -614,7 +614,7 @@ QUnit.test('only show messaging seen indicator if authored by me, after last see
{
channelId: 11,
lastSeenMessage: insert({ id: 100 }),
partnerId: this.env.messaging.currentPartner.id,
partnerId: this.messaging.currentPartner.id,
},
{
channelId: 11,
@@ -671,7 +671,7 @@ QUnit.test('allow attachment delete on authored message', async function (assert
id: 10,
name: "BLAH",
}),
author: link(this.env.messaging.currentPartner),
author: link(this.messaging.currentPartner),
body: "<p>Test</p>",
id: 100,
});
@@ -63,7 +63,7 @@ QUnit.test('rendering when just one has received the message', async function (a
}),
});
const message = this.env.models['mail.message'].insert({
author: insert({ id: this.env.messaging.currentPartner.id, display_name: "Demo User" }),
author: insert({ id: this.messaging.currentPartner.id, display_name: "Demo User" }),
body: "<p>Test</p>",
id: 100,
originThread: link(thread),
@@ -111,7 +111,7 @@ QUnit.test('rendering when everyone have received the message', async function (
}),
});
const message = this.env.models['mail.message'].insert({
author: insert({ id: this.env.messaging.currentPartner.id, display_name: "Demo User" }),
author: insert({ id: this.messaging.currentPartner.id, display_name: "Demo User" }),
body: "<p>Test</p>",
id: 100,
originThread: link(thread),
@@ -160,7 +160,7 @@ QUnit.test('rendering when just one has seen the message', async function (asser
}),
});
const message = this.env.models['mail.message'].insert({
author: insert({ id: this.env.messaging.currentPartner.id, display_name: "Demo User" }),
author: insert({ id: this.messaging.currentPartner.id, display_name: "Demo User" }),
body: "<p>Test</p>",
id: 100,
originThread: link(thread),
@@ -209,7 +209,7 @@ QUnit.test('rendering when just one has seen & received the message', async func
}),
});
const message = this.env.models['mail.message'].insert({
author: insert({ id: this.env.messaging.currentPartner.id, display_name: "Demo User" }),
author: insert({ id: this.messaging.currentPartner.id, display_name: "Demo User" }),
body: "<p>Test</p>",
id: 100,
originThread: link(thread),
@@ -260,7 +260,7 @@ QUnit.test('rendering when just everyone has seen the message', async function (
}),
});
const message = this.env.models['mail.message'].insert({
author: insert({ id: this.env.messaging.currentPartner.id, display_name: "Demo User" }),
author: insert({ id: this.messaging.currentPartner.id, display_name: "Demo User" }),
body: "<p>Test</p>",
id: 100,
originThread: link(thread),
@@ -86,9 +86,9 @@ QUnit.test('create', async function (assert) {
}))
);
// from partnerId being in needaction_partner_ids
assert.ok(message.threads.includes(this.env.messaging.inbox));
assert.ok(message.threads.includes(this.messaging.inbox));
// from partnerId being in starred_partner_ids
assert.ok(message.threads.includes(this.env.messaging.starred));
assert.ok(message.threads.includes(this.messaging.starred));
const attachment = this.env.models['mail.attachment'].findFromIdentifyingData({ id: 750 });
assert.ok(attachment);
assert.strictEqual(attachment.filename, "test.txt");
@@ -44,7 +44,7 @@ QUnit.test('openChat: display notification for partner without user', async func
},
});
await this.env.messaging.openChat({ partnerId: 14 });
await this.messaging.openChat({ partnerId: 14 });
});
QUnit.test('openChat: display notification for wrong user', async function (assert) {
@@ -69,7 +69,7 @@ QUnit.test('openChat: display notification for wrong user', async function (asse
});
// user id not in this.data
await this.env.messaging.openChat({ userId: 14 });
await this.messaging.openChat({ userId: 14 });
});
QUnit.test('openChat: open new chat for user', async function (assert) {
@@ -88,7 +88,7 @@ QUnit.test('openChat: open new chat for user', async function (assert) {
);
assert.notOk(existingChat, 'a chat should not exist with the target partner initially');
await this.env.messaging.openChat({ partnerId: 14 });
await this.messaging.openChat({ partnerId: 14 });
const chat = this.env.models['mail.thread'].find(thread =>
thread.channel_type === 'chat' &&
thread.correspondent &&
@@ -122,7 +122,7 @@ QUnit.test('openChat: open existing chat for user', async function (assert) {
assert.ok(existingChat, 'a chat should initially exist with the target partner');
assert.strictEqual(existingChat.threadViews.length, 0, 'the chat should not be displayed in a `mail.thread_view`');
await this.env.messaging.openChat({ partnerId: 14 });
await this.messaging.openChat({ partnerId: 14 });
assert.ok(existingChat, 'a chat should still exist with the target partner');
assert.strictEqual(existingChat.id, 10, 'the chat should be the existing chat');
assert.strictEqual(existingChat.threadViews.length, 1, 'the chat should now be displayed in a `mail.thread_view`');
@@ -30,7 +30,7 @@ QUnit.test('messaging menu counter should ignore unread messages in channels tha
serverMessageUnreadCounter: 1,
});
assert.strictEqual(
this.env.messaging.messagingMenu.counter,
this.messaging.messagingMenu.counter,
0,
"messaging menu counter should ignore unread messages in channels that are unpinned"
);
@@ -27,8 +27,8 @@ QUnit.test('inbox & starred mailboxes', async function (assert) {
assert.expect(10);
await this.start();
const mailboxInbox = this.env.messaging.inbox;
const mailboxStarred = this.env.messaging.starred;
const mailboxInbox = this.messaging.inbox;
const mailboxStarred = this.messaging.starred;
assert.ok(mailboxInbox, "should have mailbox inbox");
assert.ok(mailboxStarred, "should have mailbox starred");
assert.strictEqual(mailboxInbox.model, 'mail.box');
@@ -11,6 +11,7 @@ export default AbstractService.extend({
*/
init() {
this._super(...arguments);
this.messaging = undefined;
this._modelManager = new ModelManager(this.env);
this.env.modelManager = this._modelManager;
},
@@ -44,8 +45,9 @@ export default AbstractService.extend({
*/
await this.env.session.is_bound;
await this.startModelManager();
this.messaging = this._modelManager.messaging;
this.env.messagingCreatedPromise.resolve();
await this.env.messaging.start();
await this.messaging.start();
},
/**
* Starts the model manager.
+12 -9
View File
@@ -322,6 +322,15 @@ function beforeEach(self) {
unpatch,
widget: undefined
});
Object.defineProperty(self, 'messaging', {
get() {
if (!this.env || !this.env.services.messaging) {
return undefined;
}
return this.env.services.messaging.messaging;
},
});
}
function afterEach(self) {
@@ -336,6 +345,9 @@ function afterEach(self) {
self.widget.destroy();
self.widget = undefined;
}
if (self.messaging) {
self.messaging.delete();
}
self.env = undefined;
self.unpatch();
}
@@ -591,9 +603,6 @@ async function start(param0 = {}) {
destroyCallbacks.forEach(callback => callback({ widget }));
this._super(...arguments);
legacyUnpatch(widget);
if (testEnv && testEnv.modelManager.messaging) {
testEnv.modelManager.messaging.delete();
}
}
});
} else if (hasWebClient) {
@@ -642,9 +651,6 @@ async function start(param0 = {}) {
destroyCallbacks.forEach(callback => callback({ widget }));
this._super(...arguments);
legacyUnpatch(widget);
if (testEnv && testEnv.modelManager.messaging) {
testEnv.modelManager.messaging.delete();
}
}
});
} else {
@@ -658,9 +664,6 @@ async function start(param0 = {}) {
delete widget.destroy;
destroyCallbacks.forEach(callback => callback({ widget }));
parent.destroy();
if (testEnv && testEnv.modelManager.messaging) {
testEnv.modelManager.messaging.delete();
}
},
});
}