[IMP] mail: adapt composer suggestion tests to use pyEnv
Task-2793280 closes odoo/odoo#87382 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
+32
-48
@@ -11,22 +11,20 @@ QUnit.test('canned response suggestion displayed', async function (assert) {
|
||||
|
||||
const pyEnv = await startServer();
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create();
|
||||
const { createComposerSuggestionComponent, messaging } = await start();
|
||||
const thread = messaging.models['Thread'].findFromIdentifyingData({
|
||||
id: mailChannelId1,
|
||||
model: 'mail.channel',
|
||||
});
|
||||
const cannedResponse = messaging.models['CannedResponse'].create({
|
||||
id: 7,
|
||||
pyEnv['mail.shortcode'].create({
|
||||
source: 'hello',
|
||||
substitution: "Hello, how are you?",
|
||||
});
|
||||
await createComposerSuggestionComponent(thread.composer, {
|
||||
isActive: true,
|
||||
modelName: 'CannedResponse',
|
||||
recordLocalId: cannedResponse.localId,
|
||||
const { insertText, openDiscuss } = await start({
|
||||
discuss: {
|
||||
params: {
|
||||
default_active_id: mailChannelId1,
|
||||
},
|
||||
},
|
||||
hasDiscuss: true,
|
||||
});
|
||||
|
||||
await openDiscuss();
|
||||
await insertText('.o_ComposerTextInput_textarea', ":hello");
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
`.o_ComposerSuggestion`,
|
||||
@@ -35,31 +33,24 @@ QUnit.test('canned response suggestion displayed', async function (assert) {
|
||||
});
|
||||
|
||||
QUnit.test('canned response suggestion correct data', async function (assert) {
|
||||
assert.expect(5);
|
||||
assert.expect(4);
|
||||
|
||||
const pyEnv = await startServer();
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create();
|
||||
const { createComposerSuggestionComponent, messaging } = await start();
|
||||
const thread = messaging.models['Thread'].findFromIdentifyingData({
|
||||
id: mailChannelId1,
|
||||
model: 'mail.channel',
|
||||
});
|
||||
const cannedResponse = messaging.models['CannedResponse'].create({
|
||||
id: 7,
|
||||
pyEnv['mail.shortcode'].create({
|
||||
source: 'hello',
|
||||
substitution: "Hello, how are you?",
|
||||
});
|
||||
await createComposerSuggestionComponent(thread.composer, {
|
||||
isActive: true,
|
||||
modelName: 'CannedResponse',
|
||||
recordLocalId: cannedResponse.localId,
|
||||
const { insertText, openDiscuss } = await start({
|
||||
discuss: {
|
||||
params: {
|
||||
default_active_id: mailChannelId1,
|
||||
},
|
||||
},
|
||||
hasDiscuss: true,
|
||||
});
|
||||
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_ComposerSuggestion',
|
||||
"Canned response suggestion should be present"
|
||||
);
|
||||
await openDiscuss();
|
||||
await insertText('.o_ComposerTextInput_textarea', ":hello");
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_ComposerSuggestion_part1',
|
||||
@@ -83,31 +74,24 @@ QUnit.test('canned response suggestion correct data', async function (assert) {
|
||||
});
|
||||
|
||||
QUnit.test('canned response suggestion active', async function (assert) {
|
||||
assert.expect(2);
|
||||
assert.expect(1);
|
||||
|
||||
const pyEnv = await startServer();
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create();
|
||||
const { createComposerSuggestionComponent, messaging } = await start();
|
||||
const thread = messaging.models['Thread'].findFromIdentifyingData({
|
||||
id: mailChannelId1,
|
||||
model: 'mail.channel',
|
||||
});
|
||||
const cannedResponse = messaging.models['CannedResponse'].create({
|
||||
id: 7,
|
||||
pyEnv['mail.shortcode'].create({
|
||||
source: 'hello',
|
||||
substitution: "Hello, how are you?",
|
||||
});
|
||||
await createComposerSuggestionComponent(thread.composer, {
|
||||
isActive: true,
|
||||
modelName: 'CannedResponse',
|
||||
recordLocalId: cannedResponse.localId,
|
||||
const { insertText, openDiscuss } = await start({
|
||||
discuss: {
|
||||
params: {
|
||||
default_active_id: mailChannelId1,
|
||||
},
|
||||
},
|
||||
hasDiscuss: true,
|
||||
});
|
||||
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_ComposerSuggestion',
|
||||
"Canned response suggestion should be displayed"
|
||||
);
|
||||
await openDiscuss();
|
||||
await insertText('.o_ComposerTextInput_textarea', ":hello");
|
||||
assert.hasClass(
|
||||
document.querySelector('.o_ComposerSuggestion'),
|
||||
'active',
|
||||
|
||||
+31
-44
@@ -10,18 +10,17 @@ QUnit.test('channel mention suggestion displayed', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
const pyEnv = await startServer();
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create();
|
||||
const { createComposerSuggestionComponent, messaging } = await start();
|
||||
const thread = messaging.models['Thread'].findFromIdentifyingData({
|
||||
id: mailChannelId1,
|
||||
model: 'mail.channel',
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create({ name: 'my-channel' });
|
||||
const { insertText, openDiscuss } = await start({
|
||||
discuss: {
|
||||
params: {
|
||||
default_active_id: mailChannelId1,
|
||||
},
|
||||
},
|
||||
hasDiscuss: true,
|
||||
});
|
||||
await createComposerSuggestionComponent(thread.composer, {
|
||||
isActive: true,
|
||||
modelName: 'Thread',
|
||||
recordLocalId: thread.localId,
|
||||
});
|
||||
|
||||
await openDiscuss();
|
||||
await insertText('.o_ComposerTextInput_textarea', "#my-channel");
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
`.o_ComposerSuggestion`,
|
||||
@@ -30,26 +29,20 @@ QUnit.test('channel mention suggestion displayed', async function (assert) {
|
||||
});
|
||||
|
||||
QUnit.test('channel mention suggestion correct data', async function (assert) {
|
||||
assert.expect(3);
|
||||
assert.expect(2);
|
||||
|
||||
const pyEnv = await startServer();
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create({ name: "General" });
|
||||
const { createComposerSuggestionComponent, messaging } = await start();
|
||||
const thread = messaging.models['Thread'].findFromIdentifyingData({
|
||||
id: mailChannelId1,
|
||||
model: 'mail.channel',
|
||||
const { insertText, openDiscuss } = await start({
|
||||
discuss: {
|
||||
params: {
|
||||
default_active_id: mailChannelId1,
|
||||
},
|
||||
},
|
||||
hasDiscuss: true,
|
||||
});
|
||||
await createComposerSuggestionComponent(thread.composer, {
|
||||
isActive: true,
|
||||
modelName: 'Thread',
|
||||
recordLocalId: thread.localId,
|
||||
});
|
||||
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_ComposerSuggestion',
|
||||
"Channel mention suggestion should be present"
|
||||
);
|
||||
await openDiscuss();
|
||||
await insertText('.o_ComposerTextInput_textarea', "#General");
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_ComposerSuggestion_part1',
|
||||
@@ -63,26 +56,20 @@ QUnit.test('channel mention suggestion correct data', async function (assert) {
|
||||
});
|
||||
|
||||
QUnit.test('channel mention suggestion active', async function (assert) {
|
||||
assert.expect(2);
|
||||
assert.expect(1);
|
||||
|
||||
const pyEnv = await startServer();
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create();
|
||||
const { createComposerSuggestionComponent, messaging } = await start();
|
||||
const thread = messaging.models['Thread'].findFromIdentifyingData({
|
||||
id: mailChannelId1,
|
||||
model: 'mail.channel',
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create({ name: 'my-channel' });
|
||||
const { insertText, openDiscuss } = await start({
|
||||
discuss: {
|
||||
params: {
|
||||
default_active_id: mailChannelId1,
|
||||
},
|
||||
},
|
||||
hasDiscuss: true,
|
||||
});
|
||||
await createComposerSuggestionComponent(thread.composer, {
|
||||
isActive: true,
|
||||
modelName: 'Thread',
|
||||
recordLocalId: thread.localId,
|
||||
});
|
||||
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_ComposerSuggestion',
|
||||
"Channel mention suggestion should be displayed"
|
||||
);
|
||||
await openDiscuss();
|
||||
await insertText('.o_ComposerTextInput_textarea', "#my-channel");
|
||||
assert.hasClass(
|
||||
document.querySelector('.o_ComposerSuggestion'),
|
||||
'active',
|
||||
|
||||
+38
-66
@@ -10,56 +10,39 @@ QUnit.test('command suggestion displayed', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
const pyEnv = await startServer();
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create();
|
||||
const { createComposerSuggestionComponent, messaging } = await start();
|
||||
const thread = messaging.models['Thread'].findFromIdentifyingData({
|
||||
id: mailChannelId1,
|
||||
model: 'mail.channel',
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create({ name: 'my-channel' });
|
||||
const { insertText, openDiscuss } = await start({
|
||||
discuss: {
|
||||
params: {
|
||||
default_active_id: mailChannelId1,
|
||||
},
|
||||
},
|
||||
hasDiscuss: true,
|
||||
});
|
||||
const command = messaging.models['ChannelCommand'].create({
|
||||
methodName: '',
|
||||
name: 'whois',
|
||||
help: "Displays who it is",
|
||||
});
|
||||
await createComposerSuggestionComponent(thread.composer, {
|
||||
isActive: true,
|
||||
modelName: 'ChannelCommand',
|
||||
recordLocalId: command.localId,
|
||||
});
|
||||
|
||||
await openDiscuss();
|
||||
await insertText('.o_ComposerTextInput_textarea', "/who");
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
`.o_ComposerSuggestion`,
|
||||
"Command suggestion should be present"
|
||||
'.o_ComposerSuggestion',
|
||||
"Command suggestion should be present",
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('command suggestion correct data', async function (assert) {
|
||||
assert.expect(5);
|
||||
assert.expect(4);
|
||||
|
||||
const pyEnv = await startServer();
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create();
|
||||
const { createComposerSuggestionComponent, messaging } = await start();
|
||||
const thread = messaging.models['Thread'].findFromIdentifyingData({
|
||||
id: mailChannelId1,
|
||||
model: 'mail.channel',
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create({ name: 'my-channel' });
|
||||
const { insertText, openDiscuss } = await start({
|
||||
discuss: {
|
||||
params: {
|
||||
default_active_id: mailChannelId1,
|
||||
},
|
||||
},
|
||||
hasDiscuss: true,
|
||||
});
|
||||
const command = messaging.models['ChannelCommand'].create({
|
||||
methodName: '',
|
||||
name: 'whois',
|
||||
help: "Displays who it is",
|
||||
});
|
||||
await createComposerSuggestionComponent(thread.composer, {
|
||||
isActive: true,
|
||||
modelName: 'ChannelCommand',
|
||||
recordLocalId: command.localId,
|
||||
});
|
||||
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_ComposerSuggestion',
|
||||
"Command suggestion should be present"
|
||||
);
|
||||
await openDiscuss();
|
||||
await insertText('.o_ComposerTextInput_textarea', "/who");
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_ComposerSuggestion_part1',
|
||||
@@ -67,51 +50,40 @@ QUnit.test('command suggestion correct data', async function (assert) {
|
||||
);
|
||||
assert.strictEqual(
|
||||
document.querySelector(`.o_ComposerSuggestion_part1`).textContent,
|
||||
"whois",
|
||||
"who",
|
||||
"Command name should be displayed"
|
||||
);
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
document.querySelector('.o_ComposerSuggestion'),
|
||||
'.o_ComposerSuggestion_part2',
|
||||
"Command help should be present"
|
||||
);
|
||||
assert.strictEqual(
|
||||
document.querySelector(`.o_ComposerSuggestion_part2`).textContent,
|
||||
"Displays who it is",
|
||||
"List users in the current channel",
|
||||
"Command help should be displayed"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('command suggestion active', async function (assert) {
|
||||
assert.expect(2);
|
||||
assert.expect(1);
|
||||
|
||||
const pyEnv = await startServer();
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create();
|
||||
const { createComposerSuggestionComponent, messaging } = await start();
|
||||
const thread = messaging.models['Thread'].findFromIdentifyingData({
|
||||
id: mailChannelId1,
|
||||
model: 'mail.channel',
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create({ name: 'my-channel' });
|
||||
const { insertText, openDiscuss } = await start({
|
||||
discuss: {
|
||||
params: {
|
||||
default_active_id: mailChannelId1,
|
||||
},
|
||||
},
|
||||
hasDiscuss: true,
|
||||
});
|
||||
const command = messaging.models['ChannelCommand'].create({
|
||||
methodName: '',
|
||||
name: 'whois',
|
||||
help: "Displays who it is",
|
||||
});
|
||||
await createComposerSuggestionComponent(thread.composer, {
|
||||
isActive: true,
|
||||
modelName: 'ChannelCommand',
|
||||
recordLocalId: command.localId,
|
||||
});
|
||||
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_ComposerSuggestion',
|
||||
"Command suggestion should be displayed"
|
||||
);
|
||||
await openDiscuss();
|
||||
await insertText('.o_ComposerTextInput_textarea', "/who");
|
||||
assert.hasClass(
|
||||
document.querySelector('.o_ComposerSuggestion'),
|
||||
'active',
|
||||
"should be active initially"
|
||||
"1st suggestion should be active initially"
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
+44
-58
@@ -10,23 +10,22 @@ QUnit.test('partner mention suggestion displayed', async function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
const pyEnv = await startServer();
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create();
|
||||
const { createComposerSuggestionComponent, messaging } = await start();
|
||||
const thread = messaging.models['Thread'].findFromIdentifyingData({
|
||||
id: mailChannelId1,
|
||||
model: 'mail.channel',
|
||||
});
|
||||
const partner = messaging.models['Partner'].create({
|
||||
id: 7,
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create({});
|
||||
pyEnv['res.partner'].create({
|
||||
email: "demo_user@odoo.com",
|
||||
im_status: 'online',
|
||||
name: "Demo User",
|
||||
name: 'Demo User',
|
||||
});
|
||||
await createComposerSuggestionComponent(thread.composer, {
|
||||
isActive: true,
|
||||
modelName: 'Partner',
|
||||
recordLocalId: partner.localId,
|
||||
const { insertText, openDiscuss } = await start({
|
||||
discuss: {
|
||||
params: {
|
||||
default_active_id: mailChannelId1,
|
||||
},
|
||||
},
|
||||
hasDiscuss: true,
|
||||
});
|
||||
|
||||
await openDiscuss();
|
||||
await insertText('.o_ComposerTextInput_textarea', "@demo");
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
`.o_ComposerSuggestion`,
|
||||
@@ -35,35 +34,28 @@ QUnit.test('partner mention suggestion displayed', async function (assert) {
|
||||
});
|
||||
|
||||
QUnit.test('partner mention suggestion correct data', async function (assert) {
|
||||
assert.expect(6);
|
||||
assert.expect(5);
|
||||
|
||||
const pyEnv = await startServer();
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create();
|
||||
const { createComposerSuggestionComponent, messaging } = await start();
|
||||
const thread = messaging.models['Thread'].findFromIdentifyingData({
|
||||
id: mailChannelId1,
|
||||
model: 'mail.channel',
|
||||
});
|
||||
const partner = messaging.models['Partner'].create({
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create({});
|
||||
pyEnv['res.partner'].create({
|
||||
email: "demo_user@odoo.com",
|
||||
id: 7,
|
||||
im_status: 'online',
|
||||
name: "Demo User",
|
||||
name: 'Demo User',
|
||||
});
|
||||
await createComposerSuggestionComponent(thread.composer, {
|
||||
isActive: true,
|
||||
modelName: 'Partner',
|
||||
recordLocalId: partner.localId,
|
||||
const { insertText, openDiscuss } = await start({
|
||||
discuss: {
|
||||
params: {
|
||||
default_active_id: mailChannelId1,
|
||||
},
|
||||
},
|
||||
hasDiscuss: true,
|
||||
});
|
||||
|
||||
await openDiscuss();
|
||||
await insertText('.o_ComposerTextInput_textarea', "@demo");
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_ComposerSuggestion',
|
||||
"Partner mention suggestion should be present"
|
||||
);
|
||||
assert.strictEqual(
|
||||
document.querySelectorAll(`.o_PartnerImStatusIcon`).length,
|
||||
1,
|
||||
document.querySelector('.o_ComposerSuggestion'),
|
||||
'.o_PartnerImStatusIcon',
|
||||
"Partner's im_status should be displayed"
|
||||
);
|
||||
assert.containsOnce(
|
||||
@@ -72,7 +64,7 @@ QUnit.test('partner mention suggestion correct data', async function (assert) {
|
||||
"Partner's name should be present"
|
||||
);
|
||||
assert.strictEqual(
|
||||
document.querySelector(`.o_ComposerSuggestion_part1`).textContent,
|
||||
document.querySelector('.o_ComposerSuggestion_part1').textContent,
|
||||
"Demo User",
|
||||
"Partner's name should be displayed"
|
||||
);
|
||||
@@ -82,38 +74,32 @@ QUnit.test('partner mention suggestion correct data', async function (assert) {
|
||||
"Partner's email should be present"
|
||||
);
|
||||
assert.strictEqual(
|
||||
document.querySelector(`.o_ComposerSuggestion_part2`).textContent,
|
||||
document.querySelector('.o_ComposerSuggestion_part2').textContent,
|
||||
"(demo_user@odoo.com)",
|
||||
"Partner's email should be displayed"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test('partner mention suggestion active', async function (assert) {
|
||||
assert.expect(2);
|
||||
assert.expect(1);
|
||||
|
||||
const pyEnv = await startServer();
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create();
|
||||
const { createComposerSuggestionComponent, messaging } = await start();
|
||||
const thread = messaging.models['Thread'].findFromIdentifyingData({
|
||||
id: mailChannelId1,
|
||||
model: 'mail.channel',
|
||||
});
|
||||
const partner = messaging.models['Partner'].create({
|
||||
id: 7,
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create({});
|
||||
pyEnv['res.partner'].create({
|
||||
email: "demo_user@odoo.com",
|
||||
im_status: 'online',
|
||||
name: "Demo User",
|
||||
name: 'Demo User',
|
||||
});
|
||||
await createComposerSuggestionComponent(thread.composer, {
|
||||
isActive: true,
|
||||
modelName: 'Partner',
|
||||
recordLocalId: partner.localId,
|
||||
const { insertText, openDiscuss } = await start({
|
||||
discuss: {
|
||||
params: {
|
||||
default_active_id: mailChannelId1,
|
||||
},
|
||||
},
|
||||
hasDiscuss: true,
|
||||
});
|
||||
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_ComposerSuggestion',
|
||||
"Partner mention suggestion should be displayed"
|
||||
);
|
||||
await openDiscuss();
|
||||
await insertText('.o_ComposerTextInput_textarea', "@demo");
|
||||
assert.hasClass(
|
||||
document.querySelector('.o_ComposerSuggestion'),
|
||||
'active',
|
||||
|
||||
Reference in New Issue
Block a user