[FIX] mail: fix remove attachment from composer test
This PR fixes the 3922 runbot issue. closes odoo/odoo#96972 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
@@ -92,6 +92,7 @@ registerModel({
|
||||
if (!this.exists()) {
|
||||
return;
|
||||
}
|
||||
this.messaging.messagingBus.trigger('o-attachment-deleted', { attachment: this });
|
||||
this.delete();
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -37,6 +37,9 @@ registerModel({
|
||||
*/
|
||||
async uploadFiles(files) {
|
||||
await this._performUpload({ files });
|
||||
if (!this.exists()) {
|
||||
return;
|
||||
}
|
||||
if (this.fileInput && this.fileInput.el) {
|
||||
this.fileInput.el.value = '';
|
||||
}
|
||||
|
||||
@@ -148,6 +148,7 @@ registerModel({
|
||||
_handleNotificationAttachmentDelete(payload) {
|
||||
const attachment = this.messaging.models['Attachment'].findFromIdentifyingData(payload);
|
||||
if (attachment) {
|
||||
this.messaging.messagingBus.trigger('o-attachment-deleted', { attachment });
|
||||
attachment.delete();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -352,6 +352,7 @@ patch(MockServer.prototype, 'mail', {
|
||||
* @param {integer} attachment_id
|
||||
*/
|
||||
async _mockRouteMailAttachmentRemove(attachment_id) {
|
||||
this.pyEnv['bus.bus']._sendone(this.currentPartnerId, 'ir.attachment/delete', { id: attachment_id });
|
||||
return this.pyEnv['ir.attachment'].unlink([attachment_id]);
|
||||
},
|
||||
|
||||
|
||||
@@ -1292,7 +1292,7 @@ QUnit.test('remove an attachment from composer does not need any confirmation',
|
||||
|
||||
const pyEnv = await startServer();
|
||||
const mailChannelId1 = pyEnv['mail.channel'].create({});
|
||||
const { click, messaging, openDiscuss } = await start({
|
||||
const { afterEvent, messaging, openDiscuss } = await start({
|
||||
discuss: {
|
||||
context: { active_id: mailChannelId1 },
|
||||
},
|
||||
@@ -1317,7 +1317,18 @@ QUnit.test('remove an attachment from composer does not need any confirmation',
|
||||
"should have only one attachment"
|
||||
);
|
||||
|
||||
await click('.o_AttachmentCard_asideItemUnlink');
|
||||
const attachmentLocalId = document.querySelector('.o_AttachmentCard').dataset.id;
|
||||
await afterNextRender(() => afterEvent({
|
||||
eventName: 'o-attachment-deleted',
|
||||
func() {
|
||||
document.querySelector('.o_AttachmentCard_asideItemUnlink').click();
|
||||
},
|
||||
message: "should wait until attachment is deleted",
|
||||
predicate: ({ attachment }) => {
|
||||
return attachment.localId === attachmentLocalId;
|
||||
},
|
||||
}));
|
||||
|
||||
assert.containsNone(
|
||||
document.body,
|
||||
'.o_Composer .o_AttachmentCard',
|
||||
|
||||
Reference in New Issue
Block a user