[FIX] mail: fix traceback when deleting a link preview
closes odoo/odoo#117908 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -258,10 +258,10 @@ export class Messaging {
|
||||
case "mail.link.preview/delete":
|
||||
{
|
||||
const { id, message_id } = notif.payload;
|
||||
const index = this.store.messages[message_id].linkPreviews.findIndex(
|
||||
removeFromArrayWithPredicate(
|
||||
this.store.messages[message_id].linkPreviews,
|
||||
(linkPreview) => linkPreview.id === id
|
||||
);
|
||||
delete this.store.messages[message_id].linkPreviews[index];
|
||||
}
|
||||
break;
|
||||
case "mail.message/inbox": {
|
||||
|
||||
@@ -73,6 +73,20 @@ patch(MockServer.prototype, "mail/controllers/discuss", {
|
||||
if (route === "/mail/link_preview") {
|
||||
return this._mockRouteMailLinkPreview(args.message_id);
|
||||
}
|
||||
if (route == "/mail/link_preview/delete") {
|
||||
const [linkPreview] = this.pyEnv["mail.link.preview"].searchRead([
|
||||
["id", "=", args.link_preview_id],
|
||||
]);
|
||||
this.pyEnv["bus.bus"]._sendone(
|
||||
this.pyEnv.currentPartnerId,
|
||||
"mail.link.preview/delete",
|
||||
{
|
||||
id: linkPreview.id,
|
||||
message_id: linkPreview.message_id[0],
|
||||
}
|
||||
);
|
||||
return args;
|
||||
}
|
||||
if (route === "/mail/load_message_failures") {
|
||||
return this._mockRouteMailLoadMessageFailures();
|
||||
}
|
||||
|
||||
@@ -165,6 +165,8 @@ QUnit.test("Remove link preview Gif", async (assert) => {
|
||||
await openDiscuss(channelId);
|
||||
await click(".o-mail-LinkPreviewImage button[aria-label='Remove']");
|
||||
assert.containsOnce($, "p:contains(Do you really want to delete this preview?)");
|
||||
await click(".modal-footer button:contains(Ok)");
|
||||
assert.containsNone($, ".o-mail-LinkPreviewImage");
|
||||
});
|
||||
|
||||
QUnit.test("Remove link preview card", async (assert) => {
|
||||
@@ -187,6 +189,8 @@ QUnit.test("Remove link preview card", async (assert) => {
|
||||
await openDiscuss(channelId);
|
||||
await click(".o-mail-LinkPreviewCard button[aria-label='Remove']");
|
||||
assert.containsOnce($, "p:contains(Do you really want to delete this preview?)");
|
||||
await click(".modal-footer button:contains(Ok)");
|
||||
assert.containsNone($, ".o-mail-LinkPreviewCard");
|
||||
});
|
||||
|
||||
QUnit.test("Remove link preview video", async (assert) => {
|
||||
@@ -210,6 +214,8 @@ QUnit.test("Remove link preview video", async (assert) => {
|
||||
await openDiscuss(channelId);
|
||||
await click(".o-mail-LinkPreviewVideo button[aria-label='Remove']");
|
||||
assert.containsOnce($, "p:contains(Do you really want to delete this preview?)");
|
||||
await click(".modal-footer button:contains(Ok)");
|
||||
assert.containsNone($, ".o-mail-LinkPreviewVideo");
|
||||
});
|
||||
|
||||
QUnit.test("Remove link preview image", async (assert) => {
|
||||
@@ -231,4 +237,6 @@ QUnit.test("Remove link preview image", async (assert) => {
|
||||
await openDiscuss(channelId);
|
||||
await click(".o-mail-LinkPreviewImage button[aria-label='Remove']");
|
||||
assert.containsOnce($, "p:contains(Do you really want to delete this preview?)");
|
||||
await click(".modal-footer button:contains(Ok)");
|
||||
assert.containsNone($, ".o-mail-LinkPreviewImage");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user