[IMP] mail: adapt component tests data seeding

This PR adapts mail components tests after the introduction
of a new way to seed test data.

task-2792108

closes odoo/odoo#86655

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
tsm-odoo
2022-03-28 19:00:00 +02:00
parent bee32f88d4
commit b168313f0e
34 changed files with 1688 additions and 2146 deletions
@@ -2,25 +2,20 @@
import {
afterNextRender,
beforeEach,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('discuss_mobile_mailbox_selection', {}, function () {
QUnit.module('discuss_mobile_mailbox_selection_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('discuss_mobile_mailbox_selection_tests.js');
QUnit.test('select another mailbox', async function (assert) {
assert.expect(7);
const { messaging } = await start({
autoOpenDiscuss: true,
data: this.data,
env: {
browser: {
innerHeight: 640,
@@ -80,14 +75,14 @@ QUnit.test('select another mailbox', async function (assert) {
QUnit.test('auto-select "Inbox" when discuss had channel as active thread', async function (assert) {
assert.expect(3);
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { messaging } = await start({
autoOpenDiscuss: true,
data: this.data,
discuss: {
context: {
active_id: 20,
active_id: mailChannelId1,
},
},
env: {
@@ -1,31 +1,27 @@
/** @odoo-module **/
import { beforeEach, start } from '@mail/../tests/helpers/test_utils';
import { start, startServer } from '@mail/../tests/helpers/test_utils';
import Bus from 'web.Bus';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('activity_mark_done_popover_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('activity_mark_done_popover_tests.js');
QUnit.test('activity mark done popover simplest layout', async function (assert) {
assert.expect(6);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.activity'].create({
activity_category: 'not_upload_file',
can_write: true,
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { click, createChatterContainerComponent } = await start({ data: this.data });
const { click, createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
await click('.o_Activity_markDoneButton');
@@ -65,18 +61,18 @@ QUnit.test('activity mark done popover simplest layout', async function (assert)
QUnit.test('activity with force next mark done popover simplest layout', async function (assert) {
assert.expect(6);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.activity'].create({
activity_category: 'not_upload_file',
can_write: true,
chaining_type: 'trigger',
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { click, createChatterContainerComponent } = await start({ data: this.data });
const { click, createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
await click('.o_Activity_markDoneButton');
@@ -116,22 +112,21 @@ QUnit.test('activity with force next mark done popover simplest layout', async f
QUnit.test('activity mark done popover mark done without feedback', async function (assert) {
assert.expect(7);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailActivityId1 = pyEnv['mail.activity'].create({
activity_category: 'not_upload_file',
can_write: true,
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { click, createChatterContainerComponent } = await start({
data: this.data,
async mockRPC(route, args) {
if (route === '/web/dataset/call_kw/mail.activity/action_feedback') {
assert.step('action_feedback');
assert.strictEqual(args.args.length, 1);
assert.strictEqual(args.args[0].length, 1);
assert.strictEqual(args.args[0][0], 12);
assert.strictEqual(args.args[0][0], mailActivityId1);
assert.strictEqual(args.kwargs.attachment_ids.length, 0);
assert.notOk(args.kwargs.feedback);
return;
@@ -144,7 +139,7 @@ QUnit.test('activity mark done popover mark done without feedback', async functi
},
});
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
await click('.o_Activity_markDoneButton');
@@ -158,22 +153,21 @@ QUnit.test('activity mark done popover mark done without feedback', async functi
QUnit.test('activity mark done popover mark done with feedback', async function (assert) {
assert.expect(7);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailActivityId1 = pyEnv['mail.activity'].create({
activity_category: 'not_upload_file',
can_write: true,
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { click, createChatterContainerComponent } = await start({
data: this.data,
async mockRPC(route, args) {
if (route === '/web/dataset/call_kw/mail.activity/action_feedback') {
assert.step('action_feedback');
assert.strictEqual(args.args.length, 1);
assert.strictEqual(args.args[0].length, 1);
assert.strictEqual(args.args[0][0], 12);
assert.strictEqual(args.args[0][0], mailActivityId1);
assert.strictEqual(args.kwargs.attachment_ids.length, 0);
assert.strictEqual(args.kwargs.feedback, 'This task is done');
return;
@@ -186,7 +180,7 @@ QUnit.test('activity mark done popover mark done with feedback', async function
},
});
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
await click('.o_Activity_markDoneButton');
@@ -209,22 +203,21 @@ QUnit.test('activity mark done popover mark done and schedule next', async funct
assert.step('activity_action');
throw new Error("The do-action event should not be triggered when the route doesn't return an action");
});
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailActivityId1 = pyEnv['mail.activity'].create({
activity_category: 'not_upload_file',
can_write: true,
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { click, createChatterContainerComponent } = await start({
data: this.data,
async mockRPC(route, args) {
if (route === '/web/dataset/call_kw/mail.activity/action_feedback_schedule_next') {
assert.step('action_feedback_schedule_next');
assert.strictEqual(args.args.length, 1);
assert.strictEqual(args.args[0].length, 1);
assert.strictEqual(args.args[0][0], 12);
assert.strictEqual(args.args[0][0], mailActivityId1);
assert.strictEqual(args.kwargs.feedback, 'This task is done');
return false;
}
@@ -237,7 +230,7 @@ QUnit.test('activity mark done popover mark done and schedule next', async funct
env: { bus },
});
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
await click('.o_Activity_markDoneButton');
@@ -264,16 +257,15 @@ QUnit.test('[technical] activity mark done & schedule next with new action', asy
"The content of the action should be correct"
);
});
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.activity'].create({
activity_category: 'not_upload_file',
can_write: true,
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { click, createChatterContainerComponent } = await start({
data: this.data,
env: { bus },
async mockRPC(route, args) {
if (route === '/web/dataset/call_kw/mail.activity/action_feedback_schedule_next') {
@@ -283,7 +275,7 @@ QUnit.test('[technical] activity mark done & schedule next with new action', asy
},
});
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
await click('.o_Activity_markDoneButton');
@@ -1,30 +1,26 @@
/** @odoo-module **/
import { afterNextRender, beforeEach, start } from '@mail/../tests/helpers/test_utils';
import { afterNextRender, start, startServer } from '@mail/../tests/helpers/test_utils';
import Bus from 'web.Bus';
import { date_to_str } from 'web.time';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('activity_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('activity_tests.js');
QUnit.test('activity simplest layout', async function (assert) {
assert.expect(12);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
id: 12,
res_id: 100,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.activity'].create({
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -92,16 +88,16 @@ QUnit.test('activity simplest layout', async function (assert) {
QUnit.test('activity with note layout', async function (assert) {
assert.expect(3);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
id: 12,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.activity'].create({
note: 'There is no good or bad note',
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -127,17 +123,17 @@ QUnit.test('activity info layout when planned after tomorrow', async function (a
const today = new Date();
const fiveDaysFromNow = new Date();
fiveDaysFromNow.setDate(today.getDate() + 5);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.activity'].create({
date_deadline: date_to_str(fiveDaysFromNow),
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
state: 'planned',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -167,17 +163,17 @@ QUnit.test('activity info layout when planned tomorrow', async function (assert)
const today = new Date();
const tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.activity'].create({
date_deadline: date_to_str(tomorrow),
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
state: 'planned',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -204,17 +200,17 @@ QUnit.test('activity info layout when planned tomorrow', async function (assert)
QUnit.test('activity info layout when planned today', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.activity'].create({
date_deadline: date_to_str(new Date()),
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
state: 'today',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -244,17 +240,17 @@ QUnit.test('activity info layout when planned yesterday', async function (assert
const today = new Date();
const yesterday = new Date();
yesterday.setDate(today.getDate() - 1);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.activity'].create({
date_deadline: date_to_str(yesterday),
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
state: 'overdue',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -284,17 +280,17 @@ QUnit.test('activity info layout when planned before yesterday', async function
const today = new Date();
const fiveDaysBeforeNow = new Date();
fiveDaysBeforeNow.setDate(today.getDate() - 5);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.activity'].create({
date_deadline: date_to_str(fiveDaysBeforeNow),
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
state: 'overdue',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -321,16 +317,16 @@ QUnit.test('activity info layout when planned before yesterday', async function
QUnit.test('activity with a summary layout', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
id: 12,
res_id: 100,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.activity'].create({
res_id: resPartnerId1,
res_model: 'res.partner',
summary: 'test summary',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -358,16 +354,16 @@ QUnit.test('activity with a summary layout', async function (assert) {
QUnit.test('activity without summary layout', async function (assert) {
assert.expect(5);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.activity'].create({
activity_type_id: 1,
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -403,18 +399,19 @@ QUnit.test('activity details toggle', async function (assert) {
const today = new Date();
const tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const resUsersId1 = pyEnv['res.users'].create({ partner_id: resPartnerId1 });
pyEnv['mail.activity'].create({
create_date: date_to_str(today),
create_uid: 1,
create_uid: resUsersId1,
date_deadline: date_to_str(tomorrow),
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -458,25 +455,23 @@ QUnit.test('activity details layout', async function (assert) {
const today = new Date();
const tomorrow = new Date();
tomorrow.setDate(today.getDate() + 1);
this.data['res.users'].records.push({
id: 10,
name: 'Pauvre pomme',
});
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
activity_type_id: 1,
const pyEnv = await startServer();
const resUsersId1 = pyEnv['res.users'].create({ name: 'Pauvre pomme' });
const resPartnerId1 = pyEnv['res.partner'].create();
const emailActivityTypeId = pyEnv['mail.activity.type'].search([['name', '=', 'Email']])[0];
pyEnv['mail.activity'].create({
activity_type_id: emailActivityTypeId,
create_date: date_to_str(today),
create_uid: 2,
create_uid: resUsersId1,
date_deadline: date_to_str(tomorrow),
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
state: 'planned',
user_id: 10,
user_id: resUsersId1,
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -543,21 +538,19 @@ QUnit.test('activity details layout', async function (assert) {
QUnit.test('activity with mail template layout', async function (assert) {
assert.expect(8);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.template'].records.push({
id: 1,
name: "Dummy mail template",
});
this.data['mail.activity'].records.push({
activity_type_id: 1,
id: 12,
mail_template_ids: [1],
res_id: 100,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailTemplateId1 = pyEnv['mail.template'].create({ name: "Dummy mail template" });
const emailActivityTypeId = pyEnv['mail.activity.type'].search([['name', '=', 'Email']])[0];
pyEnv['mail.activity'].create({
activity_type_id: emailActivityTypeId,
mail_template_ids: [mailTemplateId1],
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -605,12 +598,22 @@ QUnit.test('activity with mail template layout', async function (assert) {
QUnit.test('activity with mail template: preview mail', async function (assert) {
assert.expect(10);
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailTemplateId1 = pyEnv['mail.template'].create({ name: "Dummy mail template" });
const emailActivityTypeId = pyEnv['mail.activity.type'].search([['name', '=', 'Email']])[0];
pyEnv['mail.activity'].create({
activity_type_id: emailActivityTypeId,
mail_template_ids: [mailTemplateId1],
res_id: resPartnerId1,
res_model: 'res.partner',
});
const bus = new Bus();
bus.on('do-action', null, payload => {
assert.step('do_action');
assert.strictEqual(
payload.action.context.default_res_id,
42,
resPartnerId1,
'Action should have the activity res id as default res id in context'
);
assert.strictEqual(
@@ -624,7 +627,7 @@ QUnit.test('activity with mail template: preview mail', async function (assert)
);
assert.strictEqual(
payload.action.context.default_template_id,
1,
mailTemplateId1,
'Action should have the selected mail template id as default template id in context'
);
assert.strictEqual(
@@ -638,22 +641,9 @@ QUnit.test('activity with mail template: preview mail', async function (assert)
'Action should have "mail.compose.message" as res_model'
);
});
this.data['res.partner'].records.push({ id: 42 });
this.data['mail.template'].records.push({
id: 1,
name: "Dummy mail template",
});
this.data['mail.activity'].records.push({
activity_type_id: 1,
id: 12,
mail_template_ids: [1],
res_id: 42,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({ data: this.data, env: { bus } });
const { createChatterContainerComponent } = await start({ env: { bus } });
await createChatterContainerComponent({
threadId: 42,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -677,26 +667,23 @@ QUnit.test('activity with mail template: preview mail', async function (assert)
QUnit.test('activity with mail template: send mail', async function (assert) {
assert.expect(7);
this.data['res.partner'].records.push({ id: 42 });
this.data['mail.template'].records.push({
id: 1,
name: "Dummy mail template",
});
this.data['mail.activity'].records.push({
activity_type_id: 1,
id: 12,
mail_template_ids: [1],
res_id: 42,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailTemplateId1 = pyEnv['mail.template'].create({ name: "Dummy mail template" });
const emailActivityTypeId = pyEnv['mail.activity.type'].search([['name', '=', 'Email']])[0];
pyEnv['mail.activity'].create({
activity_type_id: emailActivityTypeId,
mail_template_ids: [mailTemplateId1],
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({
data: this.data,
async mockRPC(route, args) {
if (args.method === 'activity_send_mail') {
assert.step('activity_send_mail');
assert.strictEqual(args.args[0].length, 1);
assert.strictEqual(args.args[0][0], 42);
assert.strictEqual(args.args[1], 1);
assert.strictEqual(args.args[0][0], resPartnerId1);
assert.strictEqual(args.args[1], mailTemplateId1);
return;
} else {
return this._super(...arguments);
@@ -704,7 +691,7 @@ QUnit.test('activity with mail template: send mail', async function (assert) {
},
});
await createChatterContainerComponent({
threadId: 42,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -728,18 +715,19 @@ QUnit.test('activity with mail template: send mail', async function (assert) {
QUnit.test('activity upload document is available', async function (assert) {
assert.expect(3);
this.data['res.partner'].records.push({ id: 100, });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const uploadActivityTypeId = pyEnv['mail.activity.type'].search([['name', '=', 'Upload Document']])[0];
pyEnv['mail.activity'].create({
activity_category: 'upload_file',
activity_type_id: 28,
activity_type_id: uploadActivityTypeId,
can_write: true,
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
const chatterContainerComponent = await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -761,18 +749,19 @@ QUnit.test('activity upload document is available', async function (assert) {
QUnit.test('activity click on mark as done', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const emailActivityTypeId = pyEnv['mail.activity.type'].search([['name', '=', 'Email']])[0];
pyEnv['mail.activity'].create({
activity_category: 'default',
activity_type_id: 1,
activity_type_id: emailActivityTypeId,
can_write: true,
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -808,18 +797,19 @@ QUnit.test('activity click on mark as done', async function (assert) {
QUnit.test('activity mark as done popover should focus feedback input on open [REQUIRE FOCUS]', async function (assert) {
assert.expect(3);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const emailActivityTypeId = pyEnv['mail.activity.type'].search([['name', '=', 'Email']])[0];
pyEnv['mail.activity'].create({
activity_category: 'default',
activity_type_id: 1,
activity_type_id: emailActivityTypeId,
can_write: true,
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.containsOnce(
@@ -846,12 +836,23 @@ QUnit.test('activity mark as done popover should focus feedback input on open [R
QUnit.test('activity click on edit', async function (assert) {
assert.expect(9);
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailTemplateId1 = pyEnv['mail.template'].create({ name: "Dummy mail template" });
const emailActivityTypeId = pyEnv['mail.activity.type'].search([['name', '=', 'Email']])[0];
const mailActivityId1 = pyEnv['mail.activity'].create({
activity_type_id: emailActivityTypeId,
can_write: true,
mail_template_ids: [mailTemplateId1],
res_id: resPartnerId1,
res_model: 'res.partner',
});
const bus = new Bus();
bus.on('do-action', null, payload => {
assert.step('do_action');
assert.strictEqual(
payload.action.context.default_res_id,
42,
resPartnerId1,
'Action should have the activity res id as default res id in context'
);
assert.strictEqual(
@@ -871,27 +872,13 @@ QUnit.test('activity click on edit', async function (assert) {
);
assert.strictEqual(
payload.action.res_id,
12,
mailActivityId1,
'Action should have activity id as res_id'
);
});
this.data['res.partner'].records.push({ id: 42 });
this.data['mail.template'].records.push({
id: 1,
name: "Dummy mail template",
});
this.data['mail.activity'].records.push({
activity_type_id: 1,
can_write: true,
id: 12,
mail_template_ids: [1],
res_id: 42,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({ data: this.data, env: { bus } });
const { createChatterContainerComponent } = await start({ env: { bus } });
await createChatterContainerComponent({
threadId: 42,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -915,12 +902,12 @@ QUnit.test('activity click on edit', async function (assert) {
QUnit.test('activity edition', async function (assert) {
assert.expect(14);
this.data['res.partner'].records.push({ id: 42 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailActivityId1 = pyEnv['mail.activity'].create({
can_write: true,
icon: 'fa-times',
id: 12,
res_id: 42,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const bus = new Bus();
@@ -928,7 +915,7 @@ QUnit.test('activity edition', async function (assert) {
assert.step('do_action');
assert.strictEqual(
payload.action.context.default_res_id,
42,
resPartnerId1,
'Action should have the activity res id as default res id in context'
);
assert.strictEqual(
@@ -948,15 +935,15 @@ QUnit.test('activity edition', async function (assert) {
);
assert.strictEqual(
payload.action.res_id,
12,
mailActivityId1,
'Action should have activity id as res_id'
);
this.data['mail.activity'].records[0].icon = 'fa-check';
pyEnv['mail.activity'].write([mailActivityId1], { icon: 'fa-check' });
payload.options.on_close();
});
const { createChatterContainerComponent } = await start({ data: this.data, env: { bus } });
const { createChatterContainerComponent } = await start({ env: { bus } });
await createChatterContainerComponent({
threadId: 42,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.containsOnce(
@@ -1007,21 +994,21 @@ QUnit.test('activity edition', async function (assert) {
QUnit.test('activity click on cancel', async function (assert) {
assert.expect(7);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
activity_type_id: 1,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const emailActivityTypeId = pyEnv['mail.activity.type'].search([['name', '=', 'Email']])[0];
const mailActivityId1 = pyEnv['mail.activity'].create({
activity_type_id: emailActivityTypeId,
can_write: true,
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({
data: this.data,
async mockRPC(route, args) {
if (route === '/web/dataset/call_kw/mail.activity/unlink') {
assert.step('unlink');
assert.strictEqual(args.args[0].length, 1);
assert.strictEqual(args.args[0][0], 12);
assert.strictEqual(args.args[0][0], mailActivityId1);
return;
} else {
return this._super(...arguments);
@@ -1029,7 +1016,7 @@ QUnit.test('activity click on cancel', async function (assert) {
},
});
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -1061,18 +1048,19 @@ QUnit.test('activity mark done popover close on ESCAPE', async function (assert)
// This test is not in activity_mark_done_popover_tests.js as it requires the activity mark done
// component to have a parent in order to allow testing interactions the popover.
assert.expect(2);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const emailActivityTypeId = pyEnv['mail.activity.type'].search([['name', '=', 'Email']])[0];
pyEnv['mail.activity'].create({
activity_category: 'default',
activity_type_id: 1,
activity_type_id: emailActivityTypeId,
can_write: true,
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
@@ -1101,18 +1089,19 @@ QUnit.test('activity mark done popover click on discard', async function (assert
// component to have a parent in order to allow testing interactions the popover.
assert.expect(3);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const emailActivityTypeId = pyEnv['mail.activity.type'].search([['name', '=', 'Email']])[0];
pyEnv['mail.activity'].create({
activity_category: 'default',
activity_type_id: 1,
activity_type_id: emailActivityTypeId,
can_write: true,
id: 12,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
@@ -1161,20 +1150,20 @@ QUnit.test('data-oe-id & data-oe-model link redirection on click', async functio
);
assert.step('do-action:openFormView_some.model_250');
});
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const emailActivityTypeId = pyEnv['mail.activity.type'].search([['name', '=', 'Email']])[0];
pyEnv['mail.activity'].create({
activity_category: 'default',
activity_type_id: 1,
activity_type_id: emailActivityTypeId,
can_write: true,
id: 12,
note: `<p><a href="#" data-oe-id="250" data-oe-model="some.model">some.model_250</a></p>`,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({ data: this.data, env: { bus } });
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.containsOnce(
@@ -1198,34 +1187,31 @@ QUnit.test('data-oe-id & data-oe-model link redirection on click', async functio
QUnit.test('button related to file uploading is replaced when updating activity type from "Upload Document" to "Email"', async function (assert) {
assert.expect(2);
const activityId = 513;
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.activity'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const uploadActivityTypeId = pyEnv['mail.activity.type'].search([['name', '=', 'Upload document']])[0];
const emailActivityTypeId = pyEnv['mail.activity.type'].search([['name', '=', 'Email']])[0];
const mailActivityId1 = pyEnv['mail.activity'].create({
activity_category: 'upload_file',
activity_type_id: 28,
activity_type_id: uploadActivityTypeId,
can_write: true,
id: activityId,
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent, env, messaging } = await start({ data: this.data });
const { createChatterContainerComponent, messaging } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
// Update the record server side then fetch updated data in order to
// emulate what happens when using the form view.
await env.services.rpc({
model: 'mail.activity',
method: 'write',
args: [[activityId], {
activity_category: 'default',
activity_type_id: 1,
}],
pyEnv['mail.activity'].write([mailActivityId1], {
activity_category: 'default',
activity_type_id: emailActivityTypeId,
});
await afterNextRender(async () => {
const activity = messaging.models['Activity'].findFromIdentifyingData({ id: activityId });
const activity = messaging.models['Activity'].findFromIdentifyingData({ id: mailActivityId1 });
await activity.fetchAndUpdate();
});
assert.containsOnce(
@@ -2,10 +2,10 @@
import {
afterNextRender,
beforeEach,
dragenterFiles,
dropFiles,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
import { file } from 'web.test_utils';
@@ -14,20 +14,17 @@ const { createFile } = file;
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('attachment_box_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('attachment_box_tests.js');
QUnit.test('base empty rendering', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({ id: 100 });
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { createChatterContainerComponent } = await start();
const chatterContainerComponent = await createChatterContainerComponent({
isAttachmentBoxVisibleInitially: true,
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -54,25 +51,26 @@ QUnit.test('base empty rendering', async function (assert) {
QUnit.test('base non-empty rendering', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({ id: 100 });
this.data['ir.attachment'].records.push(
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['ir.attachment'].create([
{
mimetype: 'text/plain',
name: 'Blah.txt',
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
},
{
mimetype: 'text/plain',
name: 'Blu.txt',
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
}
);
const { createChatterContainerComponent } = await start({ data: this.data });
},
]);
const { createChatterContainerComponent } = await start();
const chatterContainerComponent = await createChatterContainerComponent({
isAttachmentBoxVisibleInitially: true,
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -99,11 +97,12 @@ QUnit.test('base non-empty rendering', async function (assert) {
QUnit.test('attachment box: drop attachments', async function (assert) {
assert.expect(5);
this.data['res.partner'].records.push({ id: 100 });
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
isAttachmentBoxVisibleInitially: true,
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
const files = [
@@ -174,33 +173,29 @@ QUnit.test('attachment box: drop attachments', async function (assert) {
QUnit.test('view attachments', async function (assert) {
assert.expect(7);
this.data['res.partner'].records.push({ id: 100 });
this.data['ir.attachment'].records.push(
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const [irAttachmentId1] = pyEnv['ir.attachment'].create([
{
id: 143,
mimetype: 'text/plain',
name: 'Blah.txt',
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
},
{
id: 144,
mimetype: 'text/plain',
name: 'Blu.txt',
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
},
);
const { createChatterContainerComponent, messaging } = await start({
data: this.data,
hasDialog: true,
});
]);
const { createChatterContainerComponent, messaging } = await start({ hasDialog: true });
await createChatterContainerComponent({
isAttachmentBoxVisibleInitially: true,
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
const firstAttachment = messaging.models['Attachment'].findFromIdentifyingData({ id: 143 });
const firstAttachment = messaging.models['Attachment'].findFromIdentifyingData({ id: irAttachmentId1 });
await afterNextRender(() =>
document.querySelector(`
@@ -256,18 +251,18 @@ QUnit.test('view attachments', async function (assert) {
QUnit.test('remove attachment should ask for confirmation', async function (assert) {
assert.expect(5);
this.data['res.partner'].records.push({ id: 100 });
this.data['ir.attachment'].records.push({
id: 143,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['ir.attachment'].create({
mimetype: 'text/plain',
name: 'Blah.txt',
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { createChatterContainerComponent } = await start({ data: this.data, hasDialog: true });
const { createChatterContainerComponent } = await start({ hasDialog: true });
await createChatterContainerComponent({
isAttachmentBoxVisibleInitially: true,
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.containsOnce(
@@ -1,23 +1,16 @@
/** @odoo-module **/
import { link } from '@mail/model/model_field_command';
import {
beforeEach,
start,
} from '@mail/../tests/helpers/test_utils';
import { start } from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('attachment_image_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('attachment_image_tests.js');
QUnit.test('auto layout with image', async function (assert) {
assert.expect(3);
const { createMessageComponent, messaging } = await start({ data: this.data });
const { createMessageComponent, messaging } = await start();
const attachment = messaging.models['Attachment'].create({
filename: "test.png",
id: 750,
@@ -2,24 +2,16 @@
import { link } from '@mail/model/model_field_command';
import {
afterNextRender,
beforeEach,
start,
} from '@mail/../tests/helpers/test_utils';
import { afterNextRender, start } from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('attachment_list_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('attachment_list_tests.js');
QUnit.test('simplest layout', async function (assert) {
assert.expect(8);
const { createMessageComponent, messaging } = await start({ data: this.data });
const { createMessageComponent, messaging } = await start();
const attachment = messaging.models['Attachment'].create({
filename: "test.txt",
id: 750,
@@ -82,7 +74,6 @@ QUnit.test('simplest layout + editable', async function (assert) {
assert.expect(7);
const { createMessageComponent, messaging } = await start({
data: this.data,
async mockRPC(route, args) {
if (route.includes('web/image/750')) {
assert.ok(
@@ -148,7 +139,7 @@ QUnit.test('simplest layout + editable', async function (assert) {
QUnit.test('layout with card details and filename and extension', async function (assert) {
assert.expect(2);
const { createMessageComponent, messaging } = await start({ data: this.data });
const { createMessageComponent, messaging } = await start();
const attachment = messaging.models['Attachment'].create({
filename: "test.txt",
id: 750,
@@ -178,10 +169,7 @@ QUnit.test('layout with card details and filename and extension', async function
QUnit.test('view attachment', async function (assert) {
assert.expect(3);
const { createMessageComponent, messaging } = await start({
data: this.data,
hasDialog: true,
});
const { createMessageComponent, messaging } = await start({ hasDialog: true });
const attachment = messaging.models['Attachment'].create({
filename: "test.png",
id: 750,
@@ -217,7 +205,7 @@ QUnit.test('view attachment', async function (assert) {
QUnit.test('close attachment viewer', async function (assert) {
assert.expect(3);
const { createMessageComponent, messaging } = await start({ data: this.data, hasDialog: true });
const { createMessageComponent, messaging } = await start({ hasDialog: true });
const attachment = messaging.models['Attachment'].create({
filename: "test.png",
id: 750,
@@ -259,7 +247,6 @@ QUnit.test('clicking on the delete attachment button multiple times should do th
assert.expect(2);
const { createMessageComponent, messaging } = await start({
data: this.data,
hasDialog: true,
async mockRPC(route, args) {
if (route === '/mail/attachment/delete') {
@@ -310,7 +297,7 @@ QUnit.test('[technical] does not crash when the viewer is closed before image lo
*/
assert.expect(1);
const { createMessageComponent, messaging } = await start({ data: this.data, hasDialog: true });
const { createMessageComponent, messaging } = await start({ hasDialog: true });
const attachment = messaging.models['Attachment'].create({
filename: "test.png",
id: 750,
@@ -344,7 +331,7 @@ QUnit.test('[technical] does not crash when the viewer is closed before image lo
QUnit.test('plain text file is viewable', async function (assert) {
assert.expect(1);
const { createMessageComponent, messaging } = await start({ data: this.data });
const { createMessageComponent, messaging } = await start();
const attachment = messaging.models['Attachment'].create({
filename: "test.txt",
id: 750,
@@ -369,7 +356,7 @@ QUnit.test('plain text file is viewable', async function (assert) {
QUnit.test('HTML file is viewable', async function (assert) {
assert.expect(1);
const { createMessageComponent, messaging } = await start({ data: this.data });
const { createMessageComponent, messaging } = await start();
const attachment = messaging.models['Attachment'].create({
filename: "test.html",
id: 750,
@@ -393,7 +380,7 @@ QUnit.test('HTML file is viewable', async function (assert) {
QUnit.test('ODT file is not viewable', async function (assert) {
assert.expect(1);
const { createMessageComponent, messaging } = await start({ data: this.data });
const { createMessageComponent, messaging } = await start();
const attachment = messaging.models['Attachment'].create({
filename: "test.odt",
id: 750,
@@ -417,7 +404,7 @@ QUnit.test('ODT file is not viewable', async function (assert) {
QUnit.test('DOCX file is not viewable', async function (assert) {
assert.expect(1);
const { createMessageComponent, messaging } = await start({ data: this.data });
const { createMessageComponent, messaging } = await start();
const attachment = messaging.models['Attachment'].create({
filename: "test.docx",
id: 750,
@@ -2,41 +2,33 @@
import {
afterNextRender,
beforeEach,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('channel_invitation_form_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('channel_invitation_form_tests.js');
QUnit.test('should display the channel invitation form after clicking on the invite button of a chat', async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({
id: 11,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({
email: "testpartner@odoo.com",
name: "TestPartner",
});
this.data['res.users'].records.push({
partner_id: 11,
});
this.data['mail.channel'].records.push({
pyEnv['res.users'].create({ partner_id: resPartnerId1 });
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 13,
members: [this.data.currentPartnerId, 11],
members: [pyEnv.currentPartnerId, resPartnerId1],
public: 'private',
});
await start({
autoOpenDiscuss: true,
data: this.data,
discuss: {
context: {
active_id: 13,
active_id: mailChannelId1,
},
},
hasDiscuss: true,
@@ -52,34 +44,27 @@ QUnit.test('should display the channel invitation form after clicking on the inv
QUnit.test('should be able to search for a new user to invite from an existing chat', async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({
id: 11,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({
email: "testpartner@odoo.com",
name: "TestPartner",
});
this.data['res.partner'].records.push({
id: 12,
const resPartnerId2 = pyEnv['res.partner'].create({
email: "testpartner2@odoo.com",
name: "TestPartner2",
});
this.data['res.users'].records.push({
partner_id: 11,
});
this.data['res.users'].records.push({
partner_id: 12,
});
this.data['mail.channel'].records.push({
pyEnv['res.users'].create({ partner_id: resPartnerId1 });
pyEnv['res.users'].create({ partner_id: resPartnerId2 });
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 13,
members: [this.data.currentPartnerId, 11],
members: [pyEnv.currentPartnerId, resPartnerId1],
public: 'private',
});
await start({
autoOpenDiscuss: true,
data: this.data,
discuss: {
context: {
active_id: 13,
active_id: mailChannelId1,
},
},
hasDiscuss: true,
@@ -96,34 +81,27 @@ QUnit.test('should be able to search for a new user to invite from an existing c
QUnit.test('should be able to create a new group chat from an existing chat', async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({
id: 11,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({
email: "testpartner@odoo.com",
name: "TestPartner",
});
this.data['res.partner'].records.push({
id: 12,
const resPartnerId2 = pyEnv['res.partner'].create({
email: "testpartner2@odoo.com",
name: "TestPartner2",
});
this.data['res.users'].records.push({
partner_id: 11,
});
this.data['res.users'].records.push({
partner_id: 12,
});
this.data['mail.channel'].records.push({
pyEnv['res.users'].create({ partner_id: resPartnerId1 });
pyEnv['res.users'].create({ partner_id: resPartnerId2 });
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 13,
members: [this.data.currentPartnerId, 11],
members: [pyEnv.currentPartnerId, resPartnerId1],
public: 'private',
});
await start({
autoOpenDiscuss: true,
data: this.data,
discuss: {
context: {
active_id: 13,
active_id: mailChannelId1,
},
},
hasDiscuss: true,
@@ -3,9 +3,9 @@
import { makeDeferred } from '@mail/utils/deferred';
import {
afterNextRender,
beforeEach,
nextAnimationFrame,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
import { file, dom } from 'web.test_utils';
@@ -15,14 +15,11 @@ const { triggerEvent } = dom;
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('chat_window_manager_tests.js', {
async beforeEach() {
await beforeEach(this);
beforeEach() {
this.start = async params => {
return start(Object.assign(
{ hasChatWindow: true },
params,
{ data: this.data }
));
};
},
@@ -239,12 +236,10 @@ QUnit.test('open chat from "new message" chat window should open chat in place o
*/
assert.expect(11);
this.data['res.partner'].records.push({ id: 131, name: "Partner 131" });
this.data['res.users'].records.push({ partner_id: 131 });
this.data['mail.channel'].records.push(
{ is_minimized: true },
{ is_minimized: true },
);
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: "Partner 131" });
pyEnv['res.users'].create({ partner_id: resPartnerId1 });
pyEnv['mail.channel'].create([{ is_minimized: true }, { is_minimized: true }]);
const imSearchDef = makeDeferred();
const { createMessagingMenuComponent } = await this.start({
env: {
@@ -349,13 +344,13 @@ 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({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: "Partner 131" });
pyEnv['res.users'].create({ partner_id: resPartnerId1 });
pyEnv['mail.channel'].create({
channel_type: "chat",
id: 20,
is_minimized: true,
members: [this.data.currentPartnerId, 131],
members: [pyEnv.currentPartnerId, resPartnerId1],
name: "Partner 131",
public: 'private',
state: 'open',
@@ -405,8 +400,9 @@ QUnit.test('new message chat window should close on selecting the user if chat w
QUnit.test('new message autocomplete should automatically select first result', async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({ id: 131, name: "Partner 131" });
this.data['res.users'].records.push({ partner_id: 131 });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: "Partner 131" });
pyEnv['res.users'].create({ partner_id: resPartnerId1 });
const imSearchDef = makeDeferred();
const { createMessagingMenuComponent } = await this.start({
async mockRPC(route, args) {
@@ -448,9 +444,8 @@ QUnit.test('new message autocomplete should automatically select first result',
QUnit.test('chat window: basic rendering', async function (assert) {
assert.expect(14);
// channel that is expected to be found in the messaging menu
// with random unique id and name that will be asserted during the test
this.data['mail.channel'].records.push({ id: 20, name: "General" });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ name: "General" });
const { createMessagingMenuComponent, messaging } = await this.start();
await createMessagingMenuComponent();
@@ -469,7 +464,7 @@ QUnit.test('chat window: basic rendering', async function (assert) {
assert.strictEqual(
chatWindow.dataset.threadLocalId,
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
}).localId,
"should have open a chat window of channel"
@@ -539,9 +534,8 @@ QUnit.test('chat window: basic rendering', async function (assert) {
QUnit.test('chat window: fold', async function (assert) {
assert.expect(9);
// channel that is expected to be found in the messaging menu
// with random UUID, will be asserted during the test
this.data['mail.channel'].records.push({ uuid: 'channel-uuid' });
const pyEnv = await startServer();
pyEnv['mail.channel'].create({ uuid: 'channel-uuid' });
const { createMessagingMenuComponent } = await this.start({
mockRPC(route, args) {
if (args.method === 'channel_fold') {
@@ -594,9 +588,8 @@ QUnit.test('chat window: fold', async function (assert) {
QUnit.test('chat window: open / close', async function (assert) {
assert.expect(10);
// channel that is expected to be found in the messaging menu
// with random UUID, will be asserted during the test
this.data['mail.channel'].records.push({ uuid: 'channel-uuid' });
const pyEnv = await startServer();
pyEnv['mail.channel'].create({ uuid: 'channel-uuid' });
const { createMessagingMenuComponent } = await this.start({
mockRPC(route, args) {
if (args.method === 'channel_fold') {
@@ -656,11 +649,9 @@ QUnit.test('chat window: open / close', async function (assert) {
QUnit.test('Mobile: opening a chat window should not update channel state on the server', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({
id: 20,
state: 'closed',
});
const { createMessagingMenuComponent, env } = await this.start({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ state: 'closed' });
const { createMessagingMenuComponent } = await this.start({
env: {
device: {
isMobile: true,
@@ -675,11 +666,7 @@ QUnit.test('Mobile: opening a chat window should not update channel state on the
'.o_ChatWindow',
"should have a chat window after clicking on thread preview"
);
const channels = await env.services.rpc({
model: 'mail.channel',
method: 'read',
args: [20],
}, { shadow: true });
const channels = pyEnv['mail.channel'].searchRead([['id', '=', mailChannelId1]]);
assert.strictEqual(
channels[0].state,
'closed',
@@ -690,11 +677,9 @@ QUnit.test('Mobile: opening a chat window should not update channel state on the
QUnit.test('Mobile: closing a chat window should not update channel state on the server', async function (assert) {
assert.expect(3);
this.data['mail.channel'].records.push({
id: 20,
state: 'open',
});
const { createMessagingMenuComponent, env } = await this.start({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ state: 'open' });
const { createMessagingMenuComponent } = await this.start({
env: {
device: {
isMobile: true,
@@ -716,11 +701,7 @@ QUnit.test('Mobile: closing a chat window should not update channel state on the
'.o_ChatWindow',
"should not have a chat window after closing it"
);
const channels = await env.services.rpc({
model: 'mail.channel',
method: 'read',
args: [20],
}, { shadow: true });
const channels = pyEnv['mail.channel'].searchRead([['id', '=', mailChannelId1]]);
assert.strictEqual(
channels[0].state,
'open',
@@ -731,16 +712,14 @@ QUnit.test('Mobile: closing a chat window should not update channel state on the
QUnit.test("Mobile: chat window shouldn't open automatically after receiving a new message", async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({ id: 10, name: "Demo" });
this.data['res.users'].records.push({
id: 42,
partner_id: 10,
});
this.data['mail.channel'].records = [
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: "Demo" });
const resUsersId1 = pyEnv['res.users'].create({ partner_id: resPartnerId1 });
pyEnv['mail.channel'].records = [
{
channel_type: "chat",
id: 10,
members: [this.data.currentPartnerId, 10],
id: resPartnerId1,
members: [pyEnv.currentPartnerId, resPartnerId1],
uuid: 'channel-10-uuid',
},
];
@@ -757,7 +736,7 @@ QUnit.test("Mobile: chat window shouldn't open automatically after receiving a n
route: '/mail/chat_post',
params: {
context: {
mockedUserId: 42,
mockedUserId: resUsersId1,
},
message_content: "hu",
uuid: 'channel-10-uuid',
@@ -774,10 +753,9 @@ QUnit.test("Mobile: chat window shouldn't open automatically after receiving a n
QUnit.test('chat window: close on ESCAPE', async function (assert) {
assert.expect(10);
// expected partner to be found by mention during the test
this.data['res.partner'].records.push({ name: "TestPartner" });
// a chat window with thread is expected to be initially open for this test
this.data['mail.channel'].records.push({ is_minimized: true });
const pyEnv = await startServer();
pyEnv['res.partner'].create({ name: "TestPartner" });
pyEnv['mail.channel'].create({ is_minimized: true });
await this.start({
mockRPC(route, args) {
if (args.method === 'channel_fold') {
@@ -873,11 +851,11 @@ QUnit.test('focus next visible chat window when closing current chat window with
*/
assert.expect(4);
// 2 chat windows with thread are expected to be initially open for this test
this.data['mail.channel'].records.push(
const pyEnv = await startServer();
pyEnv['mail.channel'].create([
{ is_minimized: true, state: 'open' },
{ is_minimized: true, state: 'open' }
);
{ is_minimized: true, state: 'open' },
]);
await this.start({
env: {
browser: {
@@ -916,9 +894,8 @@ QUnit.test('focus next visible chat window when closing current chat window with
QUnit.test('chat window: composer state conservation on toggle discuss', async function (assert) {
assert.expect(6);
// channel that is expected to be found in the messaging menu
// with random unique id that is needed to link messages
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
pyEnv['mail.channel'].create();
const { createMessagingMenuComponent, messaging } = await this.start();
const messagingMenuComponent = await createMessagingMenuComponent();
await afterNextRender(() => document.querySelector(`.o_MessagingMenu_toggler`).click());
@@ -986,12 +963,13 @@ QUnit.test('chat window: composer state conservation on toggle discuss', async f
QUnit.test('chat window: scroll conservation on toggle discuss', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
for (let i = 0; i < 10; i++) {
this.data['mail.message'].records.push({
pyEnv['mail.message'].create({
body: "not empty",
model: "mail.channel",
res_id: 20,
res_id: mailChannelId1,
});
}
const { afterEvent, createMessagingMenuComponent, messaging } = await this.start();
@@ -1006,7 +984,7 @@ QUnit.test('chat window: scroll conservation on toggle discuss', async function
return (
thread &&
thread.model === 'mail.channel' &&
thread.id === 20 &&
thread.id === mailChannelId1 &&
scrollTop === messageList.scrollHeight - messageList.clientHeight
);
},
@@ -1022,7 +1000,7 @@ QUnit.test('chat window: scroll conservation on toggle discuss', async function
return (
thread &&
thread.model === 'mail.channel' &&
thread.id === 20 &&
thread.id === mailChannelId1 &&
scrollTop === 142
);
},
@@ -1039,7 +1017,7 @@ QUnit.test('chat window: scroll conservation on toggle discuss', async function
return (
thread &&
thread.model === 'mail.channel' &&
thread.id === 20 &&
thread.id === mailChannelId1 &&
scrollTop === 142
);
},
@@ -1067,9 +1045,8 @@ QUnit.test('open 2 different chat windows: enough screen width [REQUIRE FOCUS]',
*/
assert.expect(8);
// 2 channels are expected to be found in the messaging menu, each with a
// random unique id that will be referenced in the test
this.data['mail.channel'].records.push({ id: 10 }, { id: 20 });
const pyEnv = await startServer();
const [mailChannelId1, mailChannelId2] = pyEnv['mail.channel'].create([{ name: 'mailChannel1' }, { name: 'mailChannel2' }]);
const { createMessagingMenuComponent, messaging } = await this.start({
env: {
browser: {
@@ -1084,7 +1061,7 @@ QUnit.test('open 2 different chat windows: enough screen width [REQUIRE FOCUS]',
.o_MessagingMenu_dropdownMenu
.o_NotificationList_preview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]
@@ -1099,7 +1076,7 @@ QUnit.test('open 2 different chat windows: enough screen width [REQUIRE FOCUS]',
document.querySelectorAll(`
.o_ChatWindow[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]
@@ -1111,7 +1088,7 @@ QUnit.test('open 2 different chat windows: enough screen width [REQUIRE FOCUS]',
document.querySelector(`
.o_ChatWindow[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]
@@ -1125,7 +1102,7 @@ QUnit.test('open 2 different chat windows: enough screen width [REQUIRE FOCUS]',
.o_MessagingMenu_dropdownMenu
.o_NotificationList_preview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId2,
model: 'mail.channel',
}).localId
}"]
@@ -1140,7 +1117,7 @@ QUnit.test('open 2 different chat windows: enough screen width [REQUIRE FOCUS]',
document.querySelectorAll(`
.o_ChatWindow[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId2,
model: 'mail.channel',
}).localId
}"]
@@ -1152,7 +1129,7 @@ QUnit.test('open 2 different chat windows: enough screen width [REQUIRE FOCUS]',
document.querySelectorAll(`
.o_ChatWindow[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]
@@ -1164,7 +1141,7 @@ QUnit.test('open 2 different chat windows: enough screen width [REQUIRE FOCUS]',
document.querySelector(`
.o_ChatWindow[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId2,
model: 'mail.channel',
}).localId
}"]
@@ -1175,7 +1152,7 @@ QUnit.test('open 2 different chat windows: enough screen width [REQUIRE FOCUS]',
document.querySelector(`
.o_ChatWindow[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]
@@ -1187,9 +1164,8 @@ QUnit.test('open 2 different chat windows: enough screen width [REQUIRE FOCUS]',
QUnit.test('open 2 chat windows: check shift operations are available', async function (assert) {
assert.expect(9);
// 2 channels are expected to be found in the messaging menu
// only their existence matters, data are irrelevant
this.data['mail.channel'].records.push({}, {});
const pyEnv = await startServer();
pyEnv['mail.channel'].create([{ name: 'mailChannel1' }, { name: 'mailChannel2' }]);
const { createMessagingMenuComponent } = await this.start();
await createMessagingMenuComponent();
@@ -1284,7 +1260,8 @@ QUnit.test('open 2 folded chat windows: check shift operations are available', a
*/
assert.expect(13);
this.data['res.partner'].records.push({ id: 7, name: "Demo" });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: "Demo" });
const channel = {
channel_type: "channel",
is_minimized: true,
@@ -1295,10 +1272,10 @@ QUnit.test('open 2 folded chat windows: check shift operations are available', a
channel_type: "chat",
is_minimized: true,
is_pinned: true,
members: [this.data.currentPartnerId, 7],
members: [pyEnv.currentPartnerId, resPartnerId1],
state: 'folded',
};
this.data['mail.channel'].records.push(channel, chat);
pyEnv['mail.channel'].create([channel, chat]);
await this.start({
env: {
browser: {
@@ -1414,9 +1391,12 @@ QUnit.test('open 3 different chat windows: not enough screen width', async funct
*/
assert.expect(12);
// 3 channels are expected to be found in the messaging menu, each with a
// random unique id that will be referenced in the test
this.data['mail.channel'].records.push({ id: 1 }, { id: 2 }, { id: 3 });
const pyEnv = await startServer();
const [mailChannelId1, mailChannelId2, mailChannelId3] = pyEnv['mail.channel'].create([
{ name: 'mailChannel1' },
{ name: 'mailChannel2' },
{ name: 'mailChannel3' },
]);
const { createMessagingMenuComponent, messaging } = await this.start({
env: {
browser: {
@@ -1435,7 +1415,7 @@ QUnit.test('open 3 different chat windows: not enough screen width', async funct
.o_MessagingMenu_dropdownMenu
.o_NotificationList_preview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 1,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]
@@ -1465,7 +1445,7 @@ QUnit.test('open 3 different chat windows: not enough screen width', async funct
.o_MessagingMenu_dropdownMenu
.o_NotificationList_preview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 2,
id: mailChannelId2,
model: 'mail.channel',
}).localId
}"]
@@ -1495,7 +1475,7 @@ QUnit.test('open 3 different chat windows: not enough screen width', async funct
.o_MessagingMenu_dropdownMenu
.o_NotificationList_preview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 3,
id: mailChannelId3,
model: 'mail.channel',
}).localId
}"]
@@ -1520,7 +1500,7 @@ QUnit.test('open 3 different chat windows: not enough screen width', async funct
document.querySelectorAll(`
.o_ChatWindow[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 1,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]
@@ -1532,7 +1512,7 @@ QUnit.test('open 3 different chat windows: not enough screen width', async funct
document.querySelectorAll(`
.o_ChatWindow[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 3,
id: mailChannelId3,
model: 'mail.channel',
}).localId
}"]
@@ -1544,7 +1524,7 @@ QUnit.test('open 3 different chat windows: not enough screen width', async funct
document.querySelector(`
.o_ChatWindow[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 3,
id: mailChannelId3,
model: 'mail.channel',
}).localId
}"]
@@ -1556,12 +1536,8 @@ QUnit.test('open 3 different chat windows: not enough screen width', async funct
QUnit.test('chat window: switch on TAB', async function (assert) {
assert.expect(10);
// 2 channels are expected to be found in the messaging menu
// with random unique id and name that will be asserted during the test
this.data['mail.channel'].records.push(
{ id: 1, name: "channel1" },
{ id: 2, name: "channel2" }
);
const pyEnv = await startServer();
const [mailChannelId1, mailChannelId2] = pyEnv['mail.channel'].create([{ name: 'channel1' }, { name: 'channel2' }]);
const { createMessagingMenuComponent, messaging } = await this.start();
await createMessagingMenuComponent();
@@ -1573,7 +1549,7 @@ QUnit.test('chat window: switch on TAB', async function (assert) {
.o_MessagingMenu_dropdownMenu
.o_NotificationList_preview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 1,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`
@@ -1614,7 +1590,7 @@ QUnit.test('chat window: switch on TAB', async function (assert) {
.o_MessagingMenu_dropdownMenu
.o_NotificationList_preview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 2,
id: mailChannelId2,
model: 'mail.channel',
}).localId
}"]`
@@ -1670,7 +1646,8 @@ QUnit.test('chat window: TAB cycle with 3 open chat windows [REQUIRE FOCUS]', as
*/
assert.expect(6);
this.data['mail.channel'].records.push(
const pyEnv = await startServer();
pyEnv['mail.channel'].create([
{
is_minimized: true,
is_pinned: true,
@@ -1685,8 +1662,8 @@ QUnit.test('chat window: TAB cycle with 3 open chat windows [REQUIRE FOCUS]', as
is_minimized: true,
is_pinned: true,
state: 'open',
}
);
},
]);
await this.start({
env: {
browser: {
@@ -1758,14 +1735,13 @@ QUnit.test('chat window: TAB cycle with 3 open chat windows [REQUIRE FOCUS]', as
QUnit.test('chat window with a thread: keep scroll position in message list on folded', async function (assert) {
assert.expect(3);
// channel that is expected to be found in the messaging menu
// with a random unique id, needed to link messages
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
for (let i = 0; i < 10; i++) {
this.data['mail.message'].records.push({
pyEnv['mail.message'].create({
body: "not empty",
model: "mail.channel",
res_id: 20,
res_id: mailChannelId1,
});
}
const { afterEvent, createMessagingMenuComponent } = await this.start();
@@ -1780,7 +1756,7 @@ QUnit.test('chat window with a thread: keep scroll position in message list on f
return (
thread &&
thread.model === 'mail.channel' &&
thread.id === 20 &&
thread.id === mailChannelId1 &&
scrollTop === messageList.scrollHeight - messageList.clientHeight
);
},
@@ -1796,7 +1772,7 @@ QUnit.test('chat window with a thread: keep scroll position in message list on f
return (
thread &&
thread.model === 'mail.channel' &&
thread.id === 20 &&
thread.id === mailChannelId1 &&
scrollTop === 142
);
},
@@ -1824,9 +1800,8 @@ QUnit.test('chat window with a thread: keep scroll position in message list on f
return (
thread &&
thread.model === 'mail.channel' &&
thread.id === 20 &&
thread.id === mailChannelId1 &&
scrollTop === 142
);
},
}));
@@ -1840,16 +1815,13 @@ QUnit.test('chat window with a thread: keep scroll position in message list on f
QUnit.test('chat window should scroll to the newly posted message just after posting it', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
id: 20,
is_minimized: true,
state: 'open',
});
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ is_minimized: true, state: 'open' });
for (let i = 0; i < 10; i++) {
this.data['mail.message'].records.push({
pyEnv['mail.message'].create({
body: "not empty",
model: "mail.channel",
res_id: 20,
res_id: mailChannelId1,
});
}
await this.start();
@@ -1878,10 +1850,8 @@ QUnit.test('chat window should scroll to the newly posted message just after pos
QUnit.test('chat window: post message on non-mailing channel with "CTRL-Enter" keyboard shortcut for small screen size', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
id: 20,
is_minimized: true,
});
const pyEnv = await startServer();
pyEnv['mail.channel'].create({ is_minimized: true });
const { createMessagingMenuComponent } = await this.start({
env: {
device: {
@@ -1914,14 +1884,13 @@ QUnit.test('chat window: post message on non-mailing channel with "CTRL-Enter" k
QUnit.test('chat window with a thread: keep scroll position in message list on toggle discuss when folded', async function (assert) {
assert.expect(2);
// channel that is expected to be found in the messaging menu
// with random unique id, needed to link messages
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
for (let i = 0; i < 10; i++) {
this.data['mail.message'].records.push({
pyEnv['mail.message'].create({
body: "not empty",
model: "mail.channel",
res_id: 20,
res_id: mailChannelId1,
});
}
const { afterEvent, createMessagingMenuComponent, messaging } = await this.start();
@@ -1936,7 +1905,7 @@ QUnit.test('chat window with a thread: keep scroll position in message list on t
return (
thread &&
thread.model === 'mail.channel' &&
thread.id === 20 &&
thread.id === mailChannelId1 &&
scrollTop === messageList.scrollHeight - messageList.clientHeight
);
},
@@ -1950,7 +1919,7 @@ QUnit.test('chat window with a thread: keep scroll position in message list on t
return (
thread &&
thread.model === 'mail.channel' &&
thread.id === 20 &&
thread.id === mailChannelId1 &&
scrollTop === 142
);
},
@@ -1970,7 +1939,7 @@ QUnit.test('chat window with a thread: keep scroll position in message list on t
return (
thread &&
thread.model === 'mail.channel' &&
thread.id === 20 &&
thread.id === mailChannelId1 &&
scrollTop === 142
);
},
@@ -1985,14 +1954,13 @@ QUnit.test('chat window with a thread: keep scroll position in message list on t
QUnit.test('chat window with a thread: keep scroll position in message list on toggle discuss when folded', async function (assert) {
assert.expect(2);
// channel that is expected to be found in the messaging menu
// with random unique id, needed to link messages
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
for (let i = 0; i < 10; i++) {
this.data['mail.message'].records.push({
pyEnv['mail.message'].create({
body: "not empty",
model: "mail.channel",
res_id: 20,
res_id: mailChannelId1,
});
}
const { afterEvent, createMessagingMenuComponent, messaging } = await this.start();
@@ -2007,7 +1975,7 @@ QUnit.test('chat window with a thread: keep scroll position in message list on t
return (
thread &&
thread.model === 'mail.channel' &&
thread.id === 20 &&
thread.id === mailChannelId1 &&
scrollTop === messageList.scrollHeight - messageList.clientHeight
);
},
@@ -2021,7 +1989,7 @@ QUnit.test('chat window with a thread: keep scroll position in message list on t
return (
thread &&
thread.model === 'mail.channel' &&
thread.id === 20 &&
thread.id === mailChannelId1 &&
scrollTop === 142
);
},
@@ -2041,7 +2009,7 @@ QUnit.test('chat window with a thread: keep scroll position in message list on t
return (
thread &&
thread.model === 'mail.channel' &&
thread.id === 20 &&
thread.id === mailChannelId1 &&
scrollTop === 142
);
},
@@ -2072,28 +2040,24 @@ QUnit.test('chat window does not fetch messages if hidden', async function (asse
*/
assert.expect(11);
// 3 channels are expected to be found in the messaging menu, each with a
// random unique id that will be referenced in the test
this.data['mail.channel'].records = [
const pyEnv = await startServer();
const [mailChannelId1, mailChannelId2, mailChannelId3] = pyEnv['mail.channel'].create([
{
id: 10,
is_minimized: true,
name: "Channel #10",
state: 'open',
},
{
id: 11,
is_minimized: true,
name: "Channel #11",
state: 'open',
},
{
id: 12,
is_minimized: true,
name: "Channel #12",
state: 'open',
},
];
]);
const { messaging } = await this.start({
env: {
browser: {
@@ -2119,7 +2083,7 @@ QUnit.test('chat window does not fetch messages if hidden', async function (asse
document.body,
`.o_ChatWindow[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 12,
id: mailChannelId3,
model: 'mail.channel',
}).localId
}"]`,
@@ -2131,7 +2095,7 @@ QUnit.test('chat window does not fetch messages if hidden', async function (asse
"chat window hidden menu should be displayed"
);
assert.verifySteps(
['rpc:/mail/channel/messages:10', 'rpc:/mail/channel/messages:11'],
[`rpc:/mail/channel/messages:${mailChannelId1}`, `rpc:/mail/channel/messages:${mailChannelId2}`],
"messages should be fetched for the two visible chat windows"
);
@@ -2157,14 +2121,14 @@ QUnit.test('chat window does not fetch messages if hidden', async function (asse
document.body,
`.o_ChatWindow[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 12,
id: mailChannelId3,
model: 'mail.channel',
}).localId
}"]`,
"chat window for Channel #12 should now be visible"
);
assert.verifySteps(
['rpc:/mail/channel/messages:12'],
[`rpc:/mail/channel/messages:${mailChannelId3}`],
"messages should now be fetched for Channel #12"
);
});
@@ -2172,26 +2136,20 @@ 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 if there is a history of conversation', async function (assert) {
assert.expect(3);
this.data['res.partner'].records.push({ id: 10, name: "Demo" });
this.data['res.users'].records.push({
id: 42,
name: "Foreigner user",
partner_id: 10,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: "Demo" });
const resUsersId1 = pyEnv['res.users'].create({ name: "Foreigner user", partner_id: resPartnerId1 });
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: "chat",
is_minimized: true,
is_pinned: false,
members: [pyEnv.currentPartnerId, resPartnerId1],
uuid: 'channel-10-uuid',
});
this.data['mail.channel'].records = [
{
channel_type: "chat",
id: 10,
is_minimized: true,
is_pinned: false,
members: [this.data.currentPartnerId, 10],
uuid: 'channel-10-uuid',
},
];
this.data['mail.message'].records.push({
pyEnv['mail.message'].create({
body: "not empty",
model: 'mail.channel',
res_id: 10,
res_id: mailChannelId1,
});
const { env } = await this.start();
@@ -2200,7 +2158,7 @@ QUnit.test('new message separator is shown in a chat window of a chat on receivi
route: '/mail/chat_post',
params: {
context: {
mockedUserId: 42,
mockedUserId: resUsersId1,
},
message_content: "hu",
uuid: 'channel-10-uuid',
@@ -2227,18 +2185,14 @@ QUnit.test('new message separator is shown in a chat window of a chat on receivi
QUnit.test('new message separator is not shown in a chat window of a chat on receiving new message if there is no history of conversation', async function (assert) {
assert.expect(1);
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 = [{
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: "Demo" });
const resUsersId1 = pyEnv['res.users'].create({ name: "Foreigner user", partner_id: resPartnerId1 });
pyEnv['mail.channel'].create({
channel_type: "chat",
id: 10,
members: [this.data.currentPartnerId, 10],
members: [pyEnv.currentPartnerId, resPartnerId1],
uuid: 'channel-10-uuid',
}];
});
const { env } = await this.start();
// simulate receiving a message
@@ -2246,7 +2200,7 @@ QUnit.test('new message separator is not shown in a chat window of a chat on rec
route: '/mail/chat_post',
params: {
context: {
mockedUserId: 42,
mockedUserId: resUsersId1,
},
message_content: "hu",
uuid: 'channel-10-uuid',
@@ -2262,27 +2216,21 @@ QUnit.test('new message separator is not shown in a chat window of a chat on rec
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,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: "Demo" });
const resUsersId1 = pyEnv['res.users'].create({ name: "Foreigner user", partner_id: resPartnerId1 });
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: "chat",
is_minimized: true,
is_pinned: false,
members: [pyEnv.currentPartnerId, resPartnerId1],
message_unread_counter: 0,
uuid: 'channel-10-uuid',
});
this.data['mail.channel'].records.push(
{
channel_type: "chat",
id: 10,
is_minimized: true,
is_pinned: false,
members: [this.data.currentPartnerId, 10],
message_unread_counter: 0,
uuid: 'channel-10-uuid',
},
);
this.data['mail.message'].records.push({
pyEnv['mail.message'].create({
body: "not empty",
model: 'mail.channel',
res_id: 10,
res_id: mailChannelId1,
});
const { afterEvent, env } = await this.start();
@@ -2291,7 +2239,7 @@ QUnit.test('focusing a chat window of a chat should make new message separator d
route: '/mail/chat_post',
params: {
context: {
mockedUserId: 42,
mockedUserId: resUsersId1,
},
message_content: "hu",
uuid: 'channel-10-uuid',
@@ -2309,7 +2257,7 @@ QUnit.test('focusing a chat window of a chat should make new message separator d
message: "should wait until last seen by current partner message id changed",
predicate: ({ thread }) => {
return (
thread.id === 10 &&
thread.id === mailChannelId1 &&
thread.model === 'mail.channel'
);
},
@@ -2324,10 +2272,8 @@ QUnit.test('focusing a chat window of a chat should make new message separator d
QUnit.test('Textual representations of shift previous/next operations are correctly mapped to left/right in LTR locale', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push(
{ is_minimized: true },
{ is_minimized: true },
);
const pyEnv = await startServer();
pyEnv['mail.channel'].create([{ is_minimized: true }, { is_minimized: true }]);
await this.start();
assert.strictEqual(
@@ -2345,10 +2291,8 @@ QUnit.test('Textual representations of shift previous/next operations are correc
QUnit.test('Textual representations of shift previous/next operations are correctly mapped to right/left in RTL locale', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push(
{ is_minimized: true },
{ is_minimized: true },
);
const pyEnv = await startServer();
pyEnv['mail.channel'].create([{ is_minimized: true }, { is_minimized: true }]);
await this.start({
env: {
_t: Object.assign((s => s), {
@@ -2382,19 +2326,14 @@ QUnit.test('Textual representations of shift previous/next operations are correc
QUnit.test('chat window should open when receiving a new DM', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const resUsersId1 = pyEnv['res.users'].create({ partner_id: resPartnerId1 });
pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 11,
is_pinned: false,
members: [this.data.currentPartnerId, 11],
uuid: 'channel11uuid',
});
this.data['res.partner'].records.push({
id: 11,
});
this.data['res.users'].records.push({
id: 11,
partner_id: 11,
members: [pyEnv.currentPartnerId, resPartnerId1],
uuid: 'channel11uuid'
});
const { env } = await this.start();
@@ -2403,7 +2342,7 @@ QUnit.test('chat window should open when receiving a new DM', async function (as
route: '/mail/chat_post',
params: {
context: {
mockedUserId: 11,
mockedUserId: resUsersId1,
},
message_content: "new message",
uuid: 'channel11uuid',
@@ -2419,23 +2358,17 @@ QUnit.test('chat window should open when receiving a new DM', async function (as
QUnit.test('chat window should remain folded when new message is received', async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({ id: 10, name: "Demo" });
this.data['res.users'].records.push({
id: 42,
name: "Foreigner user",
partner_id: 10,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: "Demo" });
const resUsersId1 = pyEnv['res.users'].create({ name: "Foreigner user", partner_id: resPartnerId1 });
pyEnv['mail.channel'].create({
channel_type: "chat",
is_minimized: true,
is_pinned: false,
members: [pyEnv.currentPartnerId, resPartnerId1],
state: 'folded',
uuid: 'channel-10-uuid',
});
this.data['mail.channel'].records = [
{
channel_type: "chat",
id: 10,
is_minimized: true,
is_pinned: false,
members: [this.data.currentPartnerId, 10],
state: 'folded',
uuid: 'channel-10-uuid',
},
];
const { env } = await this.start();
// simulate receiving a new message
@@ -2443,7 +2376,7 @@ QUnit.test('chat window should remain folded when new message is received', asyn
route: '/mail/chat_post',
params: {
context: {
mockedUserId: 42,
mockedUserId: resUsersId1,
},
message_content: "New Message 2",
uuid: 'channel-10-uuid',
@@ -2474,7 +2407,8 @@ QUnit.test('should not have chat window hidden menu in mobile (transition from 2
*/
assert.expect(1);
this.data['mail.channel'].records.push({ id: 11 }, { id: 12 });
const pyEnv = await startServer();
const [mailChannelId1, mailChannelId2] = pyEnv['mail.channel'].create([{ name: 'mailChannel1' }, { name: 'mailChannel1' }]);
const { click, createMessagingMenuComponent, messaging } = await this.start({
env: {
browser: {
@@ -2489,7 +2423,7 @@ QUnit.test('should not have chat window hidden menu in mobile (transition from 2
.o_MessagingMenu_dropdownMenu
.o_NotificationList_preview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 11,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]
@@ -2499,7 +2433,7 @@ QUnit.test('should not have chat window hidden menu in mobile (transition from 2
.o_MessagingMenu_dropdownMenu
.o_NotificationList_preview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 12,
id: mailChannelId2,
model: 'mail.channel',
}).localId
}"]
@@ -1,31 +1,20 @@
/** @odoo-module **/
import { afterNextRender, beforeEach, start } from '@mail/../tests/helpers/test_utils';
import { afterNextRender, start, startServer } from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('chatter_suggested_recipients_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('chatter_suggested_recipients_tests.js');
QUnit.test("suggest recipient on 'Send message' composer", async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({
display_name: "John Jane",
email: "john@jane.be",
id: 100,
});
this.data['res.fake'].records.push({
id: 10,
email_cc: "john@test.be",
partner_ids: [100],
});
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ display_name: "John Jane", email: "john@jane.be" });
const resFakeId1 = pyEnv['res.fake'].create({ email_cc: "john@test.be", partner_ids: [resPartnerId1] });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 10,
threadId: resFakeId1,
threadModel: 'res.fake',
});
await afterNextRender(() =>
@@ -41,19 +30,12 @@ QUnit.test("suggest recipient on 'Send message' composer", async function (asser
QUnit.test("with 3 or less suggested recipients: no 'show more' button", async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({
display_name: "John Jane",
email: "john@jane.be",
id: 100,
});
this.data['res.fake'].records.push({
id: 10,
email_cc: "john@test.be",
partner_ids: [100],
});
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ display_name: "John Jane", email: "john@jane.be" });
const resFakeId1 = pyEnv['res.fake'].create({ email_cc: "john@test.be", partner_ids: [resPartnerId1] });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 10,
threadId: resFakeId1,
threadModel: 'res.fake',
});
await afterNextRender(() =>
@@ -69,24 +51,18 @@ QUnit.test("with 3 or less suggested recipients: no 'show more' button", async f
QUnit.test("display reason for suggested recipient on mouse over", async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({
display_name: "John Jane",
email: "john@jane.be",
id: 100,
});
this.data['res.fake'].records.push({
id: 10,
partner_ids: [100],
});
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ display_name: "John Jane", email: "john@jane.be" });
const resFakeId1 = pyEnv['res.fake'].create({ partner_ids: [resPartnerId1] });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 10,
threadId: resFakeId1,
threadModel: 'res.fake',
});
await afterNextRender(() =>
document.querySelector(`.o_ChatterTopbar_buttonSendMessage`).click()
);
const partnerTitle = document.querySelector('.o_ComposerSuggestedRecipient[data-partner-id="100"]').getAttribute('title');
const partnerTitle = document.querySelector(`.o_ComposerSuggestedRecipient[data-partner-id="${resPartnerId1}"]`).getAttribute('title');
assert.strictEqual(
partnerTitle,
"Add as recipient and follower (reason: Email partner)",
@@ -97,13 +73,11 @@ QUnit.test("display reason for suggested recipient on mouse over", async functio
QUnit.test("suggested recipient without partner are unchecked by default", async function (assert) {
assert.expect(1);
this.data['res.fake'].records.push({
id: 10,
email_cc: "john@test.be",
});
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resFakeId1 = pyEnv['res.fake'].create({ email_cc: "john@test.be" });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 10,
threadId: resFakeId1,
threadModel: 'res.fake',
});
await afterNextRender(() =>
@@ -119,24 +93,18 @@ QUnit.test("suggested recipient without partner are unchecked by default", async
QUnit.test("suggested recipient with partner are checked by default", async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({
display_name: "John Jane",
email: "john@jane.be",
id: 100,
});
this.data['res.fake'].records.push({
id: 10,
partner_ids: [100],
});
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ display_name: "John Jane", email: "john@jane.be" });
const resFakeId1 = pyEnv['res.fake'].create({ partner_ids: [resPartnerId1] });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 10,
threadId: resFakeId1,
threadModel: 'res.fake',
});
await afterNextRender(() =>
document.querySelector(`.o_ChatterTopbar_buttonSendMessage`).click()
);
const checkboxChecked = document.querySelector('.o_ComposerSuggestedRecipient[data-partner-id="100"] input[type=checkbox]');
const checkboxChecked = document.querySelector(`.o_ComposerSuggestedRecipient[data-partner-id="${resPartnerId1}"] input[type=checkbox]`);
assert.ok(
checkboxChecked.checked,
"suggested recipient with partner must be checked by default",
@@ -146,33 +114,19 @@ QUnit.test("suggested recipient with partner are checked by default", async func
QUnit.test("more than 3 suggested recipients: display only 3 and 'show more' button", async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({
display_name: "John Jane",
email: "john@jane.be",
id: 100,
const pyEnv = await startServer();
const [resPartnerId1, resPartnerId2, resPartnerId3, resPartnerId4] = pyEnv['res.partner'].create([
{ display_name: "John Jane", email: "john@jane.be" },
{ display_name: "Jack Jone", email: "jack@jone.be" },
{ display_name: "jack sparrow", email: "jsparrow@blackpearl.bb" },
{ display_name: "jolly Roger", email: "Roger@skullflag.com" },
]);
const resFakeId1 = pyEnv['res.fake'].create({
partner_ids: [resPartnerId1, resPartnerId2, resPartnerId3, resPartnerId4],
});
this.data['res.partner'].records.push({
display_name: "Jack Jone",
email: "jack@jone.be",
id: 1000,
});
this.data['res.partner'].records.push({
display_name: "jolly Roger",
email: "Roger@skullflag.com",
id: 1001,
});
this.data['res.partner'].records.push({
display_name: "jack sparrow",
email: "jsparrow@blackpearl.bb",
id: 1002,
});
this.data['res.fake'].records.push({
id: 10,
partner_ids: [100, 1000, 1001, 1002],
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 10,
threadId: resFakeId1,
threadModel: 'res.fake',
});
@@ -189,33 +143,19 @@ QUnit.test("more than 3 suggested recipients: display only 3 and 'show more' but
QUnit.test("more than 3 suggested recipients: show all of them on click 'show more' button", async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({
display_name: "John Jane",
email: "john@jane.be",
id: 100,
const pyEnv = await startServer();
const [resPartnerId1, resPartnerId2, resPartnerId3, resPartnerId4] = pyEnv['res.partner'].create([
{ display_name: "John Jane", email: "john@jane.be" },
{ display_name: "Jack Jone", email: "jack@jone.be" },
{ display_name: "jack sparrow", email: "jsparrow@blackpearl.bb" },
{ display_name: "jolly Roger", email: "Roger@skullflag.com" },
]);
const resFakeId1 = pyEnv['res.fake'].create({
partner_ids: [resPartnerId1, resPartnerId2, resPartnerId3, resPartnerId4],
});
this.data['res.partner'].records.push({
display_name: "Jack Jone",
email: "jack@jone.be",
id: 1000,
});
this.data['res.partner'].records.push({
display_name: "jolly Roger",
email: "Roger@skullflag.com",
id: 1001,
});
this.data['res.partner'].records.push({
display_name: "jack sparrow",
email: "jsparrow@blackpearl.bb",
id: 1002,
});
this.data['res.fake'].records.push({
id: 10,
partner_ids: [100, 1000, 1001, 1002],
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 10,
threadId: resFakeId1,
threadModel: 'res.fake',
});
@@ -236,33 +176,19 @@ QUnit.test("more than 3 suggested recipients: show all of them on click 'show mo
QUnit.test("more than 3 suggested recipients -> click 'show more' -> 'show less' button", async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({
display_name: "John Jane",
email: "john@jane.be",
id: 100,
const pyEnv = await startServer();
const [resPartnerId1, resPartnerId2, resPartnerId3, resPartnerId4] = pyEnv['res.partner'].create([
{ display_name: "John Jane", email: "john@jane.be" },
{ display_name: "Jack Jone", email: "jack@jone.be" },
{ display_name: "jack sparrow", email: "jsparrow@blackpearl.bb" },
{ display_name: "jolly Roger", email: "Roger@skullflag.com" },
]);
const resFakeId1 = pyEnv['res.fake'].create({
partner_ids: [resPartnerId1, resPartnerId2, resPartnerId3, resPartnerId4],
});
this.data['res.partner'].records.push({
display_name: "Jack Jone",
email: "jack@jone.be",
id: 1000,
});
this.data['res.partner'].records.push({
display_name: "jolly Roger",
email: "Roger@skullflag.com",
id: 1001,
});
this.data['res.partner'].records.push({
display_name: "jack sparrow",
email: "jsparrow@blackpearl.bb",
id: 1002,
});
this.data['res.fake'].records.push({
id: 10,
partner_ids: [100, 1000, 1001, 1002],
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 10,
threadId: resFakeId1,
threadModel: 'res.fake',
});
@@ -282,33 +208,19 @@ QUnit.test("more than 3 suggested recipients -> click 'show more' -> 'show less'
QUnit.test("suggested recipients list display 3 suggested recipient and 'show more' button when 'show less' button is clicked", async function (assert) {
assert.expect(2);
this.data['res.partner'].records.push({
display_name: "John Jane",
email: "john@jane.be",
id: 100,
const pyEnv = await startServer();
const [resPartnerId1, resPartnerId2, resPartnerId3, resPartnerId4] = pyEnv['res.partner'].create([
{ display_name: "John Jane", email: "john@jane.be" },
{ display_name: "Jack Jone", email: "jack@jone.be" },
{ display_name: "jack sparrow", email: "jsparrow@blackpearl.bb" },
{ display_name: "jolly Roger", email: "Roger@skullflag.com" },
]);
const resFakeId1 = pyEnv['res.fake'].create({
partner_ids: [resPartnerId1, resPartnerId2, resPartnerId3, resPartnerId4],
});
this.data['res.partner'].records.push({
display_name: "Jack Jone",
email: "jack@jone.be",
id: 1000,
});
this.data['res.partner'].records.push({
display_name: "jolly Roger",
email: "Roger@skullflag.com",
id: 1001,
});
this.data['res.partner'].records.push({
display_name: "jack sparrow",
email: "jsparrow@blackpearl.bb",
id: 1002,
});
this.data['res.fake'].records.push({
id: 10,
partner_ids: [100, 1000, 1001, 1002],
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 10,
threadId: resFakeId1,
threadModel: 'res.fake',
});
@@ -337,17 +249,10 @@ QUnit.test("suggested recipients list display 3 suggested recipient and 'show mo
QUnit.test("suggested recipients should not be notified when posting an internal note", async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({
display_name: "John Jane",
email: "john@jane.be",
id: 100,
});
this.data['res.fake'].records.push({
id: 10,
partner_ids: [100],
});
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ display_name: "John Jane", email: "john@jane.be" });
const resFakeId1 = pyEnv['res.fake'].create({ partner_ids: [resPartnerId1] });
const { createChatterContainerComponent } = await start({
data: this.data,
async mockRPC(route, args) {
if (route === '/mail/message/post') {
assert.strictEqual(
@@ -360,7 +265,7 @@ QUnit.test("suggested recipients should not be notified when posting an internal
},
});
await createChatterContainerComponent({
threadId: 10,
threadId: resFakeId1,
threadModel: 'res.fake',
});
await afterNextRender(() =>
@@ -1,30 +1,27 @@
/** @odoo-module **/
import { afterNextRender, beforeEach, nextAnimationFrame, start } from '@mail/../tests/helpers/test_utils';
import { afterNextRender, nextAnimationFrame, start, startServer } from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('chatter', {}, function () {
QUnit.module('chatter_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('chatter_tests.js');
QUnit.test('base rendering when chatter has no attachment', async function (assert) {
assert.expect(6);
this.data['res.partner'].records.push({ id: 100 });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
for (let i = 0; i < 60; i++) {
this.data['mail.message'].records.push({
pyEnv['mail.message'].create({
body: "not empty",
model: 'res.partner',
res_id: 100,
res_id: resPartnerId1,
});
}
const { createChatterContainerComponent, messaging } = await start({ data: this.data });
const { createChatterContainerComponent, messaging } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -50,7 +47,7 @@ QUnit.test('base rendering when chatter has no attachment', async function (asse
assert.strictEqual(
document.querySelector(`.o_Chatter_thread`).dataset.threadLocalId,
messaging.models['Thread'].findFromIdentifyingData({
id: 100,
id: resPartnerId1,
model: 'res.partner',
}).localId,
"thread should have the right thread local id"
@@ -65,7 +62,7 @@ QUnit.test('base rendering when chatter has no attachment', async function (asse
QUnit.test('base rendering when chatter has no record', async function (assert) {
assert.expect(10);
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
const chatterContainerComponent = await createChatterContainerComponent({
threadModel: 'res.partner',
}, { waitUntilMessagesLoaded: false });
@@ -127,24 +124,25 @@ QUnit.test('base rendering when chatter has no record', async function (assert)
QUnit.test('base rendering when chatter has attachments', async function (assert) {
assert.expect(3);
this.data['res.partner'].records.push({ id: 100 });
this.data['ir.attachment'].records.push(
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['ir.attachment'].create([
{
mimetype: 'text/plain',
name: 'Blah.txt',
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
},
{
mimetype: 'text/plain',
name: 'Blu.txt',
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
}
);
const { createChatterContainerComponent } = await start({ data: this.data });
},
]);
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -167,24 +165,25 @@ QUnit.test('base rendering when chatter has attachments', async function (assert
QUnit.test('show attachment box', async function (assert) {
assert.expect(6);
this.data['res.partner'].records.push({ id: 100 });
this.data['ir.attachment'].records.push(
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['ir.attachment'].create([
{
mimetype: 'text/plain',
name: 'Blah.txt',
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
},
{
mimetype: 'text/plain',
name: 'Blu.txt',
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
}
);
const { createChatterContainerComponent } = await start({ data: this.data });
},
]);
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -226,10 +225,11 @@ QUnit.test('show attachment box', async function (assert) {
QUnit.test('composer show/hide on log note/send message [REQUIRE FOCUS]', async function (assert) {
assert.expect(10);
this.data['res.partner'].records.push({ id: 100 });
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.strictEqual(
@@ -307,16 +307,17 @@ QUnit.test('composer show/hide on log note/send message [REQUIRE FOCUS]', async
QUnit.test('should display subject when subject is not the same as the thread name', async function (assert) {
assert.expect(2);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.message'].create({
body: "not empty",
model: 'res.partner',
res_id: 100,
res_id: resPartnerId1,
subject: "Salutations, voyageur",
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
@@ -335,19 +336,17 @@ QUnit.test('should display subject when subject is not the same as the thread na
QUnit.test('should not display subject when subject is the same as the thread name', async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({
id: 100,
name: "Salutations, voyageur",
});
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: "Salutations, voyageur" });
pyEnv['mail.message'].create({
body: "not empty",
model: 'res.partner',
res_id: 100,
res_id: resPartnerId1,
subject: "Salutations, voyageur",
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
@@ -361,16 +360,16 @@ QUnit.test('should not display subject when subject is the same as the thread na
QUnit.test('should not display user notification messages in chatter', async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.message'].records.push({
id: 102,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.message'].create({
message_type: 'user_notification',
model: 'res.partner',
res_id: 100,
res_id: resPartnerId1,
});
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
@@ -384,10 +383,11 @@ QUnit.test('should not display user notification messages in chatter', async fun
QUnit.test('post message with "CTRL-Enter" keyboard shortcut', async function (assert) {
assert.expect(2);
this.data['res.partner'].records.push({ id: 100 });
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.containsNone(
@@ -417,10 +417,11 @@ QUnit.test('post message with "CTRL-Enter" keyboard shortcut', async function (a
QUnit.test('post message with "META-Enter" keyboard shortcut', async function (assert) {
assert.expect(2);
this.data['res.partner'].records.push({ id: 100 });
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.containsNone(
@@ -453,10 +454,11 @@ QUnit.test('do not post message with "Enter" keyboard shortcut', async function
// programmatically crafted events...
assert.expect(2);
this.data['res.partner'].records.push({ id: 100 });
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.containsNone(
@@ -1,24 +1,21 @@
/** @odoo-module **/
import { afterNextRender, beforeEach, nextAnimationFrame, start } from '@mail/../tests/helpers/test_utils';
import { afterNextRender, nextAnimationFrame, start, startServer } from '@mail/../tests/helpers/test_utils';
import { makeTestPromise } from 'web.test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('chatter_topbar_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('chatter_topbar_tests.js');
QUnit.test('base rendering', async function (assert) {
assert.expect(8);
this.data['res.partner'].records.push({ id: 100 });
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
@@ -67,7 +64,7 @@ QUnit.test('base rendering', async function (assert) {
QUnit.test('base disabled rendering', async function (assert) {
assert.expect(8);
const { createChatterContainerComponent } = await start({ data: this.data });
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadModel: 'res.partner',
}, { waitUntilMessagesLoaded: false });
@@ -112,9 +109,9 @@ QUnit.test('base disabled rendering', async function (assert) {
QUnit.test('attachment loading is delayed', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({ id: 100 });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { createChatterContainerComponent, env } = await start({
data: this.data,
hasTimeControl: true,
loadingBaseDelayDuration: 100,
async mockRPC(route) {
@@ -125,7 +122,7 @@ QUnit.test('attachment loading is delayed', async function (assert) {
}
});
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
@@ -156,9 +153,9 @@ QUnit.test('attachment loading is delayed', async function (assert) {
QUnit.test('attachment counter while loading attachments', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({ id: 100 });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { createChatterContainerComponent } = await start({
data: this.data,
async mockRPC(route) {
if (route.includes('/mail/thread/data')) {
await makeTestPromise(); // simulate long loading
@@ -167,7 +164,7 @@ QUnit.test('attachment counter while loading attachments', async function (asser
}
});
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
@@ -196,10 +193,10 @@ QUnit.test('attachment counter while loading attachments', async function (asser
QUnit.test('attachment counter transition when attachments become loaded)', async function (assert) {
assert.expect(7);
this.data['res.partner'].records.push({ id: 100 });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const attachmentPromise = makeTestPromise();
const { createChatterContainerComponent } = await start({
data: this.data,
async mockRPC(route) {
const _super = this._super.bind(this, ...arguments); // limitation of class.js
if (route.includes('/mail/thread/data')) {
@@ -209,7 +206,7 @@ QUnit.test('attachment counter transition when attachments become loaded)', asyn
},
});
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
@@ -255,10 +252,11 @@ QUnit.test('attachment counter transition when attachments become loaded)', asyn
QUnit.test('attachment counter without attachments', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({ id: 100 });
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
@@ -287,24 +285,25 @@ QUnit.test('attachment counter without attachments', async function (assert) {
QUnit.test('attachment counter with attachments', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({ id: 100 });
this.data['ir.attachment'].records.push(
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['ir.attachment'].create([
{
mimetype: 'text/plain',
name: 'Blah.txt',
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
},
{
mimetype: 'text/plain',
name: 'Blu.txt',
res_id: 100,
res_id: resPartnerId1,
res_model: 'res.partner',
}
);
const { createChatterContainerComponent } = await start({ data: this.data });
},
]);
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
@@ -333,10 +332,11 @@ QUnit.test('attachment counter with attachments', async function (assert) {
QUnit.test('composer state conserved when clicking on another topbar button', async function (assert) {
assert.expect(8);
this.data['res.partner'].records.push({ id: 100 });
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
@@ -392,31 +392,29 @@ QUnit.test('composer state conserved when clicking on another topbar button', as
QUnit.test('rendering with multiple partner followers', async function (assert) {
assert.expect(7);
this.data['res.partner'].records.push(
{ id: 11 },
{ id: 12 },
{ id: 100, message_follower_ids: [1, 2] },
);
this.data['mail.followers'].records.push(
const pyEnv = await startServer();
const [resPartnerId1, resPartnerId2, resPartnerId3] = pyEnv['res.partner'].create([
{ name: 'resPartner1' },
{ name: 'resPartner2' },
{ message_follower_ids: [1, 2] },
]);
pyEnv['mail.followers'].create([
{
// simulate real return from RPC
id: 1,
name: "Jean Michang",
partner_id: 12,
res_id: 100,
res_model: 'res.partner',
}, {
// simulate real return from RPC
id: 2,
name: "Eden Hazard",
partner_id: 11,
res_id: 100,
partner_id: resPartnerId2,
res_id: resPartnerId3,
res_model: 'res.partner',
},
);
const { createChatterContainerComponent } = await start({ data: this.data });
{
name: "Eden Hazard",
partner_id: resPartnerId1,
res_id: resPartnerId3,
res_model: 'res.partner',
},
]);
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId3,
threadModel: 'res.partner',
});
@@ -466,10 +464,11 @@ QUnit.test('rendering with multiple partner followers', async function (assert)
QUnit.test('log note/send message switching', async function (assert) {
assert.expect(8);
this.data['res.partner'].records.push({ id: 100 });
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.containsOnce(
@@ -525,10 +524,11 @@ QUnit.test('log note/send message switching', async function (assert) {
QUnit.test('log note toggling', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({ id: 100 });
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.containsOnce(
@@ -564,10 +564,11 @@ QUnit.test('log note toggling', async function (assert) {
QUnit.test('send message toggling', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({ id: 100 });
const { createChatterContainerComponent } = await start({ data: this.data });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { createChatterContainerComponent } = await start();
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
assert.containsOnce(
@@ -1,22 +1,19 @@
/** @odoo-module **/
import { beforeEach, start } from '@mail/../tests/helpers/test_utils';
import { start, startServer } from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('composer_suggestion_canned_response_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('composer_suggestion_canned_response_tests.js');
QUnit.test('canned response suggestion displayed', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 20 });
const { createComposerSuggestionComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerSuggestionComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const cannedResponse = messaging.models['CannedResponse'].create({
@@ -40,10 +37,11 @@ QUnit.test('canned response suggestion displayed', async function (assert) {
QUnit.test('canned response suggestion correct data', async function (assert) {
assert.expect(5);
this.data['mail.channel'].records.push({ id: 20 });
const { createComposerSuggestionComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerSuggestionComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const cannedResponse = messaging.models['CannedResponse'].create({
@@ -87,10 +85,11 @@ QUnit.test('canned response suggestion correct data', async function (assert) {
QUnit.test('canned response suggestion active', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({ id: 20 });
const { createComposerSuggestionComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerSuggestionComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const cannedResponse = messaging.models['CannedResponse'].create({
@@ -1,22 +1,19 @@
/** @odoo-module **/
import { beforeEach, start } from '@mail/../tests/helpers/test_utils';
import { start, startServer } from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('composer_suggestion_channel_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('composer_suggestion_channel_tests.js');
QUnit.test('channel mention suggestion displayed', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 20 });
const { createComposerSuggestionComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerSuggestionComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await createComposerSuggestionComponent(thread.composer, {
@@ -35,13 +32,11 @@ QUnit.test('channel mention suggestion displayed', async function (assert) {
QUnit.test('channel mention suggestion correct data', async function (assert) {
assert.expect(3);
this.data['mail.channel'].records.push({
id: 20,
name: "General",
});
const { createComposerSuggestionComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ name: "General" });
const { createComposerSuggestionComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await createComposerSuggestionComponent(thread.composer, {
@@ -70,10 +65,11 @@ QUnit.test('channel mention suggestion correct data', async function (assert) {
QUnit.test('channel mention suggestion active', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({ id: 20 });
const { createComposerSuggestionComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerSuggestionComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await createComposerSuggestionComponent(thread.composer, {
@@ -1,22 +1,19 @@
/** @odoo-module **/
import { beforeEach, start } from '@mail/../tests/helpers/test_utils';
import { start, startServer } from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('composer_suggestion_command_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('composer_suggestion_command_tests.js');
QUnit.test('command suggestion displayed', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 20 });
const { createComposerSuggestionComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerSuggestionComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const command = messaging.models['ChannelCommand'].create({
@@ -40,10 +37,11 @@ QUnit.test('command suggestion displayed', async function (assert) {
QUnit.test('command suggestion correct data', async function (assert) {
assert.expect(5);
this.data['mail.channel'].records.push({ id: 20 });
const { createComposerSuggestionComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerSuggestionComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const command = messaging.models['ChannelCommand'].create({
@@ -87,10 +85,11 @@ QUnit.test('command suggestion correct data', async function (assert) {
QUnit.test('command suggestion active', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({ id: 20 });
const { createComposerSuggestionComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerSuggestionComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const command = messaging.models['ChannelCommand'].create({
@@ -1,22 +1,19 @@
/** @odoo-module **/
import { beforeEach, start } from '@mail/../tests/helpers/test_utils';
import { start, startServer } from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('composer_suggestion_partner_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('composer_suggestion_partner_tests.js');
QUnit.test('partner mention suggestion displayed', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 20 });
const { createComposerSuggestionComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerSuggestionComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const partner = messaging.models['Partner'].create({
@@ -40,10 +37,11 @@ QUnit.test('partner mention suggestion displayed', async function (assert) {
QUnit.test('partner mention suggestion correct data', async function (assert) {
assert.expect(6);
this.data['mail.channel'].records.push({ id: 20 });
const { createComposerSuggestionComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerSuggestionComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const partner = messaging.models['Partner'].create({
@@ -93,10 +91,11 @@ QUnit.test('partner mention suggestion correct data', async function (assert) {
QUnit.test('partner mention suggestion active', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({ id: 20 });
const { createComposerSuggestionComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerSuggestionComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const partner = messaging.models['Partner'].create({
@@ -3,12 +3,12 @@
import { insertAndReplace } from '@mail/model/model_field_command';
import {
afterNextRender,
beforeEach,
dragenterFiles,
dropFiles,
nextAnimationFrame,
pasteFiles,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
import FormView from 'web.FormView';
@@ -22,9 +22,7 @@ const { createFile, inputFiles } = file;
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('composer_tests.js', {
async beforeEach() {
await beforeEach(this);
beforeEach() {
// FIXME archs could be removed once task-2248306 is done
// The mockServer will try to get the list view
// of every relational fields present in the main view.
@@ -53,7 +51,7 @@ QUnit.module('composer_tests.js', {
QUnit.test('composer text input: basic rendering when posting a message', async function (assert) {
assert.expect(5);
const { createComposerComponent, messaging } = await start({ data: this.data });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].create({
composer: insertAndReplace({ isLog: false }),
id: 20,
@@ -89,7 +87,7 @@ QUnit.test('composer text input: basic rendering when posting a message', async
QUnit.test('composer text input: basic rendering when logging note', async function (assert) {
assert.expect(5);
const { createComposerComponent, messaging } = await start({ data: this.data });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].create({
composer: insertAndReplace({ isLog: true }),
id: 20,
@@ -125,10 +123,11 @@ QUnit.test('composer text input: basic rendering when logging note', async funct
QUnit.test('composer text input: basic rendering when linked thread is a mail.channel', async function (assert) {
assert.expect(4);
this.data['mail.channel'].records.push({ id: 20 });
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -156,14 +155,11 @@ QUnit.test('composer text input: basic rendering when linked thread is a mail.ch
QUnit.test('composer text input placeholder should contain channel name when thread does not have specific correspondent', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
channel_type: 'channel',
id: 20,
name: 'General',
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ channel_type: 'channel', name: 'General' });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -177,15 +173,15 @@ QUnit.test('composer text input placeholder should contain channel name when thr
QUnit.test('composer text input placeholder should contain correspondent name when thread has exactly one correspondent', async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({ id: 7, name: 'Marc Demo' });
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: 'Marc Demo' });
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 20,
members: [this.data.currentPartnerId, 7],
members: [pyEnv.currentPartnerId, resPartnerId1],
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -199,12 +195,11 @@ QUnit.test('composer text input placeholder should contain correspondent name wh
QUnit.test('add an emoji', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -224,12 +219,11 @@ QUnit.test('add an emoji', async function (assert) {
QUnit.test('add an emoji after some text', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -257,12 +251,11 @@ QUnit.test('add an emoji after some text', async function (assert) {
QUnit.test('add emoji replaces (keyboard) text selection', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -293,18 +286,12 @@ QUnit.test('add emoji replaces (keyboard) text selection', async function (asser
QUnit.test('display canned response suggestions on typing ":"', async function (assert) {
assert.expect(2);
this.data['mail.shortcode'].records.push({
id: 11,
source: "hello",
substitution: "Hello! How are you?",
});
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create();
pyEnv['mail.shortcode'].create({ source: "hello", substitution: "Hello! How are you?" });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -332,18 +319,12 @@ QUnit.test('display canned response suggestions on typing ":"', async function (
QUnit.test('use a canned response', async function (assert) {
assert.expect(4);
this.data['mail.shortcode'].records.push({
id: 11,
source: "hello",
substitution: "Hello! How are you?",
});
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create();
pyEnv['mail.shortcode'].create({ source: "hello", substitution: "Hello! How are you?" });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -384,18 +365,12 @@ QUnit.test('use a canned response', async function (assert) {
QUnit.test('use a canned response some text', async function (assert) {
assert.expect(5);
this.data['mail.shortcode'].records.push({
id: 11,
source: "hello",
substitution: "Hello! How are you?",
});
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create();
pyEnv['mail.shortcode'].create({ source: "hello", substitution: "Hello! How are you?" });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -444,18 +419,12 @@ QUnit.test('use a canned response some text', async function (assert) {
QUnit.test('add an emoji after a canned response', async function (assert) {
assert.expect(5);
this.data['mail.shortcode'].records.push({
id: 11,
source: "hello",
substitution: "Hello! How are you?",
});
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create();
pyEnv['mail.shortcode'].create({ source: "hello", substitution: "Hello! How are you?" });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -509,15 +478,11 @@ QUnit.test('add an emoji after a canned response', async function (assert) {
QUnit.test('display channel mention suggestions on typing "#"', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({
id: 7,
name: "General",
public: "groups",
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create({ name: "General", public: "groups" });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 7,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -545,14 +510,11 @@ QUnit.test('display channel mention suggestions on typing "#"', async function (
QUnit.test('mention a channel', async function (assert) {
assert.expect(4);
this.data['mail.channel'].records.push({
id: 7,
name: "General",
public: "groups",
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create({ name: "General", public: "groups" });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 7,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -593,14 +555,11 @@ QUnit.test('mention a channel', async function (assert) {
QUnit.test('mention a channel after some text', async function (assert) {
assert.expect(5);
this.data['mail.channel'].records.push({
id: 7,
name: "General",
public: "groups",
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create({ name: "General", public: "groups" });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 7,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -649,14 +608,11 @@ QUnit.test('mention a channel after some text', async function (assert) {
QUnit.test('add an emoji after a channel mention', async function (assert) {
assert.expect(5);
this.data['mail.channel'].records.push({
id: 7,
name: "General",
public: "groups",
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create({ name: "General", public: "groups" });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 7,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -710,10 +666,11 @@ QUnit.test('add an emoji after a channel mention', async function (assert) {
QUnit.test('display command suggestions on typing "/"', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({ channel_type: 'channel', id: 20 });
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create({ channel_type: 'channel' });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -741,13 +698,13 @@ QUnit.test('display command suggestions on typing "/"', async function (assert)
QUnit.test('do not send typing notification on typing "/" command', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
await start({
autoOpenDiscuss: true,
data: this.data,
discuss: {
params: {
default_active_id: 20,
default_active_id: `mail.channel_${mailChannelId1}`,
},
},
hasDiscuss: true,
@@ -773,13 +730,13 @@ QUnit.test('do not send typing notification on typing "/" command', async functi
QUnit.test('do not send typing notification on typing after selecting suggestion from "/" command', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
await start({
autoOpenDiscuss: true,
data: this.data,
discuss: {
params: {
default_active_id: 20,
default_active_id: `mail.channel_${mailChannelId1}`,
},
},
hasDiscuss: true,
@@ -816,10 +773,12 @@ QUnit.test('do not send typing notification on typing after selecting suggestion
QUnit.test('use a command for a specific channel type', async function (assert) {
assert.expect(3);
this.data['mail.channel'].records.push({ channel_type: 'channel', id: 20 });
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create({ channel_type: 'chat' });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -855,10 +814,11 @@ QUnit.test('use a command for a specific channel type', async function (assert)
QUnit.test('command suggestion should only open if command is the first character', async function (assert) {
assert.expect(4);
this.data['mail.channel'].records.push({ channel_type: 'channel', id: 20 });
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create({ channel_type: 'channel' });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -898,10 +858,11 @@ QUnit.test('command suggestion should only open if command is the first characte
QUnit.test('add an emoji after a command', async function (assert) {
assert.expect(4);
this.data['mail.channel'].records.push({ channel_type: 'channel', id: 20 });
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChanelId1 = pyEnv['mail.channel'].create({ channel_type: 'channel' });
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChanelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -950,26 +911,15 @@ QUnit.test('add an emoji after a command', async function (assert) {
QUnit.test('display partner mention suggestions on typing "@"', async function (assert) {
assert.expect(3);
this.data['res.partner'].records.push({
id: 11,
email: "testpartner@odoo.com",
name: "TestPartner",
});
this.data['res.partner'].records.push({
id: 12,
email: "testpartner2@odoo.com",
name: "TestPartner2",
});
this.data['res.users'].records.push({
partner_id: 11,
});
const pyEnv = await startServer();
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const resPartnerId1 = pyEnv['res.partner'].create({ email: "testpartner@odoo.com", name: "TestPartner" });
pyEnv['res.partner'].create({ email: "testpartner2@odoo.com", name: "TestPartner2" });
pyEnv['res.users'].create({ partner_id: resPartnerId1 });
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -1002,16 +952,12 @@ QUnit.test('display partner mention suggestions on typing "@"', async function (
QUnit.test('mention a partner', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({
email: "testpartner@odoo.com",
name: "TestPartner",
});
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
pyEnv['res.partner'].create({ email: "testpartner@odoo.com", name: "TestPartner" });
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -1062,16 +1008,12 @@ QUnit.test('mention a partner', async function (assert) {
QUnit.test('mention a partner after some text', async function (assert) {
assert.expect(5);
this.data['res.partner'].records.push({
email: "testpartner@odoo.com",
name: "TestPartner",
});
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
pyEnv['res.partner'].create({ email: "testpartner@odoo.com", name: "TestPartner" });
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -1131,16 +1073,12 @@ QUnit.test('mention a partner after some text', async function (assert) {
QUnit.test('add an emoji after a partner mention', async function (assert) {
assert.expect(5);
this.data['res.partner'].records.push({
email: "testpartner@odoo.com",
name: "TestPartner",
});
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
pyEnv['res.partner'].create({ email: "testpartner@odoo.com", name: "TestPartner" });
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -1204,12 +1142,11 @@ QUnit.test('add an emoji after a partner mention', async function (assert) {
QUnit.test('composer: add an attachment', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const composerComponent = await createComposerComponent(thread.composer);
@@ -1220,10 +1157,7 @@ QUnit.test('composer: add an attachment', async function (assert) {
name: 'text.txt',
});
await afterNextRender(() =>
inputFiles(
composerComponent.composerView.fileUploader.fileInput,
[file]
)
inputFiles(composerComponent.composerView.fileUploader.fileInput, [file])
);
assert.ok(
document.querySelector('.o_Composer_attachmentList'),
@@ -1238,12 +1172,11 @@ QUnit.test('composer: add an attachment', async function (assert) {
QUnit.test('composer: drop attachments', async function (assert) {
assert.expect(4);
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -1271,10 +1204,7 @@ QUnit.test('composer: drop attachments', async function (assert) {
);
await afterNextRender(() =>
dropFiles(
document.querySelector('.o_Composer_dropZone'),
files
)
dropFiles(document.querySelector('.o_Composer_dropZone'), files)
);
assert.strictEqual(
document.querySelectorAll(`.o_Composer .o_AttachmentCard`).length,
@@ -1305,12 +1235,11 @@ QUnit.test('composer: drop attachments', async function (assert) {
QUnit.test('composer: paste attachments', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -1340,11 +1269,9 @@ QUnit.test('composer: paste attachments', async function (assert) {
QUnit.test('composer text input cleared on message post', async function (assert) {
assert.expect(4);
// channel that is expected to be rendered
// with a random unique id that will be referenced in the test
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start({
data: this.data,
async mockRPC(route, args) {
if (route === '/mail/message/post') {
assert.step('message_post');
@@ -1353,7 +1280,7 @@ QUnit.test('composer text input cleared on message post', async function (assert
},
});
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -1385,13 +1312,13 @@ QUnit.test('composer with thread typing notification status', async function (as
// channel that is expected to be rendered
// with a random unique id that will be referenced in the test
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
await start({
autoOpenDiscuss: true,
data: this.data,
discuss: {
params: {
default_active_id: 20,
default_active_id: `mail.channel_${mailChannelId1}`,
},
},
hasDiscuss: true,
@@ -1414,13 +1341,13 @@ QUnit.test('current partner notify is typing to other thread members', async fun
// channel that is expected to be rendered
// with a random unique id that will be referenced in the test
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
await start({
autoOpenDiscuss: true,
data: this.data,
discuss: {
params: {
default_active_id: 20,
default_active_id: `mail.channel_${mailChannelId1}`,
},
},
hasDiscuss: true,
@@ -1448,13 +1375,13 @@ QUnit.test('current partner is typing should not translate on textual typing sta
// channel that is expected to be rendered
// with a random unique id that will be referenced in the test
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
await start({
autoOpenDiscuss: true,
data: this.data,
discuss: {
params: {
default_active_id: 20,
default_active_id: `mail.channel_${mailChannelId1}`,
},
},
hasDiscuss: true,
@@ -1490,13 +1417,13 @@ QUnit.test('current partner notify no longer is typing to thread members after 5
// channel that is expected to be rendered
// with a random unique id that will be referenced in the test
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { env } = await start({
autoOpenDiscuss: true,
data: this.data,
discuss: {
params: {
default_active_id: 20,
default_active_id: `mail.channel_${mailChannelId1}`,
},
},
hasDiscuss: true,
@@ -1531,13 +1458,13 @@ QUnit.test('current partner notify is typing again to other members every 50s of
// channel that is expected to be rendered
// with a random unique id that will be referenced in the test
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { env } = await start({
autoOpenDiscuss: true,
data: this.data,
discuss: {
params: {
default_active_id: 20,
default_active_id: `mail.channel_${mailChannelId1}`,
},
},
hasDiscuss: true,
@@ -1579,12 +1506,10 @@ QUnit.test('current partner notify is typing again to other members every 50s of
QUnit.test('composer: send button is disabled if attachment upload is not finished', async function (assert) {
assert.expect(8);
const pyEnv = await startServer();
const attachmentUploadedPromise = makeTestPromise();
this.data['mail.channel'].records.push({
id: 20,
});
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start({
data: this.data,
async mockFetch(resource, init) {
const res = this._super(...arguments);
if (resource === '/mail/attachment/upload') {
@@ -1594,7 +1519,7 @@ QUnit.test('composer: send button is disabled if attachment upload is not finish
}
});
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const composerComponent = await createComposerComponent(thread.composer);
@@ -1655,12 +1580,11 @@ QUnit.test('composer: send button is disabled if attachment upload is not finish
QUnit.test('remove an attachment from composer does not need any confirmation', async function (assert) {
assert.expect(3);
this.data['mail.channel'].records.push({
id: 20,
});
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const composerComponent = await createComposerComponent(thread.composer);
@@ -1699,11 +1623,9 @@ QUnit.test('remove an attachment from composer does not need any confirmation',
QUnit.test('remove an uploading attachment', async function (assert) {
assert.expect(4);
this.data['mail.channel'].records.push({
id: 20,
});
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start({
data: this.data,
async mockFetch(resource, init) {
const res = this._super(...arguments);
if (resource === '/mail/attachment/upload') {
@@ -1714,7 +1636,7 @@ QUnit.test('remove an uploading attachment', async function (assert) {
}
});
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const composerComponent = await createComposerComponent(thread.composer);
@@ -1757,11 +1679,9 @@ QUnit.test('remove an uploading attachment', async function (assert) {
QUnit.test('remove an uploading attachment aborts upload', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
id: 20,
});
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { afterEvent, createComposerComponent, messaging } = await start({
data: this.data,
async mockFetch(resource, init) {
const res = this._super(...arguments);
if (resource === '/mail/attachment/upload') {
@@ -1772,7 +1692,7 @@ QUnit.test('remove an uploading attachment aborts upload', async function (asser
}
});
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const composerComponent = await createComposerComponent(thread.composer);
@@ -1809,9 +1729,9 @@ QUnit.test('remove an uploading attachment aborts upload', async function (asser
QUnit.test("Show a default status in the recipient status text when the thread doesn't have a name.", async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({ id: 20 });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
await this.createView({
data: this.data,
hasView: true,
// View params
View: FormView,
@@ -1827,7 +1747,7 @@ QUnit.test("Show a default status in the recipient status text when the thread d
</div>
</form>
`,
res_id: 20,
res_id: resPartnerId1,
});
await afterNextRender(() => document.querySelector('.o_ChatterTopbar_buttonSendMessage').click());
assert.strictEqual(
@@ -1840,9 +1760,9 @@ QUnit.test("Show a default status in the recipient status text when the thread d
QUnit.test("Show a thread name in the recipient status text.", async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({ name: "test name", id: 20 });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: "test name" });
const { messaging } = await this.createView({
data: this.data,
hasView: true,
// View params
View: FormView,
@@ -1858,10 +1778,10 @@ QUnit.test("Show a thread name in the recipient status text.", async function (a
</div>
</form>
`,
res_id: 20,
res_id: resPartnerId1,
});
// hack: provide awareness of name (not received in usual chatter flow)
messaging.models['Thread'].insert({ id: 20, model: 'res.partner', name: "test name", });
messaging.models['Thread'].insert({ id: resPartnerId1, model: 'res.partner', name: "test name" });
await afterNextRender(() => document.querySelector('.o_ChatterTopbar_buttonSendMessage').click());
assert.strictEqual(
document.querySelector('.o_Composer_followers').textContent.replace(/\s+/g, ''),
@@ -1873,9 +1793,9 @@ QUnit.test("Show a thread name in the recipient status text.", async function (a
QUnit.test('send message only once when button send is clicked twice quickly', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start({
data: this.data,
async mockRPC(route, args) {
if (route === '/mail/message/post') {
assert.step('message_post');
@@ -1884,7 +1804,7 @@ QUnit.test('send message only once when button send is clicked twice quickly', a
},
});
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -1910,13 +1830,11 @@ QUnit.test('[technical] does not crash when an attachment is removed before its
// upload started.
assert.expect(1);
const pyEnv = await startServer();
// Promise to block attachment uploading
const uploadPromise = makeTestPromise();
this.data['mail.channel'].records.push({
id: 20,
});
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start({
data: this.data,
async mockFetch(resource) {
const _super = this._super.bind(this, ...arguments);
if (resource === '/mail/attachment/upload') {
@@ -1926,7 +1844,7 @@ QUnit.test('[technical] does not crash when an attachment is removed before its
},
});
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
const composerComponent = await createComposerComponent(thread.composer);
@@ -1966,10 +1884,11 @@ QUnit.test('[technical] does not crash when an attachment is removed before its
QUnit.test('send button on mail.channel should have "Send" as label', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 20 });
const { createComposerComponent, messaging } = await start({ data: this.data });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { createComposerComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await createComposerComponent(thread.composer);
@@ -2,18 +2,13 @@
import { makeDeferred } from '@mail/utils/deferred';
import {
beforeEach,
nextAnimationFrame,
start,
} from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('dialog_manager_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('dialog_manager_tests.js');
QUnit.test('[technical] messaging not created', async function (assert) {
/**
@@ -28,7 +23,6 @@ QUnit.test('[technical] messaging not created', async function (assert) {
const messagingBeforeCreationDeferred = makeDeferred();
await start({
data: this.data,
hasDialog: true,
messagingBeforeCreationDeferred,
waitUntilMessagingCondition: 'none',
@@ -53,10 +47,7 @@ QUnit.test('[technical] messaging not created', async function (assert) {
QUnit.test('initial mount', async function (assert) {
assert.expect(1);
await start({
data: this.data,
hasDialog: true,
});
await start({ hasDialog: true });
assert.containsOnce(
document.body,
'.o_DialogManager',
@@ -2,9 +2,9 @@
import {
afterNextRender,
beforeEach,
nextAnimationFrame,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
import Bus from 'web.Bus';
@@ -12,13 +12,10 @@ import Bus from 'web.Bus';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('discuss_inbox_tests.js', {
async beforeEach() {
await beforeEach(this);
beforeEach() {
this.start = async params => {
return start(Object.assign({}, params, {
autoOpenDiscuss: true,
data: this.data,
hasDiscuss: true,
}));
};
@@ -28,26 +25,24 @@ QUnit.module('discuss_inbox_tests.js', {
QUnit.test('reply: discard on pressing escape', async function (assert) {
assert.expect(9);
const pyEnv = await startServer();
// partner expected to be found by mention
this.data['res.partner'].records.push({
pyEnv['res.partner'].create({
email: "testpartnert@odoo.com",
id: 11,
name: "TestPartner",
});
// message expected to be found in inbox
this.data['mail.message'].records.push({
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
model: 'res.partner',
needaction: true,
needaction_partner_ids: [this.data.currentPartnerId],
needaction_partner_ids: [pyEnv.currentPartnerId],
res_id: 20,
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
waitUntilEvent: {
@@ -154,19 +149,20 @@ QUnit.test('reply: discard on pressing escape', async function (assert) {
QUnit.test('reply: discard on discard button click', async function (assert) {
assert.expect(4);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
model: 'res.partner',
needaction: true,
needaction_partner_ids: [this.data.currentPartnerId],
res_id: 20,
needaction_partner_ids: [pyEnv.currentPartnerId],
res_id: resPartnerId1,
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
waitUntilEvent: {
@@ -215,19 +211,20 @@ QUnit.test('reply: discard on discard button click', async function (assert) {
QUnit.test('reply: discard on reply button toggle', async function (assert) {
assert.expect(3);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
model: 'res.partner',
needaction: true,
needaction_partner_ids: [this.data.currentPartnerId],
res_id: 20,
needaction_partner_ids: [pyEnv.currentPartnerId],
res_id: resPartnerId1,
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
waitUntilEvent: {
@@ -270,19 +267,20 @@ QUnit.test('reply: discard on reply button toggle', async function (assert) {
QUnit.test('reply: discard on click away', async function (assert) {
assert.expect(7);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
model: 'res.partner',
needaction: true,
needaction_partner_ids: [this.data.currentPartnerId],
res_id: 20,
needaction_partner_ids: [pyEnv.currentPartnerId],
res_id: resPartnerId1,
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
waitUntilEvent: {
@@ -357,20 +355,21 @@ QUnit.test('reply: discard on click away', async function (assert) {
QUnit.test('"reply to" composer should log note if message replied to is a note', async function (assert) {
assert.expect(6);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
is_discussion: false,
model: 'res.partner',
needaction: true,
needaction_partner_ids: [this.data.currentPartnerId],
res_id: 20,
needaction_partner_ids: [pyEnv.currentPartnerId],
res_id: resPartnerId1,
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
async mockRPC(route, args) {
@@ -429,20 +428,21 @@ QUnit.test('"reply to" composer should log note if message replied to is a note'
QUnit.test('"reply to" composer should send message if message replied to is not a note', async function (assert) {
assert.expect(6);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
is_discussion: true,
model: 'res.partner',
needaction: true,
needaction_partner_ids: [this.data.currentPartnerId],
res_id: 20,
needaction_partner_ids: [pyEnv.currentPartnerId],
res_id: resPartnerId1,
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
async mockRPC(route, args) {
@@ -501,19 +501,20 @@ QUnit.test('"reply to" composer should send message if message replied to is not
QUnit.test('error notifications should not be shown in Inbox', async function (assert) {
assert.expect(3);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
model: 'mail.channel',
needaction: true,
needaction_partner_ids: [this.data.currentPartnerId],
res_id: 20,
needaction_partner_ids: [pyEnv.currentPartnerId],
res_id: resPartnerId1,
});
this.data['mail.notification'].records.push({
mail_message_id: 100, // id of related message
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1, // id of related message
notification_status: 'exception',
notification_type: 'email',
res_partner_id: this.data.currentPartnerId, // must be for current partner
res_partner_id: pyEnv.currentPartnerId, // must be for current partner
});
await this.start();
assert.containsOnce(
@@ -536,19 +537,19 @@ QUnit.test('error notifications should not be shown in Inbox', async function (a
QUnit.test('show subject of message in Inbox', async function (assert) {
assert.expect(3);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
model: 'mail.channel', // random existing model
model: 'mail.channel',
needaction: true,
needaction_partner_ids: [this.data.currentPartnerId], // not needed, for consistency
subject: "Salutations, voyageur", // will be asserted in the test
needaction_partner_ids: [pyEnv.currentPartnerId], // not needed, for consistency
subject: "Salutations, voyageur",
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
waitUntilEvent: {
@@ -583,19 +584,19 @@ QUnit.test('show subject of message in Inbox', async function (assert) {
QUnit.test('show subject of message in history', async function (assert) {
assert.expect(3);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
history_partner_ids: [3], // not needed, for consistency
id: 100,
model: 'mail.channel', // random existing model
subject: "Salutations, voyageur", // will be asserted in the test
model: 'mail.channel',
subject: "Salutations, voyageur",
});
this.data['mail.notification'].records.push({
pyEnv['mail.notification'].create({
is_read: true,
mail_message_id: 100,
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
discuss: {
@@ -635,6 +636,21 @@ QUnit.test('show subject of message in history', async function (assert) {
QUnit.test('click on (non-channel/non-partner) origin thread link should redirect to form view', async function (assert) {
assert.expect(9);
const pyEnv = await startServer();
const resFakeId1 = pyEnv['res.fake'].create({ name: 'Some record' });
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
model: 'res.fake',
needaction: true,
needaction_partner_ids: [pyEnv.currentPartnerId],
res_id: resFakeId1,
});
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: pyEnv.currentPartnerId,
});
const bus = new Bus();
bus.on('do-action', null, payload => {
// Callback of doing an action (action manager).
@@ -653,30 +669,15 @@ QUnit.test('click on (non-channel/non-partner) origin thread link should redirec
);
assert.strictEqual(
payload.action.res_model,
'some.model',
"action should open view with model 'some.model' (model of message origin thread)"
'res.fake',
"action should open view with model 'res.fake' (model of message origin thread)"
);
assert.strictEqual(
payload.action.res_id,
10,
"action should open view with id 10 (id of message origin thread)"
resFakeId1,
"action should open view with id of resFake1 (id of message origin thread)"
);
});
this.data['some.model'] = { fields: {}, records: [{ id: 10, name: "Some record" }] };
this.data['mail.message'].records.push({
body: "not empty",
id: 100,
model: 'some.model',
needaction: true,
needaction_partner_ids: [this.data.currentPartnerId],
res_id: 10,
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
});
await this.start({
env: {
bus,
@@ -716,23 +717,20 @@ QUnit.test('click on (non-channel/non-partner) origin thread link should redirec
QUnit.test('subject should not be shown when subject is the same as the thread name', async function (assert) {
assert.expect(1);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ name: "Salutations, voyageur" });
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
model: 'mail.channel',
res_id: 100,
res_id: mailChannelId1,
needaction: true,
subject: "Salutations, voyageur",
});
this.data['mail.channel'].records.push({
id: 100,
name: "Salutations, voyageur",
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
waitUntilEvent: {
@@ -757,23 +755,20 @@ QUnit.test('subject should not be shown when subject is the same as the thread n
QUnit.test('subject should not be shown when subject is the same as the thread name and both have the same prefix', async function (assert) {
assert.expect(1);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ name: "Re: Salutations, voyageur" });
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
model: 'mail.channel',
res_id: 100,
res_id: mailChannelId1,
needaction: true,
subject: "Re: Salutations, voyageur",
});
this.data['mail.channel'].records.push({
id: 100,
name: "Re: Salutations, voyageur",
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
waitUntilEvent: {
@@ -798,23 +793,20 @@ QUnit.test('subject should not be shown when subject is the same as the thread n
QUnit.test('subject should not be shown when subject differs from thread name only by the "Re:" prefix', async function (assert) {
assert.expect(1);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ name: "Salutations, voyageur" });
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
model: 'mail.channel',
res_id: 100,
res_id: mailChannelId1,
needaction: true,
subject: "Re: Salutations, voyageur",
});
this.data['mail.channel'].records.push({
id: 100,
name: "Salutations, voyageur",
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
waitUntilEvent: {
@@ -839,23 +831,20 @@ QUnit.test('subject should not be shown when subject differs from thread name on
QUnit.test('subject should not be shown when subject differs from thread name only by the "Fw:" and "Re:" prefix', async function (assert) {
assert.expect(1);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ name: "Salutations, voyageur" });
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
model: 'mail.channel',
res_id: 100,
res_id: mailChannelId1,
needaction: true,
subject: "Fw: Re: Salutations, voyageur",
});
this.data['mail.channel'].records.push({
id: 100,
name: "Salutations, voyageur",
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
waitUntilEvent: {
@@ -880,23 +869,20 @@ QUnit.test('subject should not be shown when subject differs from thread name on
QUnit.test('subject should be shown when the thread name has an extra prefix compared to subject', async function (assert) {
assert.expect(1);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ name: "Re: Salutations, voyageur" });
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
model: 'mail.channel',
res_id: 100,
res_id: mailChannelId1,
needaction: true,
subject: "Salutations, voyageur",
});
this.data['mail.channel'].records.push({
id: 100,
name: "Re: Salutations, voyageur",
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
waitUntilEvent: {
@@ -921,23 +907,20 @@ QUnit.test('subject should be shown when the thread name has an extra prefix com
QUnit.test('subject should not be shown when subject differs from thread name only by the "fw:" prefix and both contain another common prefix', async function (assert) {
assert.expect(1);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ name: "Re: Salutations, voyageur" });
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
model: 'mail.channel',
res_id: 100,
res_id: mailChannelId1,
needaction: true,
subject: "fw: re: Salutations, voyageur",
});
this.data['mail.channel'].records.push({
id: 100,
name: "Re: Salutations, voyageur",
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
waitUntilEvent: {
@@ -962,23 +945,20 @@ QUnit.test('subject should not be shown when subject differs from thread name on
QUnit.test('subject should not be shown when subject differs from thread name only by the "Re: Re:" prefix', async function (assert) {
assert.expect(1);
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ name: "Salutations, voyageur" });
const mailMessageId1 = pyEnv['mail.message'].create({
body: "not empty",
id: 100,
model: 'mail.channel',
res_id: 100,
res_id: mailChannelId1,
needaction: true,
subject: "Re: Re: Salutations, voyageur",
});
this.data['mail.channel'].records.push({
id: 100,
name: "Salutations, voyageur",
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
res_partner_id: pyEnv.currentPartnerId,
});
await this.start({
waitUntilEvent: {
@@ -1,30 +1,26 @@
/** @odoo-module **/
import { beforeEach, start } from '@mail/../tests/helpers/test_utils';
import { start, startServer } from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('discuss_message_edit_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('discuss_message_edit_tests.js');
QUnit.test('click on message edit button should open edit composer', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 20 });
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
pyEnv['mail.message'].create({
body: 'not empty',
message_type: 'comment',
model: 'mail.channel',
res_id: 20,
res_id: mailChannelId1,
});
const { click, openDiscuss } = await start({
data: this.data,
discuss: {
params: {
default_active_id: 'mail.channel_20',
default_active_id: `mail.channel_${mailChannelId1}`,
},
},
hasDiscuss: true,
@@ -2,27 +2,21 @@
import {
afterNextRender,
beforeEach,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('discuss_pinned_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('discuss_pinned_tests.js');
QUnit.test('sidebar: pinned channel 1: init with one pinned channel', async function (assert) {
assert.expect(2);
// channel that is expected to be found in the sidebar
// with a random unique id that will be referenced in the test
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { messaging } = await start({
autoOpenDiscuss: true,
data: this.data,
hasDiscuss: true,
});
assert.containsOnce(
@@ -34,7 +28,7 @@ QUnit.test('sidebar: pinned channel 1: init with one pinned channel', async func
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`,
@@ -45,17 +39,15 @@ QUnit.test('sidebar: pinned channel 1: init with one pinned channel', async func
QUnit.test('sidebar: pinned channel 2: open pinned channel', async function (assert) {
assert.expect(1);
// channel that is expected to be found in the sidebar
// with a random unique id that will be referenced in the test
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { messaging } = await start({
autoOpenDiscuss: true,
data: this.data,
hasDiscuss: true,
});
const threadGeneral = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await afterNextRender(() =>
@@ -73,21 +65,18 @@ QUnit.test('sidebar: pinned channel 2: open pinned channel', async function (ass
QUnit.test('sidebar: pinned channel 3: open channel and leave it', async function (assert) {
assert.expect(6);
// channel that is expected to be found in the sidebar
// with a random unique id that will be referenced in the test
this.data['mail.channel'].records.push({
id: 20,
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({
is_minimized: true,
state: 'open',
});
const { messaging } = await start({
autoOpenDiscuss: true,
data: this.data,
hasDiscuss: true,
async mockRPC(route, args) {
if (args.method === 'action_unfollow') {
assert.step('action_unfollow');
assert.deepEqual(args.args[0], [20],
assert.deepEqual(args.args[0], [mailChannelId1],
"The right id is sent to the server to remove"
);
}
@@ -96,7 +85,7 @@ QUnit.test('sidebar: pinned channel 3: open channel and leave it', async functio
});
const threadGeneral = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await afterNextRender(() =>
@@ -129,16 +118,14 @@ QUnit.test('sidebar: pinned channel 3: open channel and leave it', async functio
QUnit.test('sidebar: unpin channel from bus', async function (assert) {
assert.expect(5);
// channel that is expected to be found in the sidebar
// with a random unique id that will be referenced in the test
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { env, messaging } = await start({
autoOpenDiscuss: true,
data: this.data,
hasDiscuss: true,
});
const threadGeneral = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
@@ -171,7 +158,7 @@ QUnit.test('sidebar: unpin channel from bus', async function (assert) {
type: 'mail.channel/unpin',
payload: {
channel_type: 'channel',
id: 20,
id: mailChannelId1,
name: "General",
public: 'public',
state: 'open',
@@ -198,19 +185,17 @@ QUnit.test('[technical] sidebar: channel group_based_subscription: mandatorily p
// and is_pinned functionalities, especially in python.
// task-2284357
// channel that is expected to be found in the sidebar
this.data['mail.channel'].records.push({
group_based_subscription: true, // expected value for this test
id: 20, // random unique id, will be referenced in the test
is_pinned: false, // expected value for this test
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({
group_based_subscription: true,
is_pinned: false,
});
const { messaging } = await start({
autoOpenDiscuss: true,
data: this.data,
hasDiscuss: true,
});
const threadGeneral = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
assert.containsOnce(
@@ -2,38 +2,31 @@
import {
afterNextRender,
beforeEach,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
import { datetime_to_str } from 'web.time';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('discuss_sidebar_category_item_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('discuss_sidebar_category_item_tests.js');
QUnit.test('channel - avatar: should have correct avatar', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({
avatarCacheKey: '100111',
id: 20,
});
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ avatarCacheKey: '100111' });
const { messaging } = await start({
autoOpenDiscuss: true,
data: this.data,
hasDiscuss: true,
});
const channelItem = document.querySelector(`
.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]
@@ -46,7 +39,7 @@ QUnit.test('channel - avatar: should have correct avatar', async function (asser
assert.strictEqual(
channelItem.querySelector(`:scope .o_DiscussSidebarCategoryItem_image`).dataset.src,
'/web/image/mail.channel/20/avatar_128?unique=100111',
`/web/image/mail.channel/${mailChannelId1}/avatar_128?unique=100111`,
'should link to the correct picture source'
);
});
@@ -54,21 +47,18 @@ QUnit.test('channel - avatar: should have correct avatar', async function (asser
QUnit.test('channel - avatar: should update avatar url from bus', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({
avatarCacheKey: '101010',
id: 20,
});
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({ avatarCacheKey: '101010' });
const { env, messaging } = await start({
const { env, messaging } = await start({
autoOpenDiscuss: true,
data: this.data,
hasDiscuss: true,
});
const channelItemAvatar = document.querySelector(`
.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"] .o_DiscussSidebarCategoryItem_image
@@ -76,49 +66,44 @@ QUnit.test('channel - avatar: should update avatar url from bus', async function
assert.strictEqual(
channelItemAvatar.dataset.src,
'/web/image/mail.channel/20/avatar_128?unique=101010',
`/web/image/mail.channel/${mailChannelId1}/avatar_128?unique=101010`,
);
await afterNextRender(() => {
env.services.rpc({
model: 'mail.channel',
method: 'write',
args: [[20], { image_128: 'This field does not matter' }],
args: [[mailChannelId1], { image_128: 'This field does not matter' }],
});
});
const result = await env.services.rpc({
model: 'mail.channel',
method: 'read',
args: [[20], ['avatarCacheKey']],
});
const result = pyEnv['mail.channel'].searchRead([['id', '=', mailChannelId1]]);
const newCacheKey = result[0]['avatarCacheKey'];
assert.strictEqual(
channelItemAvatar.dataset.src,
`/web/image/mail.channel/20/avatar_128?unique=${newCacheKey}`,
`/web/image/mail.channel/${mailChannelId1}/avatar_128?unique=${newCacheKey}`,
);
});
QUnit.test('chat - avatar: should have correct avatar', async function (assert) {
assert.expect(2);
this.data['res.partner'].records.push({ id: 15, name: "Demo", im_status: 'offline' });
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: "Demo", im_status: 'offline' });
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 10,
members: [this.data.currentPartnerId, 15],
members: [pyEnv.currentPartnerId, resPartnerId1],
public: 'private',
});
const { messaging } = await start({
autoOpenDiscuss: true,
data: this.data,
hasDiscuss: true,
});
const chatItem = document.querySelector(`
.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]
@@ -131,7 +116,7 @@ QUnit.test('chat - avatar: should have correct avatar', async function (assert)
assert.strictEqual(
chatItem.querySelector(`:scope .o_DiscussSidebarCategoryItem_image`).dataset.src,
'/web/image/res.partner/15/avatar_128',
`/web/image/res.partner/${resPartnerId1}/avatar_128`,
'should link to the partner avatar'
);
});
@@ -139,29 +124,30 @@ QUnit.test('chat - avatar: should have correct avatar', async function (assert)
QUnit.test('chat - sorting: should be sorted by last activity time', async function (assert) {
assert.expect(6);
this.data['mail.channel'].records.push({
channel_type: 'chat',
id: 10,
public: 'private',
last_interest_dt: datetime_to_str(new Date(2021, 0, 1)), // less recent one
}, {
channel_type: 'chat',
id: 20,
public: 'private',
last_interest_dt: datetime_to_str(new Date(2021, 0, 2)), // more recent one
});
const pyEnv = await startServer();
const [mailChannelId1, mailChannelId2] = pyEnv['mail.channel'].create([
{
channel_type: 'chat',
public: 'private',
last_interest_dt: datetime_to_str(new Date(2021, 0, 1)), // less recent one
},
{
channel_type: 'chat',
public: 'private',
last_interest_dt: datetime_to_str(new Date(2021, 0, 2)), // more recent one
},
]);
const { messaging } = await start({
autoOpenDiscuss: true,
data: this.data,
hasDiscuss: true,
});
const chat10 = messaging.models['Thread'].findFromIdentifyingData({
id: 10,
const chat1 = messaging.models['Thread'].findFromIdentifyingData({
id: mailChannelId1,
model: 'mail.channel',
});
const chat20 = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
const chat2 = messaging.models['Thread'].findFromIdentifyingData({
id: mailChannelId2,
model: 'mail.channel',
});
const initialChats = document.querySelectorAll('.o_DiscussSidebar_categoryChat .o_DiscussSidebarCategoryItem');
@@ -172,12 +158,12 @@ QUnit.test('chat - sorting: should be sorted by last activity time', async funct
);
assert.strictEqual(
initialChats[0].dataset.threadLocalId,
chat20.localId,
chat2.localId,
"first livechat should be the one with the more recent last activity time"
);
assert.strictEqual(
initialChats[1].dataset.threadLocalId,
chat10.localId,
chat1.localId,
"second chat should be the one with the less recent last activity time"
);
@@ -193,12 +179,12 @@ QUnit.test('chat - sorting: should be sorted by last activity time', async funct
);
assert.strictEqual(
newChats[0].dataset.threadLocalId,
chat10.localId,
chat1.localId,
"first chat should be the one with the more recent last activity time"
);
assert.strictEqual(
newChats[1].dataset.threadLocalId,
chat20.localId,
chat2.localId,
"second chat should be the one with the less recent last activity time"
);
});
@@ -2,20 +2,17 @@
import {
afterNextRender,
beforeEach,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('discuss_sidebar_category_tests.js', {
async beforeEach() {
await beforeEach(this);
beforeEach() {
this.start = async params => {
return start(Object.assign({}, params, {
autoOpenDiscuss: true,
data: this.data,
hasDiscuss: true,
}));
};
@@ -25,7 +22,8 @@ QUnit.module('discuss_sidebar_category_tests.js', {
QUnit.test('channel - counter: should not have a counter if the category is unfolded and without needaction messages', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
pyEnv['mail.channel'].create();
await this.start();
assert.strictEqual(
@@ -38,30 +36,32 @@ QUnit.test('channel - counter: should not have a counter if the category is unfo
QUnit.test('channel - counter: should not have a counter if the category is unfolded and with needaction messagens', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push(
{ id: 20 },
{ id: 30 },
);
this.data['mail.message'].records.push({
body: "message 1",
id: 100,
model: "mail.channel",
res_id: 20,
}, {
body: "message_2",
id: 200,
model: "mail.channel",
res_id: 30,
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
}, {
mail_message_id: 200,
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
});
const pyEnv = await startServer();
const [mailChannelId1, mailChannelId2] = pyEnv['mail.channel'].create([{ name: 'mailChannel1' }, { name: 'mailChannel2' }]);
const [mailMessageId1, mailMessageId2] = pyEnv['mail.message'].create([
{
body: "message 1",
model: "mail.channel",
res_id: mailChannelId1,
},
{
body: "message_2",
model: "mail.channel",
res_id: mailChannelId2,
},
]);
pyEnv['mail.notification'].create([
{
mail_message_id: mailMessageId1,
notification_type: 'inbox',
res_partner_id: pyEnv.currentPartnerId,
},
{
mail_message_id: mailMessageId2,
notification_type: 'inbox',
res_partner_id: pyEnv.currentPartnerId,
},
]);
await this.start();
assert.strictEqual(
document.querySelectorAll(`.o_DiscussSidebar_categoryChannel .o_DiscussSidebarCategory_counter`).length,
@@ -73,9 +73,10 @@ QUnit.test('channel - counter: should not have a counter if the category is unfo
QUnit.test('channel - counter: should not have a counter if category is folded and without needaction messages', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 20 });
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
const pyEnv = await startServer();
pyEnv['mail.channel'].create();
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_channel_open: false,
});
@@ -91,32 +92,34 @@ QUnit.test('channel - counter: should not have a counter if category is folded a
QUnit.test('channel - counter: should have correct value of needaction threads if category is folded and with needaction messages', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push(
{ id: 20 },
{ id: 30 },
);
this.data['mail.message'].records.push({
body: "message 1",
id: 100,
model: "mail.channel",
res_id: 20,
}, {
body: "message_2",
id: 200,
model: "mail.channel",
res_id: 30,
});
this.data['mail.notification'].records.push({
mail_message_id: 100,
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
}, {
mail_message_id: 200,
notification_type: 'inbox',
res_partner_id: this.data.currentPartnerId,
});
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
const pyEnv = await startServer();
const [mailChannelId1, mailChannelId2] = pyEnv['mail.channel'].create([{ name: 'mailChannel1' }, { name: 'mailChannel2' }]);
const [mailMessageId1, mailMessageId2] = pyEnv['mail.message'].create([
{
body: "message 1",
model: "mail.channel",
res_id: mailChannelId1,
},
{
body: "message_2",
model: "mail.channel",
res_id: mailChannelId2,
},
]);
pyEnv['mail.notification'].create([
{
mail_message_id: mailMessageId1,
notification_type: 'inbox',
res_partner_id: pyEnv.currentPartnerId,
},
{
mail_message_id: mailMessageId2,
notification_type: 'inbox',
res_partner_id: pyEnv.currentPartnerId,
},
]);
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_channel_open: false,
});
await this.start();
@@ -143,8 +146,9 @@ QUnit.test('channel - command: should have view command when category is unfolde
QUnit.test('channel - command: should have view command when category is folded', async function (assert) {
assert.expect(1);
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
const pyEnv = await startServer();
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_channel_open: false,
});
await this.start();
@@ -174,8 +178,9 @@ QUnit.test('channel - command: should have add command when category is unfolded
QUnit.test('channel - command: should not have add command when category is folded', async function (assert) {
assert.expect(1);
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
const pyEnv = await startServer();
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_channel_open: false,
});
await this.start();
@@ -190,9 +195,10 @@ QUnit.test('channel - command: should not have add command when category is fold
QUnit.test('channel - states: close manually by clicking the title', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 20 });
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_channel_open: true,
});
const { messaging } = await this.start();
@@ -204,7 +210,7 @@ QUnit.test('channel - states: close manually by clicking the title', async funct
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`,
@@ -215,9 +221,10 @@ QUnit.test('channel - states: close manually by clicking the title', async funct
QUnit.test('channel - states: open manually by clicking the title', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 20 });
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_channel_open: false,
});
const { messaging } = await this.start();
@@ -229,7 +236,7 @@ QUnit.test('channel - states: open manually by clicking the title', async functi
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`,
@@ -240,12 +247,13 @@ QUnit.test('channel - states: open manually by clicking the title', async functi
QUnit.test('channel - states: close should update the value on the server', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({ id: 20 });
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
const pyEnv = await startServer();
pyEnv['mail.channel'].create();
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_channel_open: true,
});
const currentUserId = this.data.currentUserId;
const currentUserId = pyEnv.currentUserId;
const { env } = await this.start();
const initalSettings = await env.services.rpc({
@@ -277,12 +285,13 @@ QUnit.test('channel - states: close should update the value on the server', asyn
QUnit.test('channel - states: open should update the value on the server', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({ id: 20 });
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
const pyEnv = await startServer();
pyEnv['mail.channel'].create();
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_channel_open: false,
});
const currentUserId = this.data.currentUserId;
const currentUserId = pyEnv.currentUserId;
const { env } = await this.start();
const initalSettings = await env.services.rpc({
@@ -314,9 +323,10 @@ QUnit.test('channel - states: open should update the value on the server', async
QUnit.test('channel - states: close from the bus', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 20 });
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_channel_open: true,
});
const { messaging, env } = await this.start();
@@ -333,7 +343,7 @@ QUnit.test('channel - states: close from the bus', async function (assert) {
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`,
@@ -344,9 +354,10 @@ QUnit.test('channel - states: close from the bus', async function (assert) {
QUnit.test('channel - states: open from the bus', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 20 });
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_channel_open: false,
});
const { env, messaging } = await this.start();
@@ -363,7 +374,7 @@ QUnit.test('channel - states: open from the bus', async function (assert) {
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`,
@@ -374,14 +385,15 @@ QUnit.test('channel - states: open from the bus', async function (assert) {
QUnit.test('channel - states: the active category item should be visble even if the category is closed', async function (assert) {
assert.expect(4);
this.data['mail.channel'].records.push({ id: 20 });
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const { messaging } = await this.start();
assert.containsOnce(
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`
@@ -389,7 +401,7 @@ QUnit.test('channel - states: the active category item should be visble even if
const channel = document.querySelector(`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`);
@@ -406,7 +418,7 @@ QUnit.test('channel - states: the active category item should be visble even if
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`,
@@ -423,7 +435,7 @@ QUnit.test('channel - states: the active category item should be visble even if
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`,
@@ -434,9 +446,9 @@ QUnit.test('channel - states: the active category item should be visble even if
QUnit.test('chat - counter: should not have a counter if the category is unfolded and without unread messages', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 10,
message_unread_counter: 0,
public: 'private',
});
@@ -452,9 +464,9 @@ QUnit.test('chat - counter: should not have a counter if the category is unfolde
QUnit.test('chat - counter: should not have a counter if the category is unfolded and with unread messagens', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 10,
message_unread_counter: 10,
public: 'private',
});
@@ -469,9 +481,9 @@ QUnit.test('chat - counter: should not have a counter if the category is unfolde
QUnit.test('chat - counter: should not have a counter if category is folded and without unread messages', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 10,
message_unread_counter: 0,
public: 'private',
});
@@ -491,17 +503,19 @@ QUnit.test('chat - counter: should not have a counter if category is folded and
QUnit.test('chat - counter: should have correct value of unread threads if category is folded and with unread messages', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
channel_type: 'chat',
id: 10,
message_unread_counter: 10,
public: 'private',
}, {
channel_type: 'chat',
id: 20,
message_unread_counter: 20,
public: 'private',
});
const pyEnv = await startServer();
pyEnv['mail.channel'].create([
{
channel_type: 'chat',
message_unread_counter: 10,
public: 'private',
},
{
channel_type: 'chat',
message_unread_counter: 20,
public: 'private',
},
]);
await this.start();
await afterNextRender(() => {
@@ -528,8 +542,9 @@ QUnit.test('chat - command: should have add command when category is unfolded',
QUnit.test('chat - command: should not have add command when category is folded', async function (assert) {
assert.expect(1);
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
const pyEnv = await startServer();
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_chat_open: false,
});
await this.start();
@@ -544,14 +559,14 @@ QUnit.test('chat - command: should not have add command when category is folded'
QUnit.test('chat - states: close manually by clicking the title', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 10,
message_unread_counter: 0,
public: 'private',
});
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_chat_open: true,
});
const { messaging } = await this.start();
@@ -563,7 +578,7 @@ QUnit.test('chat - states: close manually by clicking the title', async function
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`,
@@ -574,14 +589,14 @@ QUnit.test('chat - states: close manually by clicking the title', async function
QUnit.test('chat - states: open manually by clicking the title', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 10,
message_unread_counter: 0,
public: 'private',
});
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_chat_open: false,
});
const { messaging } = await this.start();
@@ -593,7 +608,7 @@ QUnit.test('chat - states: open manually by clicking the title', async function
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`,
@@ -604,12 +619,13 @@ QUnit.test('chat - states: open manually by clicking the title', async function
QUnit.test('chat - states: close should call update server data', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({ id: 20 });
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
const pyEnv = await startServer();
pyEnv['mail.channel'].create();
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_chat_open: true,
});
const currentUserId = this.data.currentUserId;
const currentUserId = pyEnv.currentUserId;
const { env } = await this.start();
const initalSettings = await env.services.rpc({
@@ -641,18 +657,18 @@ QUnit.test('chat - states: close should call update server data', async function
QUnit.test('chat - states: open should call update server data', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({ id: 20 });
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
const pyEnv = await startServer();
pyEnv['mail.channel'].create();
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_chat_open: false,
});
const currentUserId = this.data.currentUserId;
const { env } = await this.start();
const initalSettings = await env.services.rpc({
model: 'res.users.settings',
method: '_find_or_create_for_user',
args: [[currentUserId]],
args: [[pyEnv.currentUserId]],
});
assert.strictEqual(
initalSettings.is_discuss_sidebar_category_chat_open,
@@ -666,7 +682,7 @@ QUnit.test('chat - states: open should call update server data', async function
const newSettings = await env.services.rpc({
model: 'res.users.settings',
method: '_find_or_create_for_user',
args: [[currentUserId]],
args: [[pyEnv.currentUserId]],
});
assert.strictEqual(
newSettings.is_discuss_sidebar_category_chat_open,
@@ -678,14 +694,14 @@ QUnit.test('chat - states: open should call update server data', async function
QUnit.test('chat - states: close from the bus', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 10,
message_unread_counter: 0,
public: 'private',
});
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_chat_open: true,
});
const { env, messaging } = await this.start();
@@ -702,7 +718,7 @@ QUnit.test('chat - states: close from the bus', async function (assert) {
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`,
@@ -713,14 +729,14 @@ QUnit.test('chat - states: close from the bus', async function (assert) {
QUnit.test('chat - states: open from the bus', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 10,
message_unread_counter: 0,
public: 'private',
});
this.data['res.users.settings'].records.push({
user_id: this.data.currentUserId,
pyEnv['res.users.settings'].create({
user_id: pyEnv.currentUserId,
is_discuss_sidebar_category_chat_open: false,
});
const { env, messaging } = await this.start();
@@ -737,7 +753,7 @@ QUnit.test('chat - states: open from the bus', async function (assert) {
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`,
@@ -748,9 +764,9 @@ QUnit.test('chat - states: open from the bus', async function (assert) {
QUnit.test('chat - states: the active category item should be visble even if the category is closed', async function (assert) {
assert.expect(4);
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 10,
message_unread_counter: 0,
public: 'private',
});
@@ -760,7 +776,7 @@ QUnit.test('chat - states: the active category item should be visble even if the
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`
@@ -768,7 +784,7 @@ QUnit.test('chat - states: the active category item should be visble even if the
const chat = document.querySelector(`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`);
@@ -785,7 +801,7 @@ QUnit.test('chat - states: the active category item should be visble even if the
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`,
@@ -802,7 +818,7 @@ QUnit.test('chat - states: the active category item should be visble even if the
document.body,
`.o_DiscussSidebarCategoryItem[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]`,
@@ -3,25 +3,21 @@
import { makeDeferred } from '@mail/utils/deferred';
import {
afterNextRender,
beforeEach,
nextAnimationFrame,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('discuss_sidebar_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('discuss_sidebar_tests.js');
QUnit.test('sidebar find shows channels matching search term', async function (assert) {
assert.expect(3);
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
pyEnv['mail.channel'].create({
channel_type: 'channel',
id: 20,
members: [],
name: 'test',
public: 'public',
@@ -29,7 +25,6 @@ QUnit.test('sidebar find shows channels matching search term', async function (a
const searchReadDef = makeDeferred();
await start({
autoOpenDiscuss: true,
data: this.data,
hasDiscuss: true,
async mockRPC(route, args) {
const res = await this._super(...arguments);
@@ -74,17 +69,16 @@ QUnit.test('sidebar find shows channels matching search term', async function (a
QUnit.test('sidebar find shows channels matching search term even when user is member', async function (assert) {
assert.expect(3);
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
pyEnv['mail.channel'].create({
channel_type: 'channel',
id: 20,
members: [this.data.currentPartnerId],
members: [pyEnv.currentPartnerId],
name: 'test',
public: 'public',
});
const searchReadDef = makeDeferred();
await start({
autoOpenDiscuss: true,
data: this.data,
hasDiscuss: true,
async mockRPC(route, args) {
const res = await this._super(...arguments);
@@ -129,15 +123,15 @@ QUnit.test('sidebar find shows channels matching search term even when user is m
QUnit.test('sidebar channels should be ordered case insensitive alphabetically', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push(
{ id: 19, name: "Xyz" },
{ id: 20, name: "abc" },
{ id: 21, name: "Abc" },
{ id: 22, name: "Xyz" }
);
const pyEnv = await startServer();
pyEnv['mail.channel'].create([
{ name: "Xyz" },
{ name: "abc" },
{ name: "Abc" },
{ name: "Xyz" },
]);
await start({
autoOpenDiscuss: true,
data: this.data,
hasDiscuss: true,
});
const results = document.querySelectorAll('.o_DiscussSidebar_categoryChannel .o_DiscussSidebarCategoryItem_name');
@@ -2,17 +2,15 @@
import {
afterNextRender,
beforeEach,
createRootMessagingComponent,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('follow_button_tests.js', {
async beforeEach() {
await beforeEach(this);
beforeEach() {
this.createFollowButtonComponent = async (thread, target, otherProps = {}) => {
const props = Object.assign({ threadLocalId: thread.localId }, otherProps);
await createRootMessagingComponent(thread.env, "FollowButton", {
@@ -26,7 +24,7 @@ QUnit.module('follow_button_tests.js', {
QUnit.test('base rendering not editable', async function (assert) {
assert.expect(3);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
id: 100,
model: 'res.partner',
@@ -51,7 +49,7 @@ QUnit.test('base rendering not editable', async function (assert) {
QUnit.test('base rendering editable', async function (assert) {
assert.expect(3);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
id: 100,
model: 'res.partner',
@@ -76,17 +74,17 @@ QUnit.test('base rendering editable', async function (assert) {
QUnit.test('hover following button', async function (assert) {
assert.expect(8);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.followers'].records.push({
id: 1,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.followers'].create({
is_active: true,
partner_id: this.data.currentPartnerId,
res_id: 100,
partner_id: pyEnv.currentPartnerId,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
id: 100,
id: resPartnerId1,
model: 'res.partner',
});
thread.follow();
@@ -143,16 +141,15 @@ QUnit.test('hover following button', async function (assert) {
QUnit.test('click on "follow" button', async function (assert) {
assert.expect(6);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.followers'].records.push({
id: 1,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.followers'].create({
is_active: true,
partner_id: this.data.currentPartnerId,
res_id: 100,
partner_id: pyEnv.currentPartnerId,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { messaging, widget } = await start({
data: this.data,
async mockRPC(route, args) {
if (route.includes('message_subscribe')) {
assert.step('rpc:message_subscribe');
@@ -161,7 +158,7 @@ QUnit.test('click on "follow" button', async function (assert) {
},
});
const thread = messaging.models['Thread'].create({
id: 100,
id: resPartnerId1,
model: 'res.partner',
});
await this.createFollowButtonComponent(thread, widget.el);
@@ -197,16 +194,15 @@ QUnit.test('click on "follow" button', async function (assert) {
QUnit.test('click on "unfollow" button', async function (assert) {
assert.expect(7);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.followers'].records.push({
id: 1,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.followers'].create({
is_active: true,
partner_id: this.data.currentPartnerId,
res_id: 100,
partner_id: pyEnv.currentPartnerId,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { messaging, widget } = await start({
data: this.data,
async mockRPC(route, args) {
if (route.includes('message_unsubscribe')) {
assert.step('rpc:message_unsubscribe');
@@ -215,7 +211,7 @@ QUnit.test('click on "unfollow" button', async function (assert) {
},
});
const thread = messaging.models['Thread'].create({
id: 100,
id: resPartnerId1,
model: 'res.partner',
});
thread.follow();
@@ -3,9 +3,9 @@
import { insert, link } from '@mail/model/model_field_command';
import {
afterNextRender,
beforeEach,
createRootMessagingComponent,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
import Bus from 'web.Bus';
@@ -13,9 +13,7 @@ import Bus from 'web.Bus';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('follower_list_menu_tests.js', {
async beforeEach() {
await beforeEach(this);
beforeEach() {
this.createFollowerListMenuComponent = async (thread, target, otherProps = {}) => {
const props = Object.assign({ threadLocalId: thread.localId }, otherProps);
await createRootMessagingComponent(thread.env, "FollowerListMenu", {
@@ -29,7 +27,7 @@ QUnit.module('follower_list_menu_tests.js', {
QUnit.test('base rendering not editable', async function (assert) {
assert.expect(5);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
id: 100,
model: 'res.partner',
@@ -66,7 +64,7 @@ QUnit.test('base rendering not editable', async function (assert) {
QUnit.test('base rendering editable', async function (assert) {
assert.expect(5);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
id: 100,
model: 'res.partner',
@@ -107,6 +105,19 @@ QUnit.test('base rendering editable', async function (assert) {
QUnit.test('click on "add followers" button', async function (assert) {
assert.expect(15);
const pyEnv = await startServer();
const [resPartnerId1, resPartnerId2] = pyEnv['res.partner'].create([
{ name: 'resPartner1'},
{ name: 'resPartner2' },
]);
const mailFollowerId1 = pyEnv['mail.followers'].create({
partner_id: resPartnerId2,
email: "bla@bla.bla",
is_active: true,
name: "François Perusse",
res_id: resPartnerId1,
res_model: 'res.partner',
});
const bus = new Bus();
bus.on('do-action', null, payload => {
assert.step('action:open_view');
@@ -117,7 +128,7 @@ QUnit.test('click on "add followers" button', async function (assert) {
);
assert.strictEqual(
payload.action.context.default_res_id,
100,
resPartnerId1,
"The 'add followers' action should contain thread id in context"
);
assert.strictEqual(
@@ -130,26 +141,13 @@ QUnit.test('click on "add followers" button', async function (assert) {
"ir.actions.act_window",
"The 'add followers' action should be of type 'ir.actions.act_window'"
);
const partner = this.data['res.partner'].records.find(
partner => partner.id === payload.action.context.default_res_id
);
partner.message_follower_ids.push(1);
pyEnv['res.partner'].write([payload.action.context.default_res_id], { message_follower_ids: [mailFollowerId1] });
payload.options.on_close();
});
this.data['res.partner'].records.push({ id: 100 }, { id: 42 });
this.data['mail.followers'].records.push({
partner_id: 42,
email: "bla@bla.bla",
id: 1,
is_active: true,
name: "François Perusse",
res_id: 100,
res_model: 'res.partner',
});
const { messaging, widget } = await start({ data: this.data, env: { bus } });
const { messaging, widget } = await start({ env: { bus } });
const thread = messaging.models['Thread'].create({
hasWriteAccess: true,
id: 100,
id: resPartnerId1,
model: 'res.partner',
});
await this.createFollowerListMenuComponent(thread, widget.el);
@@ -219,15 +217,15 @@ QUnit.test('click on "add followers" button', async function (assert) {
QUnit.test('click on remove follower', async function (assert) {
assert.expect(6);
this.data['res.partner'].records.push({ id: 100 });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { messaging, widget } = await start({
data: this.data,
async mockRPC(route, args) {
if (route.includes('message_unsubscribe')) {
assert.step('message_unsubscribe');
assert.deepEqual(
args.args,
[[100], [messaging.currentPartner.id]],
[[resPartnerId1], [messaging.currentPartner.id]],
"message_unsubscribe should be called with right argument"
);
}
@@ -235,7 +233,7 @@ QUnit.test('click on remove follower', async function (assert) {
},
});
const thread = messaging.models['Thread'].create({
id: 100,
id: resPartnerId1,
model: 'res.partner',
});
await messaging.models['Follower'].create({
@@ -281,26 +279,25 @@ QUnit.test('click on remove follower', async function (assert) {
QUnit.test('Hide "Add follower" and subtypes edition/removal buttons except own user on read only record', async function (assert) {
assert.expect(5);
this.data['res.partner'].records.push({ id: 100 }, { id: 11 });
this.data['mail.followers'].records.push(
const pyEnv = await startServer();
const [resPartnerId1, resPartnerId2] = pyEnv['res.partner'].create([{ name: "resPartner1" }, { name: "resPartner2" }]);
pyEnv['mail.followers'].create([
{
id: 1,
name: "Jean Michang",
is_active: true,
partner_id: this.data.currentPartnerId,
res_id: 100,
res_model: 'res.partner',
}, {
id: 2,
name: "Eden Hazard",
is_active: true,
partner_id: 11,
res_id: 100,
partner_id: pyEnv.currentPartnerId,
res_id: resPartnerId1,
res_model: 'res.partner',
},
);
{
name: "Eden Hazard",
is_active: true,
partner_id: resPartnerId2,
res_id: resPartnerId1,
res_model: 'res.partner',
},
]);
const { click, createChatterContainerComponent } = await start({
data: this.data,
async mockRPC(route, args) {
if (route === '/mail/thread/data') {
// mimic user with no write access
@@ -312,7 +309,7 @@ QUnit.test('Hide "Add follower" and subtypes edition/removal buttons except own
},
});
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
@@ -348,26 +345,25 @@ QUnit.test('Hide "Add follower" and subtypes edition/removal buttons except own
QUnit.test('Show "Add follower" and subtypes edition/removal buttons on all followers if user has write access', async function (assert) {
assert.expect(5);
this.data['res.partner'].records.push({ id: 100 }, { id: 11 });
this.data['mail.followers'].records.push(
const pyEnv = await startServer();
const [resPartnerId1, resPartnerId2] = pyEnv['res.partner'].create([{ name: "resPartner1" }, { name: "resPartner2" }]);
pyEnv['mail.followers'].create([
{
id: 1,
name: "Jean Michang",
is_active: true,
partner_id: this.data.currentPartnerId,
res_id: 100,
res_model: 'res.partner',
}, {
id: 2,
name: "Eden Hazard",
is_active: true,
partner_id: 11,
res_id: 100,
partner_id: pyEnv.currentPartnerId,
res_id: resPartnerId1,
res_model: 'res.partner',
},
);
{
name: "Eden Hazard",
is_active: true,
partner_id: resPartnerId2,
res_id: resPartnerId1,
res_model: 'res.partner',
},
]);
const { click, createChatterContainerComponent } = await start({
data: this.data,
async mockRPC(route, args) {
if (route === '/mail/thread/data') {
// mimic user with write access
@@ -379,7 +375,7 @@ QUnit.test('Show "Add follower" and subtypes edition/removal buttons on all foll
},
});
await createChatterContainerComponent({
threadId: 100,
threadId: resPartnerId1,
threadModel: 'res.partner',
});
@@ -415,7 +411,7 @@ QUnit.test('Show "Add follower" and subtypes edition/removal buttons on all foll
QUnit.test('Show "No Followers" dropdown-item if there are no followers and user dose not have write access', async function (assert) {
assert.expect(1);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
id: 100,
model: 'res.partner',
@@ -3,7 +3,6 @@
import { insert, link } from '@mail/model/model_field_command';
import {
afterNextRender,
beforeEach,
createRootMessagingComponent,
start,
} from '@mail/../tests/helpers/test_utils';
@@ -11,9 +10,7 @@ import {
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('follower_subtype_tests.js', {
async beforeEach() {
await beforeEach(this);
beforeEach() {
this.createFollowerSubtypeComponent = async ({ follower, followerSubtype, target }) => {
const props = {
followerLocalId: follower.localId,
@@ -30,7 +27,7 @@ QUnit.module('follower_subtype_tests.js', {
QUnit.test('simplest layout of a followed subtype', async function (assert) {
assert.expect(5);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
id: 100,
@@ -90,7 +87,7 @@ QUnit.test('simplest layout of a followed subtype', async function (assert) {
QUnit.test('simplest layout of a not followed subtype', async function (assert) {
assert.expect(5);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
id: 100,
@@ -147,7 +144,7 @@ QUnit.test('simplest layout of a not followed subtype', async function (assert)
QUnit.test('toggle follower subtype checkbox', async function (assert) {
assert.expect(5);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
id: 100,
@@ -4,9 +4,9 @@ import { insert, link } from '@mail/model/model_field_command';
import { makeDeferred } from '@mail/utils/deferred';
import {
afterNextRender,
beforeEach,
createRootMessagingComponent,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
import Bus from 'web.Bus';
@@ -14,9 +14,7 @@ import Bus from 'web.Bus';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('follower_tests.js', {
async beforeEach() {
await beforeEach(this);
beforeEach() {
this.createFollowerComponent = async (follower, target) => {
await createRootMessagingComponent(follower.env, "Follower", {
props: { followerLocalId: follower.localId },
@@ -29,7 +27,7 @@ QUnit.module('follower_tests.js', {
QUnit.test('base rendering not editable', async function (assert) {
assert.expect(5);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
hasWriteAccess: false,
@@ -76,7 +74,7 @@ QUnit.test('base rendering not editable', async function (assert) {
QUnit.test('base rendering editable', async function (assert) {
assert.expect(6);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
hasWriteAccess: true,
id: 100,
@@ -148,10 +146,11 @@ QUnit.test('click on partner follower details', async function (assert) {
);
openFormDef.resolve();
});
this.data['res.partner'].records.push({ id: 100 });
const { messaging, widget } = await start({ data: this.data, env: { bus } });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { messaging, widget } = await start({ env: { bus } });
const thread = messaging.models['Thread'].create({
id: 100,
id: resPartnerId1,
model: 'res.partner',
});
const follower = await messaging.models['Follower'].create({
@@ -187,16 +186,15 @@ QUnit.test('click on partner follower details', async function (assert) {
QUnit.test('click on edit follower', async function (assert) {
assert.expect(5);
this.data['res.partner'].records.push({ id: 100 });
this.data['mail.followers'].records.push({
id: 2,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['mail.followers'].create({
is_active: true,
partner_id: this.data.currentPartnerId,
res_id: 100,
partner_id: pyEnv.currentPartnerId,
res_id: resPartnerId1,
res_model: 'res.partner',
});
const { messaging, widget } = await start({
data: this.data,
hasDialog: true,
async mockRPC(route, args) {
if (route.includes('/mail/read_subscription_data')) {
@@ -206,7 +204,7 @@ QUnit.test('click on edit follower', async function (assert) {
},
});
const thread = messaging.models['Thread'].create({
id: 100,
id: resPartnerId1,
model: 'res.partner',
});
await thread.fetchData(['followers']);
@@ -237,9 +235,9 @@ QUnit.test('click on edit follower', async function (assert) {
QUnit.test('edit follower and close subtype dialog', async function (assert) {
assert.expect(6);
this.data['res.partner'].records.push({ id: 100 });
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const { messaging, widget } = await start({
data: this.data,
hasDialog: true,
async mockRPC(route, args) {
if (route.includes('/mail/read_subscription_data')) {
@@ -257,7 +255,7 @@ QUnit.test('edit follower and close subtype dialog', async function (assert) {
},
});
const thread = messaging.models['Thread'].create({
id: 100,
id: resPartnerId1,
model: 'res.partner',
});
const follower = await messaging.models['Follower'].create({
@@ -2,7 +2,6 @@
import { insert, insertAndReplace, link } from '@mail/model/model_field_command';
import {
beforeEach,
createRootMessagingComponent,
start,
} from '@mail/../tests/helpers/test_utils';
@@ -10,9 +9,7 @@ import {
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('message_seen_indicator_tests.js', {
async beforeEach() {
await beforeEach(this);
beforeEach() {
this.createMessageSeenIndicatorComponent = async ({ message, target, thread }, otherProps) => {
const props = Object.assign(
{ messageLocalId: message.localId, threadLocalId: thread.localId },
@@ -29,7 +26,7 @@ QUnit.module('message_seen_indicator_tests.js', {
QUnit.test('rendering when just one has received the message', async function (assert) {
assert.expect(3);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
id: 1000,
model: 'mail.channel',
@@ -73,7 +70,7 @@ QUnit.test('rendering when just one has received the message', async function (a
QUnit.test('rendering when everyone have received the message', async function (assert) {
assert.expect(3);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
id: 1000,
model: 'mail.channel',
@@ -118,7 +115,7 @@ QUnit.test('rendering when everyone have received the message', async function (
QUnit.test('rendering when just one has seen the message', async function (assert) {
assert.expect(3);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
id: 1000,
model: 'mail.channel',
@@ -165,7 +162,7 @@ QUnit.test('rendering when just one has seen the message', async function (asser
QUnit.test('rendering when just one has seen & received the message', async function (assert) {
assert.expect(3);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
id: 1000,
model: 'mail.channel',
@@ -211,7 +208,7 @@ QUnit.test('rendering when just one has seen & received the message', async func
QUnit.test('rendering when just everyone has seen the message', async function (assert) {
assert.expect(3);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].create({
id: 1000,
model: 'mail.channel',
@@ -4,26 +4,22 @@ import { insert, insertAndReplace, link, replace } from '@mail/model/model_field
import { makeDeferred } from '@mail/utils/deferred';
import {
afterNextRender,
beforeEach,
createRootMessagingComponent,
nextAnimationFrame,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
import Bus from 'web.Bus';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('message_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('message_tests.js');
QUnit.test('basic rendering', async function (assert) {
assert.expect(12);
const { createMessageComponent, messaging } = await start({ data: this.data });
const { createMessageComponent, messaging } = await start();
const message = messaging.models['Message'].create({
author: insert({ id: 7, display_name: "Demo User" }),
body: "<p>Test</p>",
@@ -98,25 +94,24 @@ QUnit.test('basic rendering', async function (assert) {
QUnit.test('Notification Sent', async function (assert) {
assert.expect(9);
this.data['res.partner'].records.push({ id: 12, name: "Someone", partner_share: true });
this.data['mail.channel'].records.push({ id: 11 });
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const resPartnerId1 = pyEnv['res.partner'].create({ name: 'Someone', partner_share: true });
const mailMessageId1 = pyEnv['mail.message'].create({
body: 'not empty',
id: 10,
message_type: 'email',
model: 'mail.channel',
res_id: 11,
res_id: mailChannelId1,
});
this.data['mail.notification'].records.push({
id: 11,
mail_message_id: 10,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'sent',
notification_type: 'email',
res_partner_id: 12,
res_partner_id: resPartnerId1,
});
const { createThreadViewComponent, messaging } = await start({ data: this.data });
const { createThreadViewComponent, messaging } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 11,
id: mailChannelId1,
model: 'mail.channel',
});
const threadViewer = messaging.models['ThreadViewer'].create({
@@ -180,6 +175,21 @@ QUnit.test('Notification Sent', async function (assert) {
QUnit.test('Notification Error', async function (assert) {
assert.expect(8);
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: "Someone", partner_share: true });
const mailChannelId1 = pyEnv['mail.channel'].create();
const mailMessageId1 = pyEnv['mail.message'].create({
body: 'not empty',
message_type: 'email',
model: 'mail.channel',
res_id: mailChannelId1,
});
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'exception',
notification_type: 'email',
res_partner_id: resPartnerId1,
});
const openResendActionDef = makeDeferred();
const bus = new Bus();
bus.on('do-action', null, payload => {
@@ -191,31 +201,14 @@ QUnit.test('Notification Error', async function (assert) {
);
assert.strictEqual(
payload.options.additional_context.mail_message_to_resend,
10,
mailMessageId1,
"action should have correct message id"
);
openResendActionDef.resolve();
});
this.data['res.partner'].records.push({ id: 12, name: "Someone", partner_share: true });
this.data['mail.channel'].records.push({ id: 11 });
this.data['mail.message'].records.push({
body: 'not empty',
id: 10,
message_type: 'email',
model: 'mail.channel',
res_id: 11,
});
this.data['mail.notification'].records.push({
id: 11,
mail_message_id: 10,
notification_status: 'exception',
notification_type: 'email',
res_partner_id: 12,
});
const { createThreadViewComponent, messaging } = await start({ data: this.data, env: { bus } });
const { createThreadViewComponent, messaging } = await start({ env: { bus } });
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 11,
id: mailChannelId1,
model: 'mail.channel',
});
const threadViewer = messaging.models['ThreadViewer'].create({
@@ -256,22 +249,19 @@ QUnit.test('Notification Error', async function (assert) {
QUnit.test("'channel_fetch' notification received is correctly handled", async function (assert) {
assert.expect(3);
this.data['res.partner'].records.push({
display_name: "Recipient",
id: 11,
});
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ display_name: "Recipient" });
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 11,
members: [this.data.currentPartnerId, 11],
members: [pyEnv.currentPartnerId, resPartnerId1],
});
const { createThreadViewComponent, messaging, widget } = await start({ data: this.data });
const { createThreadViewComponent, messaging, widget } = await start();
const currentPartner = messaging.models['Partner'].insert({
id: messaging.currentPartner.id,
display_name: "Demo User",
});
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 11,
id: mailChannelId1,
model: 'mail.channel',
});
const threadViewer = messaging.models['ThreadViewer'].create({
@@ -304,9 +294,9 @@ QUnit.test("'channel_fetch' notification received is correctly handled", async f
widget.call('bus_service', 'trigger', 'notification', [{
type: 'mail.channel.partner/fetched',
payload: {
channel_id: 11,
channel_id: mailChannelId1,
last_message_id: 100,
partner_id: 11,
partner_id: resPartnerId1,
},
}]);
});
@@ -321,22 +311,19 @@ QUnit.test("'channel_fetch' notification received is correctly handled", async f
QUnit.test("'channel_seen' notification received is correctly handled", async function (assert) {
assert.expect(3);
this.data['res.partner'].records.push({
display_name: "Recipient",
id: 11,
});
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ display_name: "Recipient" });
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 11,
members: [this.data.currentPartnerId, 11],
members: [pyEnv.currentPartnerId, resPartnerId1],
});
const { createThreadViewComponent, messaging, widget } = await start({ data: this.data });
const { createThreadViewComponent, messaging, widget } = await start();
const currentPartner = messaging.models['Partner'].insert({
id: messaging.currentPartner.id,
display_name: "Demo User",
});
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 11,
id: mailChannelId1,
model: 'mail.channel',
});
const threadViewer = messaging.models['ThreadViewer'].create({
@@ -368,9 +355,9 @@ QUnit.test("'channel_seen' notification received is correctly handled", async fu
widget.call('bus_service', 'trigger', 'notification', [{
type: 'mail.channel.partner/seen',
payload: {
channel_id: 11,
channel_id: mailChannelId1,
last_message_id: 100,
partner_id: 11,
partner_id: resPartnerId1,
},
}]);
});
@@ -385,22 +372,19 @@ QUnit.test("'channel_seen' notification received is correctly handled", async fu
QUnit.test("'channel_fetch' notification then 'channel_seen' received are correctly handled", async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({
display_name: "Recipient",
id: 11,
});
this.data['mail.channel'].records.push({
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ display_name: "Recipient" });
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 11,
members: [this.data.currentPartnerId, 11],
members: [pyEnv.currentPartnerId, resPartnerId1],
});
const { createThreadViewComponent, messaging, widget } = await start({ data: this.data });
const { createThreadViewComponent, messaging, widget } = await start();
const currentPartner = messaging.models['Partner'].insert({
id: messaging.currentPartner.id,
display_name: "Demo User",
});
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 11,
id: mailChannelId1,
model: 'mail.channel',
});
const threadViewer = messaging.models['ThreadViewer'].create({
@@ -432,9 +416,9 @@ QUnit.test("'channel_fetch' notification then 'channel_seen' received are corre
widget.call('bus_service', 'trigger', 'notification', [{
type: 'mail.channel.partner/fetched',
payload: {
channel_id: 11,
channel_id: mailChannelId1,
last_message_id: 100,
partner_id: 11,
partner_id: resPartnerId1,
}
}]);
});
@@ -449,9 +433,9 @@ QUnit.test("'channel_fetch' notification then 'channel_seen' received are corre
widget.call('bus_service', 'trigger', 'notification', [{
type: 'mail.channel.partner/seen',
payload: {
channel_id: 11,
channel_id: mailChannelId1,
last_message_id: 100,
partner_id: 11,
partner_id: resPartnerId1,
},
}]);
});
@@ -466,7 +450,7 @@ QUnit.test("'channel_fetch' notification then 'channel_seen' received are corre
QUnit.test('do not show messaging seen indicator if not authored by me', async function (assert) {
assert.expect(2);
const { createThreadViewComponent, messaging } = await start({ data: this.data });
const { createThreadViewComponent, messaging } = await start();
const author = messaging.models['Partner'].create({
id: 100,
display_name: "Demo User"
@@ -514,7 +498,7 @@ QUnit.test('do not show messaging seen indicator if not authored by me', async f
QUnit.test('do not show messaging seen indicator if before last seen by all message', async function (assert) {
assert.expect(3);
const { env, messaging, widget } = await start({ data: this.data });
const { env, messaging, widget } = await start();
const currentPartner = messaging.models['Partner'].insert({
id: messaging.currentPartner.id,
display_name: "Demo User",
@@ -581,7 +565,7 @@ QUnit.test('do not show messaging seen indicator if before last seen by all mess
QUnit.test('only show messaging seen indicator if authored by me, after last seen by all message', async function (assert) {
assert.expect(3);
const { createThreadViewComponent, messaging } = await start({ data: this.data });
const { createThreadViewComponent, messaging } = await start();
const currentPartner = messaging.models['Partner'].insert({
id: messaging.currentPartner.id,
display_name: "Demo User"
@@ -639,7 +623,7 @@ QUnit.test('only show messaging seen indicator if authored by me, after last see
QUnit.test('allow attachment delete on authored message', async function (assert) {
assert.expect(5);
const { createMessageComponent, messaging } = await start({ data: this.data, hasDialog: true });
const { createMessageComponent, messaging } = await start({ hasDialog: true });
const message = messaging.models['Message'].create({
attachments: insertAndReplace({
filename: "BLAH.jpg",
@@ -689,7 +673,7 @@ QUnit.test('allow attachment delete on authored message', async function (assert
QUnit.test('prevent attachment delete on non-authored message in channels', async function (assert) {
assert.expect(2);
const { createMessageComponent, messaging } = await start({ data: this.data });
const { createMessageComponent, messaging } = await start();
const message = messaging.models['Message'].create({
attachments: insertAndReplace({
filename: "BLAH.jpg",
@@ -722,7 +706,7 @@ QUnit.test('prevent attachment delete on non-authored message in channels', asyn
QUnit.test('subtype description should be displayed if it is different than body', async function (assert) {
assert.expect(2);
const { createMessageComponent, messaging } = await start({ data: this.data });
const { createMessageComponent, messaging } = await start();
const message = messaging.models['Message'].create({
body: "<p>Hello</p>",
id: 100,
@@ -744,7 +728,7 @@ QUnit.test('subtype description should be displayed if it is different than body
QUnit.test('subtype description should not be displayed if it is similar to body', async function (assert) {
assert.expect(2);
const { createMessageComponent, messaging } = await start({ data: this.data });
const { createMessageComponent, messaging } = await start();
const message = messaging.models['Message'].create({
body: "<p>Hello</p>",
id: 100,
@@ -785,7 +769,7 @@ QUnit.test('data-oe-id & data-oe-model link redirection on click', async functio
);
assert.step('do-action:openFormView_some.model_250');
});
const { createMessageComponent, messaging } = await start({ data: this.data, env: { bus } });
const { createMessageComponent, messaging } = await start({ env: { bus } });
const message = messaging.models['Message'].create({
body: `<p><a href="#" data-oe-id="250" data-oe-model="some.model">some.model_250</a></p>`,
id: 100,
@@ -812,14 +796,12 @@ QUnit.test('data-oe-id & data-oe-model link redirection on click', async functio
QUnit.test('chat with author should be opened after clicking on his avatar', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({ id: 10 });
this.data['res.users'].records.push({ partner_id: 10 });
const { createMessageComponent, messaging } = await start({
data: this.data,
hasChatWindow: true,
});
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['res.users'].create({ partner_id: resPartnerId1 });
const { createMessageComponent, messaging } = await start({ hasChatWindow: true });
const message = messaging.models['Message'].create({
author: insert({ id: 10 }),
author: insert({ id: resPartnerId1 }),
id: 10,
});
await createMessageComponent(message);
@@ -852,14 +834,12 @@ QUnit.test('chat with author should be opened after clicking on his avatar', asy
QUnit.test('chat with author should be opened after clicking on his im status icon', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({ id: 10 });
this.data['res.users'].records.push({ partner_id: 10 });
const { createMessageComponent, messaging } = await start({
data: this.data,
hasChatWindow: true,
});
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['res.users'].create({ partner_id: resPartnerId1 });
const { createMessageComponent, messaging } = await start({ hasChatWindow: true });
const message = messaging.models['Message'].create({
author: insert({ id: 10, im_status: 'online' }),
author: insert({ id: resPartnerId1, im_status: 'online' }),
id: 10,
});
await createMessageComponent(message);
@@ -892,26 +872,22 @@ QUnit.test('chat with author should be opened after clicking on his im status ic
QUnit.test('open chat with author on avatar click should be disabled when currently chatting with the author', async function (assert) {
assert.expect(3);
this.data['mail.channel'].records.push({
id: 11,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
pyEnv['res.users'].create({ partner_id: resPartnerId1 });
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
members: [this.data.currentPartnerId, 10],
members: [pyEnv.currentPartnerId, resPartnerId1],
public: 'private',
});
this.data['res.partner'].records.push({ id: 10 });
this.data['res.users'].records.push({ partner_id: 10 });
this.data['mail.message'].records.push({
author_id: 10,
pyEnv['mail.message'].create({
author_id: resPartnerId1,
body: 'not empty',
id: 10,
model: 'mail.channel',
res_id: 11,
res_id: mailChannelId1,
});
const { createThreadViewComponent, messaging } = await start({
data: this.data,
hasChatWindow: true,
});
const correspondent = messaging.models['Partner'].insert({ id: 10 });
const { createThreadViewComponent, messaging } = await start({ hasChatWindow: true });
const correspondent = messaging.models['Partner'].insert({ id: resPartnerId1 });
const thread = await correspondent.getChat();
const threadViewer = messaging.models['ThreadViewer'].create({
hasThreadView: true,
@@ -942,7 +918,7 @@ QUnit.test('open chat with author on avatar click should be disabled when curren
QUnit.test('message should not be considered as "clicked" after clicking on its author name', async function (assert) {
assert.expect(1);
const { createMessageComponent, messaging } = await start({ data: this.data });
const { createMessageComponent, messaging } = await start();
const message = messaging.models['Message'].create({
author: [['insert', { id: 7, display_name: "Demo User" }]],
body: "<p>Test</p>",
@@ -961,7 +937,7 @@ QUnit.test('message should not be considered as "clicked" after clicking on its
QUnit.test('message should not be considered as "clicked" after clicking on its author avatar', async function (assert) {
assert.expect(1);
const { createMessageComponent, messaging } = await start({ data: this.data });
const { createMessageComponent, messaging } = await start();
const message = messaging.models['Message'].create({
author: [['insert', { id: 7, display_name: "Demo User" }]],
body: "<p>Test</p>",
@@ -980,25 +956,24 @@ QUnit.test('message should not be considered as "clicked" after clicking on its
QUnit.test('message should not be considered as "clicked" after clicking on notification failure icon', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({ id: 10 });
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const mailMessageId1 = pyEnv['mail.message'].create({
body: 'not empty',
id: 10,
model: 'mail.channel',
res_id: 11,
res_id: mailChannelId1,
});
this.data['mail.notification'].records.push({
id: 11,
mail_message_id: 10,
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1,
notification_status: 'exception',
notification_type: 'email',
});
const { createThreadViewComponent, messaging } = await start({ data: this.data });
const { createThreadViewComponent, messaging } = await start();
const threadViewer = messaging.models['ThreadViewer'].create({
hasThreadView: true,
qunitTest: insertAndReplace(),
thread: insert({
id: 11,
id: mailChannelId1,
model: 'mail.channel',
}),
});
@@ -2,19 +2,15 @@
import {
afterNextRender,
beforeEach,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
import { makeTestPromise } from 'web.test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('messaging_menu_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('messaging_menu_tests.js');
QUnit.test('[technical] messaging not created then becomes created', async function (assert) {
/**
@@ -29,7 +25,6 @@ QUnit.test('[technical] messaging not created then becomes created', async funct
const messagingBeforeCreationDeferred = makeTestPromise();
const { createMessagingMenuComponent } = await start({
data: this.data,
messagingBeforeCreationDeferred,
waitUntilMessagingCondition: 'none',
});
@@ -53,7 +48,6 @@ QUnit.test('messaging not initialized', async function (assert) {
assert.expect(2);
const { createMessagingMenuComponent } = await start({
data: this.data,
async mockRPC(route) {
if (route === '/mail/init_messaging') {
// simulate messaging never initialized
@@ -84,7 +78,6 @@ QUnit.test('messaging becomes initialized', async function (assert) {
const messagingInitializedProm = makeTestPromise();
const { createMessagingMenuComponent } = await start({
data: this.data,
async mockRPC(route) {
const _super = this._super.bind(this, ...arguments); // limitation of class.js
if (route === '/mail/init_messaging') {
@@ -113,7 +106,7 @@ QUnit.test('messaging becomes initialized', async function (assert) {
QUnit.test('basic rendering', async function (assert) {
assert.expect(21);
const { createMessagingMenuComponent } = await start({ data: this.data });
const { createMessagingMenuComponent } = await start();
await createMessagingMenuComponent();
assert.strictEqual(
document.querySelectorAll('.o_MessagingMenu').length,
@@ -238,23 +231,20 @@ QUnit.test('basic rendering', async function (assert) {
QUnit.test('counter is taking into account failure notification', async function (assert) {
assert.expect(2);
this.data['mail.channel'].records.push({
id: 31,
seen_message_id: 11,
});
// message that is expected to have a failure
this.data['mail.message'].records.push({
id: 11, // random unique id, will be used to link failure to message
model: 'mail.channel', // expected value to link message to channel
res_id: 31, // id of a random channel
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const mailMessageId1 = pyEnv['mail.message'].create({
model: 'mail.channel',
res_id: mailChannelId1,
});
pyEnv['mail.channel'].write([mailChannelId1], { seen_message_id: mailMessageId1 });
// failure that is expected to be used in the test
this.data['mail.notification'].records.push({
mail_message_id: 11, // id of the related message
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1, // id of the related message
notification_status: 'exception', // necessary value to have a failure
notification_type: 'email',
});
const { createMessagingMenuComponent } = await start({ data: this.data });
const { createMessagingMenuComponent } = await start();
await createMessagingMenuComponent();
assert.containsOnce(
@@ -272,7 +262,7 @@ QUnit.test('counter is taking into account failure notification', async function
QUnit.test('switch tab', async function (assert) {
assert.expect(15);
const { createMessagingMenuComponent } = await start({ data: this.data });
const { createMessagingMenuComponent } = await start();
await createMessagingMenuComponent();
await afterNextRender(() => document.querySelector(`.o_MessagingMenu_toggler`).click());
@@ -380,7 +370,7 @@ QUnit.test('switch tab', async function (assert) {
QUnit.test('new message', async function (assert) {
assert.expect(3);
const { createMessagingMenuComponent } = await start({ data: this.data, hasChatWindow: true });
const { createMessagingMenuComponent } = await start({ hasChatWindow: true });
await createMessagingMenuComponent();
await afterNextRender(() =>
document.querySelector(`.o_MessagingMenu_toggler`).click()
@@ -408,7 +398,6 @@ QUnit.test('no new message when discuss is open', async function (assert) {
assert.expect(3);
const { discussWidget, createMessagingMenuComponent } = await start({
data: this.data,
autoOpenDiscuss: true,
hasDiscuss: true,
});
@@ -443,23 +432,16 @@ QUnit.test('no new message when discuss is open', async function (assert) {
QUnit.test('channel preview: basic rendering', async function (assert) {
assert.expect(9);
this.data['res.partner'].records.push({
id: 7, // random unique id, to link message author
name: "Demo", // random name, will be asserted in the test
});
// channel that is expected to be found in the test
this.data['mail.channel'].records.push({
id: 20, // random unique id, will be used to link message to channel
name: "General", // random name, will be asserted in the test
});
// message that is expected to be displayed in the test
this.data['mail.message'].records.push({
author_id: 7, // not current partner, will be asserted in the test
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({ name: "Demo" });
const mailChannelId1 = pyEnv['mail.channel'].create({ name: "General" });
pyEnv['mail.message'].create({
author_id: resPartnerId1, // not current partner, will be asserted in the test
body: "<p>test</p>", // random body, will be asserted in the test
model: 'mail.channel', // necessary to link message to channel
res_id: 20, // id of related channel
res_id: mailChannelId1, // id of related channel
});
const { createMessagingMenuComponent } = await start({ data: this.data });
const { createMessagingMenuComponent } = await start();
await createMessagingMenuComponent();
await afterNextRender(() => document.querySelector(`.o_MessagingMenu_toggler`).click());
@@ -542,22 +524,22 @@ QUnit.test('channel preview: basic rendering', async function (assert) {
QUnit.test('filtered previews', async function (assert) {
assert.expect(12);
// chat and channel expected to be found in the menu
this.data['mail.channel'].records.push(
{ channel_type: "chat", id: 10 },
{ id: 20 },
);
this.data['mail.message'].records.push(
const pyEnv = await startServer();
const [mailChannelId1, mailChannelId2] = pyEnv['mail.channel'].create([
{ channel_type: "chat" },
{ name: "mailChannel1" },
]);
pyEnv['mail.message'].create([
{
model: 'mail.channel', // to link message to channel
res_id: 10, // id of related channel
res_id: mailChannelId1, // id of related channel
},
{
model: 'mail.channel', // to link message to channel
res_id: 20, // id of related channel
res_id: mailChannelId2, // id of related channel
},
);
const { createMessagingMenuComponent, messaging } = await start({ data: this.data });
]);
const { createMessagingMenuComponent, messaging } = await start();
await createMessagingMenuComponent();
await afterNextRender(() =>
@@ -573,7 +555,7 @@ QUnit.test('filtered previews', async function (assert) {
.o_MessagingMenu_dropdownMenu
.o_ThreadPreview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]
@@ -586,7 +568,7 @@ QUnit.test('filtered previews', async function (assert) {
.o_MessagingMenu_dropdownMenu
.o_ThreadPreview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId2,
model: 'mail.channel',
}).localId
}"]
@@ -608,7 +590,7 @@ QUnit.test('filtered previews', async function (assert) {
.o_MessagingMenu_dropdownMenu
.o_ThreadPreview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]
@@ -621,7 +603,7 @@ QUnit.test('filtered previews', async function (assert) {
.o_MessagingMenu_dropdownMenu
.o_ThreadPreview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId2,
model: 'mail.channel',
}).localId
}"]
@@ -646,7 +628,7 @@ QUnit.test('filtered previews', async function (assert) {
.o_MessagingMenu_dropdownMenu
.o_ThreadPreview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]
@@ -659,7 +641,7 @@ QUnit.test('filtered previews', async function (assert) {
.o_MessagingMenu_dropdownMenu
.o_ThreadPreview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId2,
model: 'mail.channel',
}).localId
}"]
@@ -681,7 +663,7 @@ QUnit.test('filtered previews', async function (assert) {
.o_MessagingMenu_dropdownMenu
.o_ThreadPreview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 10,
id: mailChannelId1,
model: 'mail.channel',
}).localId
}"]
@@ -694,7 +676,7 @@ QUnit.test('filtered previews', async function (assert) {
.o_MessagingMenu_dropdownMenu
.o_ThreadPreview[data-thread-local-id="${
messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId2,
model: 'mail.channel',
}).localId
}"]
@@ -707,9 +689,9 @@ QUnit.test('filtered previews', async function (assert) {
QUnit.test('open chat window from preview', async function (assert) {
assert.expect(1);
// channel expected to be found in the menu, only its existence matters, data are irrelevant
this.data['mail.channel'].records.push({});
const { createMessagingMenuComponent } = await start({ data: this.data, hasChatWindow: true });
const pyEnv = await startServer();
pyEnv['mail.channel'].create();
const { createMessagingMenuComponent } = await start({ hasChatWindow: true });
await createMessagingMenuComponent();
await afterNextRender(() =>
@@ -728,13 +710,14 @@ QUnit.test('open chat window from preview', async function (assert) {
QUnit.test('no code injection in message body preview', async function (assert) {
assert.expect(5);
this.data['mail.channel'].records.push({ id: 11 });
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
pyEnv['mail.message'].create({
body: "<p><em>&shoulnotberaised</em><script>throw new Error('CodeInjectionError');</script></p>",
model: "mail.channel",
res_id: 11,
res_id: mailChannelId1,
});
const { createMessagingMenuComponent } = await start({ data: this.data });
const { createMessagingMenuComponent } = await start();
await createMessagingMenuComponent();
await afterNextRender(() => {
@@ -771,13 +754,14 @@ QUnit.test('no code injection in message body preview', async function (assert)
QUnit.test('no code injection in message body preview from sanitized message', async function (assert) {
assert.expect(5);
this.data['mail.channel'].records.push({ id: 11 });
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
pyEnv['mail.message'].create({
body: "<p>&lt;em&gt;&shoulnotberaised&lt;/em&gt;&lt;script&gt;throw new Error('CodeInjectionError');&lt;/script&gt;</p>",
model: "mail.channel",
res_id: 11,
res_id: mailChannelId1,
});
const { createMessagingMenuComponent } = await start({ data: this.data });
const { createMessagingMenuComponent } = await start();
await createMessagingMenuComponent();
await afterNextRender(() => {
@@ -814,13 +798,14 @@ QUnit.test('no code injection in message body preview from sanitized message', a
QUnit.test('<br/> tags in message body preview are transformed in spaces', async function (assert) {
assert.expect(4);
this.data['mail.channel'].records.push({ id: 11 });
this.data['mail.message'].records.push({
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
pyEnv['mail.message'].create({
body: "<p>a<br/>b<br>c<br />d<br ></p>",
model: "mail.channel",
res_id: 11,
res_id: mailChannelId1,
});
const { createMessagingMenuComponent } = await start({ data: this.data });
const { createMessagingMenuComponent } = await start();
await createMessagingMenuComponent();
await afterNextRender(() => {
@@ -852,7 +837,6 @@ QUnit.test('rendering with OdooBot has a request (default)', async function (ass
assert.expect(4);
const { createMessagingMenuComponent } = await start({
data: this.data,
env: {
browser: {
Notification: {
@@ -892,7 +876,6 @@ QUnit.test('rendering without OdooBot has a request (denied)', async function (a
assert.expect(2);
const { createMessagingMenuComponent } = await start({
data: this.data,
env: {
browser: {
Notification: {
@@ -923,7 +906,6 @@ QUnit.test('rendering without OdooBot has a request (accepted)', async function
assert.expect(2);
const { createMessagingMenuComponent } = await start({
data: this.data,
env: {
browser: {
Notification: {
@@ -954,7 +936,6 @@ QUnit.test('respond to notification prompt (denied)', async function (assert) {
assert.expect(4);
const { createMessagingMenuComponent } = await start({
data: this.data,
env: {
browser: {
Notification: {
@@ -1007,12 +988,12 @@ QUnit.test('respond to notification prompt (denied)', async function (assert) {
QUnit.test('Group chat should be displayed inside the chat section of the messaging menu', async function (assert) {
assert.expect(1);
this.data['mail.channel'].records.push({
id: 11,
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'group',
is_pinned: true,
});
const { createMessagingMenuComponent, messaging } = await start({ data: this.data });
const { createMessagingMenuComponent, messaging } = await start();
await createMessagingMenuComponent();
await afterNextRender(() =>
@@ -1026,7 +1007,7 @@ QUnit.test('Group chat should be displayed inside the chat section of the messag
document.querySelectorAll(`
.o_MessagingMenu_dropdownMenu
.o_ThreadPreview[data-thread-local-id="${messaging.models['Thread'].findFromIdentifyingData({
id: 11,
id: mailChannelId1,
model: 'mail.channel',
}).localId}"]`).length,
1,
@@ -1,35 +1,31 @@
/** @odoo-module **/
import { afterNextRender, beforeEach, start, } from '@mail/../tests/helpers/test_utils';
import { afterNextRender, start, startServer } from '@mail/../tests/helpers/test_utils';
import Bus from 'web.Bus';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('notification_list_notification_group_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('notification_list_notification_group_tests.js');
QUnit.test('notification group basic layout', async function (assert) {
assert.expect(10);
// message that is expected to have a failure
this.data['mail.message'].records.push({
id: 11, // random unique id, will be used to link failure to message
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const mailMessageId1 = pyEnv['mail.message'].create({
message_type: 'email', // message must be email (goal of the test)
model: 'mail.channel', // expected value to link message to channel
res_id: 31, // id of a random channel
res_id: mailChannelId1,
res_model_name: "Channel", // random res model name, will be asserted in the test
});
// failure that is expected to be used in the test
this.data['mail.notification'].records.push({
mail_message_id: 11, // id of the related message
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1, // id of the related message
notification_status: 'exception', // necessary value to have a failure
notification_type: 'email', // expected failure type for email message
});
const { createNotificationListComponent } = await start({ data: this.data });
const { createNotificationListComponent } = await start();
await createNotificationListComponent();
assert.containsOnce(
document.body,
@@ -86,17 +82,17 @@ QUnit.test('notification group basic layout', async function (assert) {
QUnit.test('mark as read', async function (assert) {
assert.expect(6);
// message that is expected to have a failure
this.data['mail.message'].records.push({
id: 11, // random unique id, will be used to link failure to message
const pyEnv = await startServer();
const mailChannelId1 = pyEnv['mail.channel'].create();
const mailMessageId1 = pyEnv['mail.message'].create({
message_type: 'email', // message must be email (goal of the test)
model: 'mail.channel', // expected value to link message to channel
res_id: 31, // id of a random channel
res_id: mailChannelId1,
res_model_name: "Channel", // random res model name, will be asserted in the test
});
// failure that is expected to be used in the test
this.data['mail.notification'].records.push({
mail_message_id: 11, // id of the related message
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1, // id of the related message
notification_status: 'exception', // necessary value to have a failure
notification_type: 'email', // expected failure type for email message
});
@@ -119,7 +115,7 @@ QUnit.test('mark as read', async function (assert) {
"action should have the group notification length as unread_counter"
);
});
const { createNotificationListComponent } = await start({ data: this.data, env: { bus } });
const { createNotificationListComponent } = await start({ env: { bus } });
await createNotificationListComponent();
assert.containsOnce(
document.body,
@@ -139,10 +135,10 @@ QUnit.test('grouped notifications by document', async function (assert) {
// notification should group all those failures.
assert.expect(5);
this.data['mail.message'].records.push(
const pyEnv = await startServer();
const [mailMessageId1, mailMessageId2] = pyEnv['mail.message'].create([
// first message that is expected to have a failure
{
id: 11, // random unique id, will be used to link failure to message
message_type: 'email', // message must be email (goal of the test)
model: 'res.partner', // same model as second message (and not `mail.channel`)
res_id: 31, // same res_id as second message
@@ -150,28 +146,27 @@ QUnit.test('grouped notifications by document', async function (assert) {
},
// second message that is expected to have a failure
{
id: 12, // random unique id, will be used to link failure to message
message_type: 'email', // message must be email (goal of the test)
model: 'res.partner', // same model as first message (and not `mail.channel`)
res_id: 31, // same res_id as first message
res_model_name: "Partner", // same related model name for consistency
}
);
this.data['mail.notification'].records.push(
},
]);
pyEnv['mail.notification'].create([
// first failure that is expected to be used in the test
{
mail_message_id: 11, // id of the related first message
mail_message_id: mailMessageId1, // id of the related first message
notification_status: 'exception', // one possible value to have a failure
notification_type: 'email', // expected failure type for email message
},
// second failure that is expected to be used in the test
{
mail_message_id: 12, // id of the related second message
mail_message_id: mailMessageId2, // id of the related second message
notification_status: 'bounce', // other possible value to have a failure
notification_type: 'email', // expected failure type for email message
}
);
const { createNotificationListComponent } = await start({ data: this.data, hasChatWindow: true });
]);
const { createNotificationListComponent } = await start({ hasChatWindow: true });
await createNotificationListComponent();
assert.containsOnce(
@@ -211,10 +206,10 @@ QUnit.test('grouped notifications by document model', async function (assert) {
// document model.
assert.expect(12);
this.data['mail.message'].records.push(
const pyEnv = await startServer();
const [mailMessageId1, mailMessageId2] = pyEnv['mail.message'].create([
// first message that is expected to have a failure
{
id: 11, // random unique id, will be used to link failure to message
message_type: 'email', // message must be email (goal of the test)
model: 'res.partner', // same model as second message (and not `mail.channel`)
res_id: 31, // different res_id from second message
@@ -222,27 +217,26 @@ QUnit.test('grouped notifications by document model', async function (assert) {
},
// second message that is expected to have a failure
{
id: 12, // random unique id, will be used to link failure to message
message_type: 'email', // message must be email (goal of the test)
model: 'res.partner', // same model as first message (and not `mail.channel`)
res_id: 32, // different res_id from first message
res_model_name: "Partner", // same related model name for consistency
}
);
this.data['mail.notification'].records.push(
},
]);
pyEnv['mail.notification'].create([
// first failure that is expected to be used in the test
{
mail_message_id: 11, // id of the related first message
mail_message_id: mailMessageId1, // id of the related first message
notification_status: 'exception', // one possible value to have a failure
notification_type: 'email', // expected failure type for email message
},
// second failure that is expected to be used in the test
{
mail_message_id: 12, // id of the related second message
mail_message_id: mailMessageId2, // id of the related second message
notification_status: 'bounce', // other possible value to have a failure
notification_type: 'email', // expected failure type for email message
}
);
},
]);
const bus = new Bus();
bus.on('do-action', null, payload => {
assert.step('do_action');
@@ -283,7 +277,7 @@ QUnit.test('grouped notifications by document model', async function (assert) {
);
});
const { createNotificationListComponent } = await start({ data: this.data, env: { bus } });
const { createNotificationListComponent } = await start({ env: { bus } });
await createNotificationListComponent();
assert.containsOnce(
@@ -314,42 +308,40 @@ QUnit.test('different mail.channel are not grouped', async function (assert) {
// they are linked to different channels, even though the model is the same.
assert.expect(6);
this.data['mail.channel'].records.push({ id: 31 }, { id: 32 });
this.data['mail.message'].records.push(
const pyEnv = await startServer();
const [mailChannelId1, mailChannelId2] = pyEnv['mail.channel'].create([{ name: "mailChannel1" }, { name: "mailChannel2" }]);
const [mailMessageId1, mailMessageId2] = pyEnv['mail.message'].create([
// first message that is expected to have a failure
{
id: 11, // random unique id, will be used to link failure to message
message_type: 'email', // message must be email (goal of the test)
model: 'mail.channel', // testing a channel is the goal of the test
res_id: 31, // different res_id from second message
res_id: mailChannelId1, // different res_id from second message
res_model_name: "Channel", // random related model name
},
// second message that is expected to have a failure
{
id: 12, // random unique id, will be used to link failure to message
message_type: 'email', // message must be email (goal of the test)
model: 'mail.channel', // testing a channel is the goal of the test
res_id: 32, // different res_id from first message
res_id: mailChannelId2, // different res_id from first message
res_model_name: "Channel", // same related model name for consistency
}
);
this.data['mail.notification'].records.push(
},
]);
pyEnv['mail.notification'].create([
// first failure that is expected to be used in the test
{
mail_message_id: 11, // id of the related first message
mail_message_id: mailMessageId1, // id of the related first message
notification_status: 'exception', // one possible value to have a failure
notification_type: 'email', // expected failure type for email message
},
// second failure that is expected to be used in the test
}, // second failure that is expected to be used in the test
{
mail_message_id: 12, // id of the related second message
mail_message_id: mailMessageId2, // id of the related second message
notification_status: 'bounce', // other possible value to have a failure
notification_type: 'email', // expected failure type for email message
}
);
},
]);
const { createNotificationListComponent } = await start({
data: this.data,
hasChatWindow: true, // needed to assert thread.open
// needed to assert thread.open
hasChatWindow: true,
});
await createNotificationListComponent();
assert.containsN(
@@ -391,39 +383,38 @@ QUnit.test('different mail.channel are not grouped', async function (assert) {
QUnit.test('multiple grouped notifications by document model, sorted by the most recent message of each group', async function (assert) {
assert.expect(9);
this.data['mail.message'].records.push(
const pyEnv = await startServer();
const [mailMessageId1, mailMessageId2] = pyEnv['mail.message'].create([
// first message that is expected to have a failure
{
id: 11, // random unique id, will be used to link failure to message
message_type: 'email', // message must be email (goal of the test)
model: 'res.partner', // different model from second message
res_id: 31, // random unique id, useful to link failure to message
res_id: 31,
res_model_name: "Partner", // random related model name
},
// second message that is expected to have a failure
{
id: 12, // random unique id, will be used to link failure to message
message_type: 'email', // message must be email (goal of the test)
model: 'res.company', // different model from first message
res_id: 32, // random unique id, useful to link failure to message
res_id: 32,
res_model_name: "Company", // random related model name
}
);
this.data['mail.notification'].records.push(
},
]);
pyEnv['mail.notification'].create([
// first failure that is expected to be used in the test
{
mail_message_id: 11, // id of the related first message
mail_message_id: mailMessageId1, // id of the related first message
notification_status: 'exception', // one possible value to have a failure
notification_type: 'email', // expected failure type for email message
},
// second failure that is expected to be used in the test
{
mail_message_id: 12, // id of the related second message
mail_message_id: mailMessageId2, // id of the related second message
notification_status: 'bounce', // other possible value to have a failure
notification_type: 'email', // expected failure type for email message
}
);
const { createNotificationListComponent } = await start({ data: this.data });
},
]);
const { createNotificationListComponent } = await start();
await createNotificationListComponent();
assert.containsN(
document.body,
@@ -477,24 +468,19 @@ QUnit.test('multiple grouped notifications by document model, sorted by the most
QUnit.test('non-failure notifications are ignored', async function (assert) {
assert.expect(1);
this.data['mail.message'].records.push(
// message that is expected to have a notification
{
id: 11, // random unique id, will be used to link failure to message
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create();
const mailMessageId1 = pyEnv['mail.message'].create({
message_type: 'email', // message must be email (goal of the test)
model: 'res.partner', // random model
res_id: 31, // random unique id, useful to link failure to message
}
);
this.data['mail.notification'].records.push(
// notification that is expected to be used in the test
{
mail_message_id: 11, // id of the related first message
res_id: resPartnerId1,
});
pyEnv['mail.notification'].create({
mail_message_id: mailMessageId1, // id of the related first message
notification_status: 'ready', // non-failure status
notification_type: 'email', // expected notification type for email message
},
);
const { createNotificationListComponent } = await start({ data: this.data });
});
const { createNotificationListComponent } = await start();
await createNotificationListComponent();
assert.containsNone(
document.body,
@@ -1,37 +1,32 @@
/** @odoo-module **/
import { afterNextRender, beforeEach, start } from '@mail/../tests/helpers/test_utils';
import { afterNextRender, start, startServer } from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('notification_list_tests.js', {
async beforeEach() {
await beforeEach(this);
},
});
QUnit.module('notification_list_tests.js');
QUnit.test('marked as read thread notifications are ordered by last message date', async function (assert) {
assert.expect(3);
this.data['mail.channel'].records.push(
{ id: 100, name: "Channel 2019" },
{ id: 200, name: "Channel 2020" }
);
this.data['mail.message'].records.push(
const pyEnv = await startServer();
const [mailChannelId1, mailChannelId2] = pyEnv['mail.channel'].create([
{ name: "Channel 2019" },
{ name: "Channel 2020" },
]);
pyEnv['mail.message'].create([
{
date: "2019-01-01 00:00:00",
id: 42,
model: 'mail.channel',
res_id: 100,
res_id: mailChannelId1,
},
{
date: "2020-01-01 00:00:00",
id: 43,
model: 'mail.channel',
res_id: 200,
}
);
const { createNotificationListComponent } = await start({ data: this.data });
res_id: mailChannelId2,
},
]);
const { createNotificationListComponent } = await start();
await createNotificationListComponent({ filter: 'all' });
assert.containsN(
document.body,
@@ -55,25 +50,24 @@ QUnit.test('marked as read thread notifications are ordered by last message date
QUnit.test('thread notifications are re-ordered on receiving a new message', async function (assert) {
assert.expect(4);
this.data['mail.channel'].records.push(
{ id: 100, name: "Channel 2019" },
{ id: 200, name: "Channel 2020" }
);
this.data['mail.message'].records.push(
const pyEnv = await startServer();
const [mailChannelId1, mailChannelId2] = pyEnv['mail.channel'].create([
{ name: "Channel 2019" },
{ name: "Channel 2020" },
]);
pyEnv['mail.message'].create([
{
date: "2019-01-01 00:00:00",
id: 42,
model: 'mail.channel',
res_id: 100,
res_id: mailChannelId1,
},
{
date: "2020-01-01 00:00:00",
id: 43,
model: 'mail.channel',
res_id: 200,
}
);
const { createNotificationListComponent, widget } = await start({ data: this.data });
res_id: mailChannelId2,
},
]);
const { createNotificationListComponent, widget } = await start();
await createNotificationListComponent({ filter: 'all' });
assert.containsN(
document.body,
@@ -86,7 +80,7 @@ QUnit.test('thread notifications are re-ordered on receiving a new message', asy
widget.call('bus_service', 'trigger', 'notification', [{
type: 'mail.channel/new_message',
payload: {
id: 100,
id: mailChannelId1,
message: {
author_id: [7, "Demo User"],
body: "<p>New message !</p>",
@@ -95,7 +89,7 @@ QUnit.test('thread notifications are re-ordered on receiving a new message', asy
message_type: 'comment',
model: 'mail.channel',
record_name: 'Channel 2019',
res_id: 100,
res_id: mailChannelId1,
},
},
}]);
@@ -2,7 +2,6 @@
import {
afterNextRender,
beforeEach,
createRootMessagingComponent,
start,
} from '@mail/../tests/helpers/test_utils';
@@ -10,9 +9,7 @@ import {
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('partner_im_status_icon_tests.js', {
async beforeEach() {
await beforeEach(this);
beforeEach() {
this.createPartnerImStatusIcon = async (partner, target) => {
await createRootMessagingComponent(partner.env, "PartnerImStatusIcon", {
props: { partnerLocalId: partner.localId },
@@ -25,7 +22,7 @@ QUnit.module('partner_im_status_icon_tests.js', {
QUnit.test('initially online', async function (assert) {
assert.expect(3);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const partner = messaging.models['Partner'].create({
id: 7,
name: "Demo User",
@@ -52,7 +49,7 @@ QUnit.test('initially online', async function (assert) {
QUnit.test('initially offline', async function (assert) {
assert.expect(1);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const partner = messaging.models['Partner'].create({
id: 7,
name: "Demo User",
@@ -69,7 +66,7 @@ QUnit.test('initially offline', async function (assert) {
QUnit.test('initially away', async function (assert) {
assert.expect(1);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const partner = messaging.models['Partner'].create({
id: 7,
name: "Demo User",
@@ -86,7 +83,7 @@ QUnit.test('initially away', async function (assert) {
QUnit.test('change icon on change partner im_status', async function (assert) {
assert.expect(4);
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const partner = messaging.models['Partner'].create({
id: 7,
name: "Demo User",
@@ -2,17 +2,15 @@
import {
afterNextRender,
beforeEach,
createRootMessagingComponent,
start,
startServer,
} from '@mail/../tests/helpers/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('components', {}, function () {
QUnit.module('thread_icon_tests.js', {
async beforeEach() {
await beforeEach(this);
this.createThreadIcon = async (thread, target) => {
await createRootMessagingComponent(thread.env, "ThreadIcon", {
props: { threadLocalId: thread.localId },
@@ -25,19 +23,18 @@ QUnit.module('thread_icon_tests.js', {
QUnit.test('chat: correspondent is typing', async function (assert) {
assert.expect(5);
this.data['res.partner'].records.push({
id: 17,
const pyEnv = await startServer();
const resPartnerId1 = pyEnv['res.partner'].create({
im_status: 'online',
name: 'Demo',
});
this.data['mail.channel'].records.push({
const mailChannelId1 = pyEnv['mail.channel'].create({
channel_type: 'chat',
id: 20,
members: [this.data.currentPartnerId, 17],
members: [pyEnv.currentPartnerId, resPartnerId1],
});
const { messaging, widget } = await start({ data: this.data });
const { messaging, widget } = await start();
const thread = messaging.models['Thread'].findFromIdentifyingData({
id: 20,
id: mailChannelId1,
model: 'mail.channel',
});
await this.createThreadIcon(thread, widget.el);
@@ -58,9 +55,9 @@ QUnit.test('chat: correspondent is typing', async function (assert) {
widget.call('bus_service', 'trigger', 'notification', [{
type: 'mail.channel.partner/typing_status',
payload: {
channel_id: 20,
channel_id: mailChannelId1,
is_typing: true,
partner_id: 17,
partner_id: resPartnerId1,
partner_name: "Demo",
},
}]);
@@ -81,9 +78,9 @@ QUnit.test('chat: correspondent is typing', async function (assert) {
widget.call('bus_service', 'trigger', 'notification', [{
type: 'mail.channel.partner/typing_status',
payload: {
channel_id: 20,
channel_id: mailChannelId1,
is_typing: false,
partner_id: 17,
partner_id: resPartnerId1,
partner_name: "Demo",
},
}]);