diff --git a/addons/barcodes/static/tests/barcode_tests.js b/addons/barcodes/static/tests/barcode_tests.js
index aefc90bb5ba..8ba4b92c3a7 100644
--- a/addons/barcodes/static/tests/barcode_tests.js
+++ b/addons/barcodes/static/tests/barcode_tests.js
@@ -8,7 +8,6 @@ var fieldRegistry = require('web.field_registry');
var FormController = require('web.FormController');
var FormView = require('web.FormView');
var testUtils = require('web.test_utils');
-var NotificationService = require('web.NotificationService');
var createView = testUtils.createView;
var triggerKeypressEvent = testUtils.dom.triggerKeypressEvent;
@@ -66,11 +65,11 @@ QUnit.test('Button with barcode_trigger', async function (assert) {
'',
res_id: 2,
services: {
- notification: NotificationService.extend({
+ notification: {
notify: function (params) {
assert.step(params.type);
}
- }),
+ },
},
intercepts: {
execute_action: function (event) {
@@ -536,11 +535,11 @@ QUnit.test('barcode_scanned only trigger error for active view', async function
},
res_id: 1,
services: {
- notification: NotificationService.extend({
+ notification: {
notify: function (params) {
assert.step(params.type);
}
- }),
+ },
},
viewOptions: {
mode: 'edit',
diff --git a/addons/hr/static/tests/m2x_avatar_employee_tests.js b/addons/hr/static/tests/m2x_avatar_employee_tests.js
index f1787312b87..8e943ed5f08 100644
--- a/addons/hr/static/tests/m2x_avatar_employee_tests.js
+++ b/addons/hr/static/tests/m2x_avatar_employee_tests.js
@@ -182,6 +182,21 @@ QUnit.module('hr', {}, function () {
return this._super(...arguments);
},
res_id: 1,
+ services: {
+ notification: {
+ notify(notification) {
+ assert.ok(
+ true,
+ "should display a toast notification after failing to open chat"
+ );
+ assert.strictEqual(
+ notification.message,
+ "You can only chat with employees that have a dedicated user.",
+ "should display the correct information in the notification"
+ );
+ },
+ },
+ },
});
mock.intercept(form, 'call_service', (ev) => {
@@ -199,17 +214,6 @@ QUnit.module('hr', {}, function () {
'read hr.employee.public 11',
]);
- assert.containsOnce(
- document.body,
- '.toast .o_notification_content',
- "should display a toast notification after failing to open chat"
- );
- assert.strictEqual(
- document.querySelector('.o_notification_content').textContent,
- "You can only chat with employees that have a dedicated user.",
- "should display the correct information in the notification"
- );
-
form.destroy();
});
@@ -339,6 +343,21 @@ QUnit.module('hr', {}, function () {
return this._super(...arguments);
},
res_id: 1,
+ services: {
+ notification: {
+ notify(notification) {
+ assert.ok(
+ true,
+ "should display a toast notification after failing to open chat"
+ );
+ assert.strictEqual(
+ notification.message,
+ "You can only chat with employees that have a dedicated user.",
+ "should display the correct information in the notification"
+ );
+ },
+ },
+ },
});
mock.intercept(form, 'call_service', (ev) => {
@@ -363,16 +382,6 @@ QUnit.module('hr', {}, function () {
"read hr.employee.public 23"
]);
- assert.containsOnce(
- document.body,
- '.toast .o_notification_content',
- "should display a toast notification after failing to open chat"
- );
- assert.strictEqual(
- document.querySelector('.o_notification_content').textContent,
- "You can only chat with employees that have a dedicated user.",
- "should display the correct information in the notification"
- );
assert.containsOnce(document.body, '.o_ChatWindowHeader_name',
"should have 1 chat window");
diff --git a/addons/mail/static/src/components/discuss/tests/discuss_tests.js b/addons/mail/static/src/components/discuss/tests/discuss_tests.js
index 6858974b896..0d3d8af6094 100644
--- a/addons/mail/static/src/components/discuss/tests/discuss_tests.js
+++ b/addons/mail/static/src/components/discuss/tests/discuss_tests.js
@@ -3235,6 +3235,21 @@ QUnit.test('reply to message from inbox (message linked to document)', async fun
}
return this._super(...arguments);
},
+ services: {
+ notification: {
+ notify(notification) {
+ assert.ok(
+ true,
+ "should display a notification after posting reply"
+ );
+ assert.strictEqual(
+ notification.message,
+ "Message posted on \"Refactoring\"",
+ "notification should tell that message has been posted to the record 'Refactoring'"
+ );
+ }
+ }
+ },
});
assert.strictEqual(
document.querySelectorAll('.o_Message').length,
@@ -3299,15 +3314,6 @@ QUnit.test('reply to message from inbox (message linked to document)', async fun
document.querySelector('.o_Message').classList.contains('o-selected'),
"message should not longer be selected after posting reply"
);
- assert.ok(
- document.querySelector('.o_notification'),
- "should display a notification after posting reply"
- );
- assert.strictEqual(
- document.querySelector('.o_notification_content').textContent,
- "Message posted on \"Refactoring\"",
- "notification should tell that message has been posted to the record 'Refactoring'"
- );
});
QUnit.test('load recent messages from thread (already loaded some old messages)', async function (assert) {
diff --git a/addons/mail/static/src/components/messaging_menu/messaging_menu_tests.js b/addons/mail/static/src/components/messaging_menu/messaging_menu_tests.js
index 7db5fab7285..be66f735685 100644
--- a/addons/mail/static/src/components/messaging_menu/messaging_menu_tests.js
+++ b/addons/mail/static/src/components/messaging_menu/messaging_menu_tests.js
@@ -988,7 +988,7 @@ QUnit.test('rendering without OdooBot has a request (accepted)', async function
});
QUnit.test('respond to notification prompt (denied)', async function (assert) {
- assert.expect(3);
+ assert.expect(4);
await this.start({
env: {
@@ -1001,6 +1001,15 @@ QUnit.test('respond to notification prompt (denied)', async function (assert) {
},
},
},
+ services: {
+ notification: {
+ notify() {
+ assert.step(
+ "should display a toast notification with the deny confirmation"
+ );
+ }
+ }
+ }
},
});
@@ -1010,11 +1019,10 @@ QUnit.test('respond to notification prompt (denied)', async function (assert) {
await afterNextRender(() =>
document.querySelector('.o_NotificationRequest').click()
);
- assert.containsOnce(
- document.body,
- '.toast .o_notification_content',
- "should display a toast notification with the deny confirmation"
- );
+ assert.verifySteps([
+ "should display a toast notification with the deny confirmation",
+ ]);
+
assert.containsNone(
document.body,
'.o_MessagingMenu_counter',
diff --git a/addons/mail/static/src/models/messaging/messaging_tests.js b/addons/mail/static/src/models/messaging/messaging_tests.js
index 92b3e32fd63..5d3dccf5846 100644
--- a/addons/mail/static/src/models/messaging/messaging_tests.js
+++ b/addons/mail/static/src/models/messaging/messaging_tests.js
@@ -26,38 +26,50 @@ QUnit.test('openChat: display notification for partner without user', async func
assert.expect(2);
this.data['res.partner'].records.push({ id: 14 });
- await this.start();
+ await this.start({
+ services: {
+ notification: {
+ notify(notification) {
+ assert.ok(
+ true,
+ "should display a toast notification after failing to open chat"
+ );
+ assert.strictEqual(
+ notification.message,
+ "You can only chat with partners that have a dedicated user.",
+ "should display the correct information in the notification"
+ );
+ },
+ },
+ },
+ });
await this.env.messaging.openChat({ partnerId: 14 });
- assert.containsOnce(
- document.body,
- '.toast .o_notification_content',
- "should display a toast notification after failing to open chat"
- );
- assert.strictEqual(
- document.querySelector('.o_notification_content').textContent,
- "You can only chat with partners that have a dedicated user.",
- "should display the correct information in the notification"
- );
});
QUnit.test('openChat: display notification for wrong user', async function (assert) {
assert.expect(2);
- await this.start();
+ await this.start({
+ services: {
+ notification: {
+ notify(notification) {
+ assert.ok(
+ true,
+ "should display a toast notification after failing to open chat"
+ );
+ assert.strictEqual(
+ notification.message,
+ "You can only chat with existing users.",
+ "should display the correct information in the notification"
+ );
+ },
+ },
+ },
+ });
// user id not in this.data
await this.env.messaging.openChat({ userId: 14 });
- assert.containsOnce(
- document.body,
- '.toast .o_notification_content',
- "should display a toast notification after failing to open chat"
- );
- assert.strictEqual(
- document.querySelector('.o_notification_content').textContent,
- "You can only chat with existing users.",
- "should display the correct information in the notification"
- );
});
QUnit.test('openChat: open new chat for user', async function (assert) {
diff --git a/addons/mail/static/src/utils/test_utils.js b/addons/mail/static/src/utils/test_utils.js
index cc288f2f49f..a5c1d6b1770 100644
--- a/addons/mail/static/src/utils/test_utils.js
+++ b/addons/mail/static/src/utils/test_utils.js
@@ -15,7 +15,6 @@ import MessagingMenuWidget from '@mail/widgets/messaging_menu/messaging_menu';
import { MockModels } from '@mail/../tests/helpers/mock_models';
import AbstractStorageService from 'web.AbstractStorageService';
-import NotificationService from 'web.NotificationService';
import RamStorage from 'web.RamStorage';
import {
createView,
@@ -523,7 +522,6 @@ async function start(param0 = {}) {
_listenHomeMenu: () => {},
}),
local_storage: AbstractStorageService.extend({ storage: new RamStorage() }),
- notification: NotificationService.extend(),
}, param0.services);
const kwargs = Object.assign({}, param0, {
diff --git a/addons/partner_autocomplete/static/tests/partner_autocomplete_tests.js b/addons/partner_autocomplete/static/tests/partner_autocomplete_tests.js
index af7ee95e274..00a4e8aa03e 100644
--- a/addons/partner_autocomplete/static/tests/partner_autocomplete_tests.js
+++ b/addons/partner_autocomplete/static/tests/partner_autocomplete_tests.js
@@ -6,7 +6,6 @@ odoo.define('partner_autocomplete.tests', function (require) {
var testUtils = require("web.test_utils");
var AutocompleteField = require('partner.autocomplete.fieldchar');
var PartnerField = require('partner.autocomplete.many2one');
- var NotificationService = require('web.NotificationService');
var createView = testUtils.createView;
@@ -377,7 +376,7 @@ odoo.define('partner_autocomplete.tests', function (require) {
});
QUnit.test("Partner autocomplete : Notify not enough credits", async function (assert) {
- assert.expect(1);
+ assert.expect(2);
enrichData = {
error: true,
@@ -394,7 +393,12 @@ odoo.define('partner_autocomplete.tests', function (require) {
'