diff --git a/addons/mail/static/src/components/activity/tests/activity_tests.js b/addons/mail/static/src/components/activity/tests/activity_tests.js index 57347fa352b..15518c6b6cc 100644 --- a/addons/mail/static/src/components/activity/tests/activity_tests.js +++ b/addons/mail/static/src/components/activity/tests/activity_tests.js @@ -788,7 +788,7 @@ QUnit.test('activity upload document is available', async function (assert) { }); this.data['mail.activity'].records.push({ activity_category: 'upload_file', - activity_type_id: 1, + activity_type_id: 28, can_write: true, id: 12, res_id: 100, @@ -1275,6 +1275,54 @@ 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({ + activity_ids: [activityId], + id: 100, + }); + this.data['mail.activity'].records.push({ + activity_category: 'upload_file', + activity_type_id: 28, + can_write: true, + id: activityId, + res_id: 100, + res_model: 'res.partner', + }); + const { createChatterContainerComponent } = await this.start(); + await createChatterContainerComponent({ + threadId: 100, + threadModel: 'res.partner', + }); + + // Update the record server side then fetch updated data in order to + // emulate what happens when using the form view. + await this.env.services.rpc({ + model: 'mail.activity', + method: 'write', + args: [[activityId], { + activity_category: 'default', + activity_type_id: 1, + }], + }); + await afterNextRender(async () => { + const activity = this.messaging.models['Activity'].findFromIdentifyingData({ id: activityId }); + await activity.fetchAndUpdate(); + }); + assert.containsOnce( + document.body, + '.o_Activity_markDoneButton', + "should have a mark done button when changing activity type from 'Upload Document' to 'Email'" + ); + assert.containsNone( + document.body, + '.o_Activity_uploadButton', + "should not have an upload button after changing the activity type from 'Upload Document' to 'Email'" + ); +}); + }); }); }); diff --git a/addons/mail/static/tests/helpers/mock_models.js b/addons/mail/static/tests/helpers/mock_models.js index 2f2ae442d5b..336c94b862d 100644 --- a/addons/mail/static/tests/helpers/mock_models.js +++ b/addons/mail/static/tests/helpers/mock_models.js @@ -69,6 +69,7 @@ export class MockModels { }, records: [ { icon: 'fa-envelope', id: 1, name: "Email" }, + { icon: 'fa-upload', id: 28, name: "Upload Document" }, ], }, 'mail.channel': {