diff --git a/addons/mail/static/src/models/notification_request_view.js b/addons/mail/static/src/models/notification_request_view.js index d8ed5b71120..aa694e2383f 100644 --- a/addons/mail/static/src/models/notification_request_view.js +++ b/addons/mail/static/src/models/notification_request_view.js @@ -2,6 +2,7 @@ import { registerModel } from '@mail/model/model_core'; import { attr, one } from '@mail/model/model_field'; +import { clear } from '@mail/model/model_field_command'; import { sprintf } from '@web/core/utils/strings'; @@ -11,9 +12,12 @@ registerModel({ recordMethods: { /** * @private - * @returns {string} + * @returns {string|FieldCommand} */ _computeHeaderText() { + if (!this.messaging.partnerRoot) { + return clear(); + } return sprintf( this.env._t("%(odoobotName)s has a request"), { odoobotName: this.messaging.partnerRoot.nameOrDisplayName }, diff --git a/addons/mail/static/tests/qunit_suite_tests/components/messaging_menu_tests.js b/addons/mail/static/tests/qunit_suite_tests/components/messaging_menu_tests.js index f58edc302b0..788a72075f2 100644 --- a/addons/mail/static/tests/qunit_suite_tests/components/messaging_menu_tests.js +++ b/addons/mail/static/tests/qunit_suite_tests/components/messaging_menu_tests.js @@ -109,6 +109,12 @@ QUnit.test('messaging becomes initialized', async function (assert) { QUnit.test('basic rendering', async function (assert) { assert.expect(21); + patchWithCleanup(browser, { + Notification: { + ...browser.Notification, + permission: 'denied', + }, + }); const { click, createMessagingMenuComponent } = await start(); await createMessagingMenuComponent(); assert.strictEqual( @@ -234,6 +240,12 @@ QUnit.test('basic rendering', async function (assert) { QUnit.test('counter is taking into account failure notification', async function (assert) { assert.expect(2); + patchWithCleanup(browser, { + Notification: { + ...browser.Notification, + permission: 'denied', + }, + }); const pyEnv = await startServer(); const mailChannelId1 = pyEnv['mail.channel'].create(); const mailMessageId1 = pyEnv['mail.message'].create({ diff --git a/addons/mail/static/tests/qunit_suite_tests/models/messaging_menu_tests.js b/addons/mail/static/tests/qunit_suite_tests/models/messaging_menu_tests.js index 195162f0b86..c0c7c553352 100644 --- a/addons/mail/static/tests/qunit_suite_tests/models/messaging_menu_tests.js +++ b/addons/mail/static/tests/qunit_suite_tests/models/messaging_menu_tests.js @@ -2,6 +2,9 @@ import { start } from '@mail/../tests/helpers/test_utils'; +import { browser } from '@web/core/browser/browser'; +import { patchWithCleanup } from '@web/../tests/helpers/utils'; + QUnit.module('mail', {}, function () { QUnit.module('models', {}, function () { QUnit.module('messaging_menu_tests.js'); @@ -9,6 +12,12 @@ QUnit.module('messaging_menu_tests.js'); QUnit.test('messaging menu counter should ignore unread messages in channels that are unpinned', async function (assert) { assert.expect(1); + patchWithCleanup(browser, { + Notification: { + ...browser.Notification, + permission: 'denied', + }, + }); const { messaging } = await start(); messaging.models['Thread'].create({ id: 31, diff --git a/addons/mail/static/tests/qunit_suite_tests/widgets/notification_alert_tests.js b/addons/mail/static/tests/qunit_suite_tests/widgets/notification_alert_tests.js index 7eca2f869ad..d6109aa3a0a 100644 --- a/addons/mail/static/tests/qunit_suite_tests/widgets/notification_alert_tests.js +++ b/addons/mail/static/tests/qunit_suite_tests/widgets/notification_alert_tests.js @@ -18,7 +18,10 @@ QUnit.skip('notification_alert widget: display blocked notification alert', asyn assert.expect(1); patchWithCleanup(browser, { - Notification: 'denied', + Notification: { + ...browser.Notification, + permission: 'denied', + }, }); await start({ arch: `