mirror of
https://github.com/bringout/oca-ocb-core.git
synced 2026-04-20 09:52:02 +02:00
19.0 vanilla
This commit is contained in:
parent
d1963a3c3a
commit
2d3ee4855a
7430 changed files with 2687981 additions and 2965473 deletions
|
|
@ -0,0 +1,514 @@
|
|||
import {
|
||||
click,
|
||||
contains,
|
||||
defineMailModels,
|
||||
hover,
|
||||
insertText,
|
||||
onRpcBefore,
|
||||
openDiscuss,
|
||||
start,
|
||||
startServer,
|
||||
} from "@mail/../tests/mail_test_helpers";
|
||||
import { describe, expect, test } from "@odoo/hoot";
|
||||
import { asyncStep, waitForSteps, Command, serverState } from "@web/../tests/web_test_helpers";
|
||||
import { press } from "@odoo/hoot-dom";
|
||||
|
||||
import { rpc } from "@web/core/network/rpc";
|
||||
|
||||
describe.current.tags("desktop");
|
||||
defineMailModels();
|
||||
|
||||
test("auto layout with link preview list", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const linkPreviewId = pyEnv["mail.link.preview"].create({
|
||||
og_description: "test description",
|
||||
og_image: "https://c.tenor.com/B_zYdea4l-4AAAAC/yay-minions.gif",
|
||||
og_mimetype: "image/gif",
|
||||
og_title: "Yay Minions GIF - Yay Minions Happiness - Discover & Share GIFs",
|
||||
og_type: "video.other",
|
||||
source_url: "https://tenor.com/view/yay-minions-happiness-happy-excited-gif-15324023",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "not empty",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId })],
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await contains(".o-mail-Message .o-mail-LinkPreviewList");
|
||||
});
|
||||
|
||||
test("auto layout with link preview as gif", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const linkPreviewId = pyEnv["mail.link.preview"].create({
|
||||
og_description: "test description",
|
||||
og_image: "https://c.tenor.com/B_zYdea4l-4AAAAC/yay-minions.gif",
|
||||
og_mimetype: "image/gif",
|
||||
og_title: "Yay Minions GIF - Yay Minions Happiness - Discover & Share GIFs",
|
||||
og_type: "video.other",
|
||||
source_url: "https://tenor.com/view/yay-minions-happiness-happy-excited-gif-15324023",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "not empty",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId })],
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await contains(".o-mail-LinkPreviewImage");
|
||||
});
|
||||
|
||||
test("simplest card layout", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const linkPreviewId = pyEnv["mail.link.preview"].create({
|
||||
og_description: "Description",
|
||||
og_title: "Article title",
|
||||
og_type: "article",
|
||||
source_url: "https://www.odoo.com",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "not empty",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId })],
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await contains(".o-mail-LinkPreviewCard");
|
||||
await contains(".o-mail-LinkPreviewCard h6", { text: "Article title" });
|
||||
await contains(".o-mail-LinkPreviewCard p", { text: "Description" });
|
||||
});
|
||||
|
||||
test("simplest card layout with image", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const linkPreviewId = pyEnv["mail.link.preview"].create({
|
||||
og_description: "Description",
|
||||
og_image: "https://c.tenor.com/B_zYdea4l-4AAAAC/yay-minions.gif",
|
||||
og_title: "Article title",
|
||||
og_type: "article",
|
||||
source_url: "https://www.odoo.com",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "not empty",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId })],
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await contains(".o-mail-LinkPreviewCard");
|
||||
await contains(".o-mail-LinkPreviewCard h6", { text: "Article title" });
|
||||
await contains(".o-mail-LinkPreviewCard p", { text: "Description" });
|
||||
await contains(".o-mail-LinkPreviewCard img");
|
||||
});
|
||||
|
||||
test("Link preview video layout", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const linkPreviewId = pyEnv["mail.link.preview"].create({
|
||||
og_description: "Description",
|
||||
og_image: "https://c.tenor.com/B_zYdea4l-4AAAAC/yay-minions.gif",
|
||||
og_title: "video title",
|
||||
og_type: "video.other",
|
||||
source_url: "https://www.odoo.com",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "not empty",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId })],
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await contains(".o-mail-LinkPreviewVideo");
|
||||
await contains(".o-mail-LinkPreviewVideo h6", { text: "video title" });
|
||||
await contains(".o-mail-LinkPreviewVideo p", { text: "Description" });
|
||||
await contains(".o-mail-LinkPreviewVideo-overlay");
|
||||
});
|
||||
|
||||
test("Link preview image layout", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const linkPreviewId = pyEnv["mail.link.preview"].create({
|
||||
image_mimetype: "image/jpg",
|
||||
source_url:
|
||||
"https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/Siberischer_tiger_de_edit02.jpg/290px-Siberischer_tiger_de_edit02.jpg",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "not empty",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId })],
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await contains(".o-mail-LinkPreviewImage");
|
||||
});
|
||||
|
||||
test("Remove link preview Gif", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const linkPreviewId = pyEnv["mail.link.preview"].create({
|
||||
og_description: "test description",
|
||||
og_image: "https://c.tenor.com/B_zYdea4l-4AAAAC/yay-minions.gif",
|
||||
og_mimetype: "image/gif",
|
||||
og_title: "Yay Minions GIF - Yay Minions Happiness - Discover & Share GIFs",
|
||||
og_type: "video.other",
|
||||
source_url: "https://tenor.com/view/yay-minions-happiness-happy-excited-gif-15324023",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "not empty",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId })],
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await click(".o-mail-LinkPreviewImage button[aria-label='Remove']");
|
||||
await contains("p", { text: "Do you really want to delete this preview?" });
|
||||
await click(".modal-footer button", { text: "Delete" });
|
||||
await contains(".o-mail-LinkPreviewImage", { count: 0 });
|
||||
});
|
||||
|
||||
test("Remove link preview card", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const linkPreviewId = pyEnv["mail.link.preview"].create({
|
||||
og_description: "Description",
|
||||
og_title: "Article title",
|
||||
og_type: "article",
|
||||
source_url: "https://www.odoo.com",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "not empty",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId })],
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await click(".o-mail-LinkPreviewCard button[aria-label='Remove']");
|
||||
await contains("p", { text: "Do you really want to delete this preview?" });
|
||||
await click(".modal-footer button", { text: "Delete" });
|
||||
await contains(".o-mail-LinkPreviewCard", { count: 0 });
|
||||
});
|
||||
|
||||
test("Remove link preview video", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const linkPreviewId = pyEnv["mail.link.preview"].create({
|
||||
og_description: "Description",
|
||||
og_image: "https://c.tenor.com/B_zYdea4l-4AAAAC/yay-minions.gif",
|
||||
og_title: "video title",
|
||||
og_type: "video.other",
|
||||
source_url: "https://www.odoo.com",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "not empty",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId })],
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await click(".o-mail-LinkPreviewVideo button[aria-label='Remove']");
|
||||
await contains("p", { text: "Do you really want to delete this preview?" });
|
||||
await click(".modal-footer button", { text: "Delete" });
|
||||
await contains(".o-mail-LinkPreviewVideo", { count: 0 });
|
||||
});
|
||||
|
||||
test("Remove link preview image", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const linkPreviewId = pyEnv["mail.link.preview"].create({
|
||||
image_mimetype: "image/jpg",
|
||||
source_url:
|
||||
"https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/Siberischer_tiger_de_edit02.jpg/290px-Siberischer_tiger_de_edit02.jpg",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "not empty",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId })],
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await click(".o-mail-LinkPreviewImage button[aria-label='Remove']");
|
||||
await contains("p", { text: "Do you really want to delete this preview?" });
|
||||
await click(".modal-footer button", { text: "Delete" });
|
||||
await contains(".o-mail-LinkPreviewImage", { count: 0 });
|
||||
});
|
||||
|
||||
test("No crash on receiving link preview of non-known message", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const linkPreviewId = pyEnv["mail.link.preview"].create({
|
||||
image_mimetype: "image/jpg",
|
||||
source_url:
|
||||
"https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/Siberischer_tiger_de_edit02.jpg/290px-Siberischer_tiger_de_edit02.jpg",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
const messageId = pyEnv["mail.message"].create({
|
||||
body: "https://make-link-preview.com",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId })],
|
||||
});
|
||||
const messageLinkPreviewId = pyEnv["mail.message.link.preview"].create({
|
||||
message_id: messageId,
|
||||
link_preview_id: linkPreviewId,
|
||||
});
|
||||
await start();
|
||||
await openDiscuss();
|
||||
rpc("/mail/link_preview", { message_id: messageId });
|
||||
rpc("/mail/link_preview/hide", { message_link_preview_ids: [messageLinkPreviewId] });
|
||||
expect(true).toBe(true, { message: "no assertions" });
|
||||
});
|
||||
|
||||
test("Squash the message and the link preview when the link preview is an image and the link is the only text in the message", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const linkPreviewId = pyEnv["mail.link.preview"].create({
|
||||
image_mimetype: "image/jpg",
|
||||
source_url:
|
||||
"https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/Siberischer_tiger_de_edit02.jpg/290px-Siberischer_tiger_de_edit02.jpg",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "<a href='linkPreviewLink'>http://linkPreview</a>",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId })],
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await contains(".o-mail-LinkPreviewImage");
|
||||
await contains(".o-mail-Message-bubble", { count: 0 });
|
||||
});
|
||||
|
||||
test("Link preview and message should not be squashed when the link preview is not an image", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const linkPreviewId = pyEnv["mail.link.preview"].create({
|
||||
og_description: "Description",
|
||||
og_title: "Article title",
|
||||
og_type: "article",
|
||||
source_url: "https://www.odoo.com",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "<a href='linkPreviewLink'>http://linkPreview</a>",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId })],
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await contains(".o-mail-Message-bubble");
|
||||
});
|
||||
|
||||
test("Link preview and message should not be squashed when there is more than the link in the message", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const linkPreviewId = pyEnv["mail.link.preview"].create({
|
||||
image_mimetype: "image/jpg",
|
||||
source_url:
|
||||
"https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/Siberischer_tiger_de_edit02.jpg/290px-Siberischer_tiger_de_edit02.jpg",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "<a href='linkPreviewLink'>http://linkPreview</a> not empty",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId })],
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await contains(".o-mail-Message-bubble");
|
||||
});
|
||||
|
||||
test("Sending message with link preview URL should show a link preview card", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await insertText(".o-mail-Composer-input", "https://make-link-preview.com");
|
||||
await press("Enter");
|
||||
await contains(".o-mail-LinkPreviewCard");
|
||||
});
|
||||
|
||||
test("Delete all link previews at once", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const [linkPreviewId_1, linkPreviewId_2] = pyEnv["mail.link.preview"].create([
|
||||
{
|
||||
og_description: "Description",
|
||||
og_title: "Article title 1",
|
||||
og_type: "article",
|
||||
source_url: "https://www.odoo.com",
|
||||
},
|
||||
{
|
||||
image_mimetype: "image/jpg",
|
||||
source_url:
|
||||
"https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/Siberischer_tiger_de_edit02.jpg/290px-Siberischer_tiger_de_edit02.jpg",
|
||||
},
|
||||
]);
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "wololo" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "not empty",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [
|
||||
Command.create({ link_preview_id: linkPreviewId_1 }),
|
||||
Command.create({ link_preview_id: linkPreviewId_2 }),
|
||||
],
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await click(".o-mail-LinkPreviewCard button[aria-label='Remove']");
|
||||
await click(".modal-footer button", { text: "Delete all previews" });
|
||||
await contains(".o-mail-LinkPreviewCard", { count: 0 });
|
||||
await contains(".o-mail-LinkPreviewImage", { count: 0 });
|
||||
});
|
||||
|
||||
test("link preview request is only made when message contains URL", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "Sales" });
|
||||
onRpcBefore("/mail/link_preview", () => asyncStep("/mail/link_preview"));
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await insertText(".o-mail-Composer-input", "Hello, this message does not contain any link");
|
||||
await press("Enter");
|
||||
await contains(".o-mail-Message", {
|
||||
text: "Hello, this message does not contain any link",
|
||||
});
|
||||
await waitForSteps([]);
|
||||
await insertText(".o-mail-Composer-input", "#");
|
||||
await click(".o-mail-NavigableList-item", { text: "Sales" });
|
||||
await press("Enter");
|
||||
await contains(".o-mail-Message", { text: "Sales" });
|
||||
await waitForSteps([]);
|
||||
await insertText(".o-mail-Composer-input", "https://www.odoo.com");
|
||||
await press("Enter");
|
||||
await waitForSteps(["/mail/link_preview"]);
|
||||
});
|
||||
|
||||
test("youtube and gdrive videos URL are embed", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "General" });
|
||||
const [linkPreviewId_1, linkPreviewId_2] = pyEnv["mail.link.preview"].create([
|
||||
{
|
||||
og_title: "vokoscreenNG-2024-08-22_13-56-37.mkv",
|
||||
og_type: "article",
|
||||
source_url: "https://drive.google.com/file/d/195a8fSNxwmkfs9sDS7OCB2nX03iFr21P/view",
|
||||
},
|
||||
{
|
||||
og_title: "Cinematic",
|
||||
og_type: "video",
|
||||
source_url: "https://www.youtube.com/watch?v=9bZkp7q19f0",
|
||||
},
|
||||
]);
|
||||
pyEnv["mail.message"].create([
|
||||
{
|
||||
body: "GDrive video preview",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId_1 })],
|
||||
},
|
||||
{
|
||||
body: "YT video preview",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId_2 })],
|
||||
},
|
||||
]);
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await click(".o-mail-LinkPreviewVideo[data-provider=google-drive] .fa-play");
|
||||
await contains(
|
||||
"iframe[data-src='https://drive.google.com/file/d/195a8fSNxwmkfs9sDS7OCB2nX03iFr21P/preview']",
|
||||
{ parent: [".o-mail-LinkPreviewVideo[data-provider=google-drive]"] }
|
||||
);
|
||||
await click(".o-mail-LinkPreviewVideo[data-provider=youtube] .fa-play");
|
||||
await contains("iframe[data-src='https://www.youtube.com/embed/9bZkp7q19f0?autoplay=1']", {
|
||||
parent: [".o-mail-LinkPreviewVideo[data-provider=youtube]"],
|
||||
});
|
||||
});
|
||||
|
||||
test("Internal user can't delete others preview", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const [linkPreviewId_1, linkPreviewId_2] = pyEnv["mail.link.preview"].create([
|
||||
{
|
||||
og_description: "Description",
|
||||
og_title: "Article title 1",
|
||||
og_type: "article",
|
||||
source_url: "https://www.odoo.com/",
|
||||
},
|
||||
{
|
||||
og_description: "Description",
|
||||
og_title: "Article title 2",
|
||||
og_type: "article",
|
||||
source_url: "https://example.com",
|
||||
},
|
||||
]);
|
||||
const partnerId = pyEnv["res.partner"].create({ name: "Test User" });
|
||||
const userId = pyEnv["res.users"].create({
|
||||
partner_id: partnerId,
|
||||
login: "testUser",
|
||||
password: "testUser",
|
||||
});
|
||||
const channelId = pyEnv["discuss.channel"].create({
|
||||
name: "wololo",
|
||||
channel_member_ids: [
|
||||
Command.create({ partner_id: serverState.partnerId }),
|
||||
Command.create({ partner_id: partnerId }),
|
||||
],
|
||||
});
|
||||
pyEnv["mail.message"].create([
|
||||
{
|
||||
body: "msg-1",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
author_id: serverState.partnerId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId_1 })],
|
||||
},
|
||||
{
|
||||
body: "msg-2",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
author_id: partnerId,
|
||||
message_link_preview_ids: [Command.create({ link_preview_id: linkPreviewId_2 })],
|
||||
},
|
||||
]);
|
||||
await start({ authenticateAs: pyEnv["res.users"].read(userId)[0] });
|
||||
await openDiscuss(channelId);
|
||||
await hover(".o-mail-Message:contains('msg-2') .o-mail-LinkPreviewCard");
|
||||
await contains(
|
||||
".o-mail-Message:contains('msg-2') .o-mail-LinkPreviewCard button[aria-label='Remove']"
|
||||
);
|
||||
await hover(".o-mail-Message:contains('msg-1') .o-mail-LinkPreviewCard");
|
||||
await contains(
|
||||
".o-mail-Message:contains('msg-1') .o-mail-LinkPreviewCard button[aria-label='Remove']",
|
||||
{ count: 0 }
|
||||
);
|
||||
});
|
||||
2330
odoo-bringout-oca-ocb-mail/mail/static/tests/message/message.test.js
Normal file
2330
odoo-bringout-oca-ocb-mail/mail/static/tests/message/message.test.js
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,269 @@
|
|||
import { insertText as htmlInsertText } from "@html_editor/../tests/_helpers/user_actions";
|
||||
import {
|
||||
click,
|
||||
contains,
|
||||
defineMailModels,
|
||||
openDiscuss,
|
||||
start,
|
||||
startServer,
|
||||
openFormView,
|
||||
} from "@mail/../tests/mail_test_helpers";
|
||||
import { describe, test } from "@odoo/hoot";
|
||||
import { queryFirst } from "@odoo/hoot-dom";
|
||||
import { disableAnimations } from "@odoo/hoot-mock";
|
||||
import { getService, serverState } from "@web/../tests/web_test_helpers";
|
||||
import { deserializeDateTime } from "@web/core/l10n/dates";
|
||||
|
||||
import { getOrigin } from "@web/core/utils/urls";
|
||||
|
||||
describe.current.tags("desktop");
|
||||
defineMailModels();
|
||||
|
||||
test("click on message in reply to highlight the parent message", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "general" });
|
||||
const messageId = pyEnv["mail.message"].create({
|
||||
body: "Hey lol",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
});
|
||||
pyEnv["mail.message"].create({
|
||||
body: "Reply to Hey",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
parent_id: messageId,
|
||||
res_id: channelId,
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await click(".o-mail-MessageInReply-message", {
|
||||
parent: [".o-mail-Message", { text: "Reply to Hey" }],
|
||||
});
|
||||
await contains(".o-mail-Message.o-highlighted .o-mail-Message-content", { text: "Hey lol" });
|
||||
});
|
||||
|
||||
test("click on message in reply to scroll to the parent message", async () => {
|
||||
disableAnimations();
|
||||
const pyEnv = await startServer();
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "general" });
|
||||
const [oldestMessageId] = pyEnv["mail.message"].create(
|
||||
Array(20)
|
||||
.fill(0)
|
||||
.map(() => ({
|
||||
body: "Non Empty Body ".repeat(25),
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
}))
|
||||
);
|
||||
pyEnv["mail.message"].create({
|
||||
body: "Response to first message",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
parent_id: oldestMessageId,
|
||||
res_id: channelId,
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await click(".o-mail-MessageInReply-message", {
|
||||
parent: [".o-mail-Message", { text: "Response to first message" }],
|
||||
});
|
||||
await contains(":nth-child(1 of .o-mail-Message)", { visible: true });
|
||||
});
|
||||
|
||||
test("reply shows correct author avatar", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "general" });
|
||||
const messageId = pyEnv["mail.message"].create({
|
||||
body: "Hey there",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
});
|
||||
const partnerId = pyEnv["res.partner"].create({ name: "John Doe" });
|
||||
const partner = pyEnv["res.partner"].search_read([["id", "=", serverState.partnerId]])[0];
|
||||
pyEnv["mail.message"].create({
|
||||
body: "Howdy",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
author_id: partnerId,
|
||||
parent_id: messageId,
|
||||
res_id: channelId,
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await contains(
|
||||
`.o-mail-MessageInReply-avatar[data-src='${`${getOrigin()}/web/image/res.partner/${
|
||||
serverState.partnerId
|
||||
}/avatar_128?unique=${deserializeDateTime(partner.write_date).ts}`}`
|
||||
);
|
||||
});
|
||||
|
||||
test("click on message in reply highlights original message", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "general" });
|
||||
const messageId = pyEnv["mail.message"].create({
|
||||
body: "",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
});
|
||||
pyEnv["mail.message"].create({
|
||||
body: "Response to deleted message",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
parent_id: messageId,
|
||||
res_id: channelId,
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await click(
|
||||
".o-mail-Message:contains('Response to deleted message') .o-mail-MessageInReply:contains('Original message was deleted') .cursor-pointer"
|
||||
);
|
||||
await contains(".o-mail-Message.o-highlighted:contains('This message has been removed')");
|
||||
});
|
||||
|
||||
test("can reply to logged note in chatter", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const partnerBId = pyEnv["res.partner"].create({ name: "Partner B" });
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "general" });
|
||||
pyEnv["mail.message"].create([
|
||||
{
|
||||
author_id: partnerBId,
|
||||
body: "Test message from B",
|
||||
model: "res.partner",
|
||||
res_id: serverState.partnerId,
|
||||
subtype_id: pyEnv["mail.message.subtype"].search([
|
||||
["subtype_xmlid", "=", "mail.mt_note"],
|
||||
])[0],
|
||||
},
|
||||
{
|
||||
author_id: serverState.partnerId,
|
||||
body: "Another msg",
|
||||
model: "discuss.channel",
|
||||
message_type: "comment",
|
||||
res_id: channelId,
|
||||
},
|
||||
]);
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await click(".o-mail-Message [title='Expand']");
|
||||
await contains(".o-dropdown-item:contains('Reply')");
|
||||
await openFormView("res.partner", serverState.partnerId);
|
||||
await click(".o-mail-Message:contains('Test message from B') [title='Reply']");
|
||||
await contains("button.active", { text: "Log note" });
|
||||
await contains(".o-mail-Composer.o-focused .o-mail-Composer-input", { value: "@Partner B " });
|
||||
await click(".o-mail-Composer-send:enabled");
|
||||
await contains(".o-mail-Message a.o_mail_redirect", { text: "@Partner B" });
|
||||
await contains(".o-mail-Message:contains('@Partner B') [title='Edit']");
|
||||
await contains(".o-mail-Message:contains('@Partner B') [title='Reply']", { count: 0 });
|
||||
await click(".o-mail-Message:contains('@Partner B') [title='Expand']");
|
||||
await contains(".o-dropdown-item:contains('Delete')");
|
||||
await contains(".o-dropdown-item:contains('Reply')", { count: 0 });
|
||||
});
|
||||
|
||||
test.tags("html composer");
|
||||
test("reply to logged note in chatter keeps prefilled mention in html composer", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const partnerBId = pyEnv["res.partner"].create({ name: "Partner B" });
|
||||
pyEnv["mail.message"].create({
|
||||
author_id: partnerBId,
|
||||
body: "Test message from B",
|
||||
model: "res.partner",
|
||||
res_id: serverState.partnerId,
|
||||
subtype_id: pyEnv["mail.message.subtype"].search([
|
||||
["subtype_xmlid", "=", "mail.mt_note"],
|
||||
])[0],
|
||||
});
|
||||
await start();
|
||||
getService("mail.composer").setHtmlComposer();
|
||||
await openFormView("res.partner", serverState.partnerId);
|
||||
await click(".o-mail-Message:contains('Test message from B') [title='Reply']");
|
||||
await contains("button.active:text('Log note')");
|
||||
await contains(".o-mail-Composer.o-focused .o-mail-Composer-html.odoo-editor-editable");
|
||||
await contains(".o-mail-Composer-html.odoo-editor-editable a.o_mail_redirect:text('@Partner B')");
|
||||
const editor = {
|
||||
document,
|
||||
editable: queryFirst(".o-mail-Composer-html.odoo-editor-editable"),
|
||||
};
|
||||
await htmlInsertText(editor, "Hello");
|
||||
await contains(".o-mail-Composer-send:enabled");
|
||||
await click(".o-mail-Composer-send:enabled");
|
||||
await contains(".o-mail-Message:contains('Hello') a.o_mail_redirect:text('@Partner B')");
|
||||
});
|
||||
|
||||
test("Replying to a message containing line breaks should be correctly inlined", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "general" });
|
||||
const messageId = pyEnv["mail.message"].create({
|
||||
body: "<p>Message first line.<br>Message second line.<br>Message third line.</p>",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
});
|
||||
const partnerId = pyEnv["res.partner"].create({ name: "John Doe" });
|
||||
pyEnv["mail.message"].create({
|
||||
body: "Howdy",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
author_id: partnerId,
|
||||
parent_id: messageId,
|
||||
res_id: channelId,
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await contains(".o-mail-MessageInReply-message", {
|
||||
text: "Message first line. Message second line. Message third line.",
|
||||
});
|
||||
});
|
||||
|
||||
test("reply with only attachment shows parent message context", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const channelId = pyEnv["discuss.channel"].create({ name: "general" });
|
||||
const originalMessageId = pyEnv["mail.message"].create({
|
||||
body: "Original message content",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
res_id: channelId,
|
||||
});
|
||||
const attachmentId = pyEnv["ir.attachment"].create({
|
||||
name: "test_image.png",
|
||||
mimetype: "image/png",
|
||||
});
|
||||
pyEnv["mail.message"].create({
|
||||
attachment_ids: [attachmentId],
|
||||
body: "",
|
||||
message_type: "comment",
|
||||
model: "discuss.channel",
|
||||
parent_id: originalMessageId,
|
||||
res_id: channelId,
|
||||
});
|
||||
await start();
|
||||
await openDiscuss(channelId);
|
||||
await contains(".o-mail-MessageInReply-message", {
|
||||
text: "Original message content",
|
||||
});
|
||||
});
|
||||
|
||||
test("replying to a note restores focus on an already open composer", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const partnerBId = pyEnv["res.partner"].create({ name: "Partner B" });
|
||||
pyEnv["mail.message"].create({
|
||||
author_id: partnerBId,
|
||||
body: "Test message from B",
|
||||
model: "res.partner",
|
||||
res_id: serverState.partnerId,
|
||||
subtype_id: pyEnv["mail.message.subtype"].search([
|
||||
["subtype_xmlid", "=", "mail.mt_note"],
|
||||
])[0],
|
||||
});
|
||||
await start();
|
||||
await openFormView("res.partner", serverState.partnerId);
|
||||
await click("button:not(.active):text('Log note')");
|
||||
await contains(".o-mail-Composer.o-focused");
|
||||
queryFirst(".o-mail-Composer-input").blur();
|
||||
await contains(".o-mail-Composer.o-focused", { count: 0 });
|
||||
await click(".o-mail-Message-actions [title='Reply']");
|
||||
await contains(".o-mail-Composer.o-focused");
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue