[FIX] mail: prevent crash when switching mailbox in discuss mobile
task-2327203 closes odoo/odoo#56939 X-original-commit: 612a8f7edf3d01ec2b854839ee60be418cb141a7 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
+5
-1
@@ -73,7 +73,11 @@ class DiscussMobileMailboxSelection extends Component {
|
||||
* @param {MouseEvent} ev
|
||||
*/
|
||||
_onClick(ev) {
|
||||
const { mailbox } = ev.currentTarget.dataset;
|
||||
const { mailboxLocalId } = ev.currentTarget.dataset;
|
||||
const mailbox = this.env.models['mail.thread'].get(mailboxLocalId);
|
||||
if (!mailbox) {
|
||||
return;
|
||||
}
|
||||
mailbox.open();
|
||||
}
|
||||
|
||||
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
odoo.define('mail/static/src/components/discuss_mobile_mailbox_selection/discuss_mobile_mailbox_selection_tests.js', function (require) {
|
||||
'use strict';
|
||||
|
||||
const {
|
||||
afterEach,
|
||||
afterNextRender,
|
||||
beforeEach,
|
||||
start,
|
||||
} = require('mail/static/src/utils/test_utils.js');
|
||||
|
||||
QUnit.module('mail', {}, function () {
|
||||
QUnit.module('components', {}, function () {
|
||||
QUnit.module('discuss_mobile_mailbox_selection', {}, function () {
|
||||
QUnit.module('discuss_mobile_mailbox_selection_tests.js', {
|
||||
beforeEach() {
|
||||
beforeEach(this);
|
||||
|
||||
this.start = async params => {
|
||||
const { env, widget } = await start(Object.assign(
|
||||
{
|
||||
autoOpenDiscuss: true,
|
||||
data: this.data,
|
||||
env: {
|
||||
browser: {
|
||||
innerHeight: 640,
|
||||
innerWidth: 360,
|
||||
},
|
||||
device: {
|
||||
isMobile: true,
|
||||
},
|
||||
},
|
||||
hasDiscuss: true,
|
||||
},
|
||||
params,
|
||||
));
|
||||
this.env = env;
|
||||
this.widget = widget;
|
||||
};
|
||||
},
|
||||
afterEach() {
|
||||
afterEach(this);
|
||||
},
|
||||
});
|
||||
|
||||
QUnit.test('select another mailbox', async function (assert) {
|
||||
assert.expect(7);
|
||||
|
||||
await this.start();
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_Discuss',
|
||||
"should display discuss initially"
|
||||
);
|
||||
assert.hasClass(
|
||||
document.querySelector('.o_Discuss'),
|
||||
'o-mobile',
|
||||
"discuss should be opened in mobile mode"
|
||||
);
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_Discuss_thread',
|
||||
"discuss should display a thread initially"
|
||||
);
|
||||
assert.strictEqual(
|
||||
document.querySelector('.o_Discuss_thread').dataset.threadLocalId,
|
||||
this.env.messaging.inbox.localId,
|
||||
"inbox mailbox should be opened initially"
|
||||
);
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
`.o_DiscussMobileMailboxSelection_button[
|
||||
data-mailbox-local-id="${this.env.messaging.starred.localId}"
|
||||
]`,
|
||||
"should have a button to open starred mailbox"
|
||||
);
|
||||
|
||||
await afterNextRender(() =>
|
||||
document.querySelector(`.o_DiscussMobileMailboxSelection_button[
|
||||
data-mailbox-local-id="${this.env.messaging.starred.localId}"]
|
||||
`).click()
|
||||
);
|
||||
assert.containsOnce(
|
||||
document.body,
|
||||
'.o_Discuss_thread',
|
||||
"discuss should still have a thread after clicking on starred mailbox"
|
||||
);
|
||||
assert.strictEqual(
|
||||
document.querySelector('.o_Discuss_thread').dataset.threadLocalId,
|
||||
this.env.messaging.starred.localId,
|
||||
"starred mailbox should be opened after clicking on it"
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -296,5 +296,11 @@
|
||||
<script type="text/javascript" src="/mail/static/src/widgets/notification_alert/notification_alert_tests.js"/>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<template id="qunit_mobile_suite" name="mail_qunit_mobile_suite" inherit_id="web.qunit_mobile_suite_tests">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/mail/static/src/components/discuss_mobile_mailbox_selection/discuss_mobile_mailbox_selection_tests.js"/>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user