[FIX] mail: guard the thread name and test the fallback

task-2343800

closes odoo/odoo#58848

X-original-commit: 13d78eda1243a5a625473adbae981b2891221ffc
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Didier (did)
2020-09-29 15:36:10 +00:00
parent 91f9520ef0
commit 5be44732cb
2 changed files with 18 additions and 1 deletions
@@ -38,7 +38,7 @@
<b class="text-muted">To: </b>
<em class="text-muted">Followers of </em>
<b>
<t t-if="composer.thread">
<t t-if="composer.thread and composer.thread.name">
&#32;&quot;<t t-esc="composer.thread.name"/>&quot;
</t>
<t t-else="">
@@ -1842,6 +1842,23 @@ QUnit.test('remove an uploading attachment aborts upload', async function (asser
});
});
QUnit.test("basic rendering when sending a message to the followers and thread doesn't have a name", async function (assert) {
assert.expect(1);
await this.start();
const thread = this.env.models['mail.thread'].create({
composer: [['create', { isLog: false }]],
id: 20,
model: 'res.partner',
});
await this.createComposerComponent(thread.composer, { hasFollowers: true });
assert.strictEqual(
document.querySelector('.o_Composer_followers').textContent.replace(/\s+/g, ''),
"To:Followersofthisdocument",
"Composer should display \"To: Followers of this document\" if the thread as no name."
);
});
});
});
});