[FIX] mail: do not fetch attachment style in QUnit tests

Task-2339931

closes odoo/odoo#57875

X-original-commit: 7586f7756859bb0711eee8a82bf728a039ad0d72
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Alexandre Kühn
2020-09-16 15:28:00 +00:00
parent 65094a3af7
commit 74ae95db22
3 changed files with 20 additions and 0 deletions
@@ -71,6 +71,12 @@ class Attachment extends Component {
if (this.attachment.fileType !== 'image') {
return '';
}
if (this.env.isQUnitTest) {
// background-image:url is hardly mockable, and attachments in
// QUnit tests do not actually exist in DB, so style should not
// be fetched at all.
return '';
}
let size;
if (this.detailsMode === 'card') {
size = '38x38';
+7
View File
@@ -56,6 +56,13 @@ function addMessagingToEnv(providedEnv = {}) {
}
return this.messaging.isInitialized;
},
/**
* States whether the environment is in QUnit test or not.
*
* Useful to prevent some behaviour in QUnit tests, like applying
* style of attachment that uses url.
*/
isQUnitTest: true,
loadingBaseDelayDuration: providedEnv.loadingBaseDelayDuration || 0,
messaging: undefined,
messagingCreatedPromise: makeDeferred(),
+7
View File
@@ -71,6 +71,13 @@ Object.assign(env, {
}
return this.messaging.isInitialized;
},
/**
* States whether the environment is in QUnit test or not.
*
* Useful to prevent some behaviour in QUnit tests, like applying
* style of attachment that uses url.
*/
isQUnitTest: false,
loadingBaseDelayDuration: 400,
messaging: undefined,
messagingBus: new EventBus(),