[REF] mail, *: remove unnecessary makeFakeNotificationService
* = hr, im_livechat The real service works just as well, gives more guarantee on what is actually tested, and requires less lines of code. closes odoo/odoo#132744 Related: odoo/enterprise#46108 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
/** @odoo-module **/
|
||||
/* @odoo-module */
|
||||
|
||||
import { afterNextRender, start, startServer } from "@mail/../tests/helpers/test_utils";
|
||||
|
||||
import { makeFakeNotificationService } from "@web/../tests/helpers/mock_services";
|
||||
import { afterNextRender, contains, start, startServer } from "@mail/../tests/helpers/test_utils";
|
||||
|
||||
import { dom } from "@web/../tests/legacy/helpers/test_utils";
|
||||
|
||||
@@ -155,15 +153,6 @@ QUnit.test(
|
||||
}
|
||||
},
|
||||
serverData: { views },
|
||||
services: {
|
||||
notification: makeFakeNotificationService((message) => {
|
||||
assert.step("notification");
|
||||
assert.strictEqual(
|
||||
message,
|
||||
"You can only chat with employees that have a dedicated user."
|
||||
);
|
||||
}),
|
||||
},
|
||||
});
|
||||
await openView({
|
||||
res_model: "m2x.avatar.employee",
|
||||
@@ -176,7 +165,10 @@ QUnit.test(
|
||||
);
|
||||
|
||||
await dom.click(document.querySelector(".o_m2o_avatar > img"));
|
||||
assert.verifySteps([`web_read m2x.avatar.employee ${avatarId}`, "notification"]);
|
||||
await contains(
|
||||
".o_notification.border-info:contains(You can only chat with employees that have a dedicated user.)"
|
||||
);
|
||||
assert.verifySteps([`web_read m2x.avatar.employee ${avatarId}`]);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -352,7 +344,7 @@ QUnit.test("many2many_avatar_employee widget in kanban view", async function (as
|
||||
document
|
||||
.querySelector(".o_kanban_record .o_field_many2many_avatar_employee img.o_m2m_avatar")
|
||||
.getAttribute("data-src"),
|
||||
`/web/image/hr.employee.public/${employeeId_2}/avatar_128`,
|
||||
`/web/image/hr.employee.public/${employeeId_2}/avatar_128`
|
||||
);
|
||||
assert.strictEqual(
|
||||
document
|
||||
@@ -360,11 +352,11 @@ QUnit.test("many2many_avatar_employee widget in kanban view", async function (as
|
||||
".o_kanban_record .o_field_many2many_avatar_employee img.o_m2m_avatar"
|
||||
)[1]
|
||||
.getAttribute("data-src"),
|
||||
`/web/image/hr.employee.public/${employeeId_1}/avatar_128`,
|
||||
`/web/image/hr.employee.public/${employeeId_1}/avatar_128`
|
||||
);
|
||||
|
||||
await dom.click(document.querySelectorAll('.o_kanban_record img.o_m2m_avatar')[1]);
|
||||
await dom.click(document.querySelectorAll('.o_kanban_record img.o_m2m_avatar')[0]);
|
||||
await dom.click(document.querySelectorAll(".o_kanban_record img.o_m2m_avatar")[1]);
|
||||
await dom.click(document.querySelectorAll(".o_kanban_record img.o_m2m_avatar")[0]);
|
||||
assert.verifySteps([
|
||||
`read hr.employee.public ${employeeId_1}`,
|
||||
`read hr.employee.public ${employeeId_2}`,
|
||||
@@ -398,15 +390,6 @@ QUnit.test(
|
||||
}
|
||||
},
|
||||
serverData: { views },
|
||||
services: {
|
||||
notification: makeFakeNotificationService((message) => {
|
||||
assert.step("notification");
|
||||
assert.strictEqual(
|
||||
message,
|
||||
"You can only chat with employees that have a dedicated user."
|
||||
);
|
||||
}),
|
||||
},
|
||||
});
|
||||
await openView({
|
||||
res_model: "m2x.avatar.employee",
|
||||
@@ -420,20 +403,20 @@ QUnit.test(
|
||||
.getAttribute("data-src"),
|
||||
`/web/image/hr.employee.public/${employeeId_1}/avatar_128`
|
||||
);
|
||||
|
||||
await dom.click(
|
||||
document.querySelector(".o_field_many2many_avatar_employee .o_tag .o_m2m_avatar")
|
||||
);
|
||||
await dom.click(
|
||||
document.querySelectorAll(".o_field_many2many_avatar_employee .o_tag .o_m2m_avatar")[1]
|
||||
);
|
||||
await contains(
|
||||
".o_notification.border-info:contains(You can only chat with employees that have a dedicated user.)"
|
||||
);
|
||||
assert.verifySteps([
|
||||
`web_read m2x.avatar.employee ${employeeId_1}`,
|
||||
`read hr.employee.public ${employeeId_1}`,
|
||||
"notification",
|
||||
`read hr.employee.public ${employeeId_2}`,
|
||||
]);
|
||||
|
||||
assert.containsOnce(document.body, ".o-mail-ChatWindow-name");
|
||||
}
|
||||
);
|
||||
|
||||
@@ -4,14 +4,11 @@ import { startServer } from "@bus/../tests/helpers/mock_python_environment";
|
||||
import { makeFakePresenceService } from "@bus/../tests/helpers/mock_services";
|
||||
|
||||
import { Command } from "@mail/../tests/helpers/command";
|
||||
import { start } from "@mail/../tests/helpers/test_utils";
|
||||
|
||||
import { makeFakeNotificationService } from "@web/../tests/helpers/mock_services";
|
||||
import { nextTick } from "@web/../tests/helpers/utils";
|
||||
import { contains, start } from "@mail/../tests/helpers/test_utils";
|
||||
|
||||
QUnit.module("messaging service (patch)");
|
||||
|
||||
QUnit.test("Notify message received out of focus", async (assert) => {
|
||||
QUnit.test("Notify message received out of focus", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const channelId = pyEnv["discuss.channel"].create({
|
||||
name: "Livechat 1",
|
||||
@@ -24,10 +21,6 @@ QUnit.test("Notify message received out of focus", async (assert) => {
|
||||
const [channel] = pyEnv["discuss.channel"].searchRead([["id", "=", channelId]]);
|
||||
const { env } = await start({
|
||||
services: {
|
||||
notification: makeFakeNotificationService((message, { title }) => {
|
||||
assert.step(`message - ${message}`);
|
||||
assert.step(`title - ${title}`);
|
||||
}),
|
||||
presence: makeFakePresenceService({
|
||||
isOdooFocused() {
|
||||
return false;
|
||||
@@ -41,6 +34,5 @@ QUnit.test("Notify message received out of focus", async (assert) => {
|
||||
uuid: channel.uuid,
|
||||
})
|
||||
);
|
||||
await nextTick();
|
||||
assert.verifySteps(["message - Hello", "title - New message"]);
|
||||
await contains(".o_notification.border-info:contains(New message):contains(Hello)");
|
||||
});
|
||||
|
||||
@@ -1,59 +1,43 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { Command } from "@mail/../tests/helpers/command";
|
||||
import { afterNextRender, start, startServer } from "@mail/../tests/helpers/test_utils";
|
||||
|
||||
import { makeFakeNotificationService } from "@web/../tests/helpers/mock_services";
|
||||
import { contains, start, startServer } from "@mail/../tests/helpers/test_utils";
|
||||
|
||||
QUnit.module("Open Chat test", {});
|
||||
|
||||
QUnit.test("openChat: display notification for partner without user", async (assert) => {
|
||||
QUnit.test("openChat: display notification for partner without user", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const partnerId = pyEnv["res.partner"].create({});
|
||||
const { env } = await start({
|
||||
services: {
|
||||
notification: makeFakeNotificationService((message) => {
|
||||
assert.step("notification");
|
||||
assert.strictEqual(
|
||||
message,
|
||||
"You can only chat with partners that have a dedicated user."
|
||||
);
|
||||
}),
|
||||
},
|
||||
});
|
||||
const { env } = await start();
|
||||
await env.services["mail.thread"].openChat({ partnerId });
|
||||
assert.verifySteps(["notification"]);
|
||||
await contains(
|
||||
".o_notification.border-info:contains(You can only chat with partners that have a dedicated user.)"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("openChat: display notification for wrong user", async (assert) => {
|
||||
QUnit.test("openChat: display notification for wrong user", async () => {
|
||||
const pyEnv = await startServer();
|
||||
pyEnv["res.users"].create({});
|
||||
const { env } = await start({
|
||||
services: {
|
||||
notification: makeFakeNotificationService((message) => {
|
||||
assert.step("notification");
|
||||
assert.strictEqual(message, "You can only chat with existing users.");
|
||||
}),
|
||||
},
|
||||
});
|
||||
const { env } = await start();
|
||||
// userId not in the server data
|
||||
await env.services["mail.thread"].openChat({ userId: 4242 });
|
||||
assert.verifySteps(["notification"]);
|
||||
await contains(
|
||||
".o_notification.border-warning:contains(You can only chat with existing users.)"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("openChat: open new chat for user", async (assert) => {
|
||||
QUnit.test("openChat: open new chat for user", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const partnerId = pyEnv["res.partner"].create({});
|
||||
pyEnv["res.users"].create({ partner_id: partnerId });
|
||||
const { env } = await start();
|
||||
assert.containsNone($, ".o-mail-ChatWindow");
|
||||
await afterNextRender(() => {
|
||||
env.services["mail.thread"].openChat({ partnerId });
|
||||
});
|
||||
assert.containsOnce($, ".o-mail-ChatWindow");
|
||||
await contains(".o-mail-ChatWindowContainer");
|
||||
await contains(".o-mail-ChatWindow", 0);
|
||||
env.services["mail.thread"].openChat({ partnerId });
|
||||
await contains(".o-mail-ChatWindow");
|
||||
});
|
||||
|
||||
QUnit.test("openChat: open existing chat for user", async (assert) => {
|
||||
QUnit.test("openChat: open existing chat for user [REQUIRE FOCUS]", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const partnerId = pyEnv["res.partner"].create({});
|
||||
pyEnv["res.users"].create({ partner_id: partnerId });
|
||||
@@ -69,9 +53,7 @@ QUnit.test("openChat: open existing chat for user", async (assert) => {
|
||||
channel_type: "chat",
|
||||
});
|
||||
const { env } = await start();
|
||||
assert.containsOnce($, ".o-mail-ChatWindow");
|
||||
await afterNextRender(() => {
|
||||
env.services["mail.thread"].openChat({ partnerId });
|
||||
});
|
||||
assert.containsOnce($, ".o-mail-ChatWindow");
|
||||
await contains(".o-mail-ChatWindow .o-mail-Composer-input:not(:focus)");
|
||||
env.services["mail.thread"].openChat({ partnerId });
|
||||
await contains(".o-mail-ChatWindow .o-mail-Composer-input:focus");
|
||||
});
|
||||
|
||||
@@ -2,17 +2,13 @@
|
||||
|
||||
import { makeFakePresenceService } from "@bus/../tests/helpers/mock_services";
|
||||
|
||||
import { start } from "@mail/../tests/helpers/test_utils";
|
||||
|
||||
import { makeFakeNotificationService } from "@web/../tests/helpers/mock_services";
|
||||
import { nextTick } from "@web/../tests/helpers/utils";
|
||||
import { contains, start } from "@mail/../tests/helpers/test_utils";
|
||||
|
||||
QUnit.module("out of focus");
|
||||
|
||||
QUnit.test("Spaces in notifications are not encoded", async (assert) => {
|
||||
QUnit.test("Spaces in notifications are not encoded", async () => {
|
||||
const { openDiscuss, pyEnv } = await start({
|
||||
services: {
|
||||
notification: makeFakeNotificationService((message) => assert.step(message)),
|
||||
presence: makeFakePresenceService({ isOdooFocused: () => false }),
|
||||
},
|
||||
});
|
||||
@@ -28,6 +24,5 @@ QUnit.test("Spaces in notifications are not encoded", async (assert) => {
|
||||
res_id: channelId,
|
||||
},
|
||||
});
|
||||
await nextTick();
|
||||
assert.verifySteps(["Hello world!"]);
|
||||
await contains(".o_notification.border-info:contains(Hello world!)");
|
||||
});
|
||||
|
||||
@@ -17,7 +17,6 @@ import {
|
||||
startServer,
|
||||
} from "@mail/../tests/helpers/test_utils";
|
||||
|
||||
import { makeFakeNotificationService } from "@web/../tests/helpers/mock_services";
|
||||
import { editInput, makeDeferred, nextTick, triggerHotkey } from "@web/../tests/helpers/utils";
|
||||
|
||||
QUnit.module("discuss");
|
||||
@@ -41,7 +40,7 @@ QUnit.test("sanity check", async (assert) => {
|
||||
]);
|
||||
});
|
||||
|
||||
QUnit.test("can change the thread name of #general", async (assert) => {
|
||||
QUnit.test("can change the thread name of #general [REQUIRE FOCUS]", async (assert) => {
|
||||
const pyEnv = await startServer();
|
||||
const channelId = pyEnv["discuss.channel"].create({
|
||||
name: "general",
|
||||
@@ -307,7 +306,7 @@ QUnit.test("sidebar: chat custom name", async () => {
|
||||
await contains(".o-mail-DiscussSidebarChannel span:contains(Marc)");
|
||||
});
|
||||
|
||||
QUnit.test("reply to message from inbox (message linked to document)", async (assert) => {
|
||||
QUnit.test("reply to message from inbox (message linked to document) [REQUIRE FOCUS]", async () => {
|
||||
const pyEnv = await startServer();
|
||||
const partnerId = pyEnv["res.partner"].create({ name: "Refactoring" });
|
||||
const messageId = pyEnv["mail.message"].create({
|
||||
@@ -323,23 +322,7 @@ QUnit.test("reply to message from inbox (message linked to document)", async (as
|
||||
notification_type: "inbox",
|
||||
res_partner_id: pyEnv.currentPartnerId,
|
||||
});
|
||||
const { openDiscuss, openFormView } = await start({
|
||||
async mockRPC(route, args) {
|
||||
if (route === "/mail/message/post") {
|
||||
assert.step("message_post");
|
||||
assert.strictEqual(args.thread_model, "res.partner");
|
||||
assert.strictEqual(args.thread_id, partnerId);
|
||||
assert.strictEqual(args.post_data.body, "Hello");
|
||||
assert.strictEqual(args.post_data.message_type, "comment");
|
||||
}
|
||||
},
|
||||
services: {
|
||||
notification: makeFakeNotificationService((notification) => {
|
||||
assert.ok(true);
|
||||
assert.strictEqual(notification, 'Message posted on "Refactoring"');
|
||||
}),
|
||||
},
|
||||
});
|
||||
const { openDiscuss, openFormView } = await start();
|
||||
openDiscuss();
|
||||
await contains(".o-mail-Message");
|
||||
await contains(".o-mail-Message-header:contains(on Refactoring)");
|
||||
@@ -351,9 +334,7 @@ QUnit.test("reply to message from inbox (message linked to document)", async (as
|
||||
await click(".o-mail-Composer-send:not(:disabled)");
|
||||
await contains(".o-mail-Composer", 0);
|
||||
await contains(".o-mail-Message:not(.o-selected)");
|
||||
await contains(".o-mail-Message:contains(Test)");
|
||||
await contains(".o-mail-Message");
|
||||
assert.verifySteps(["message_post"]);
|
||||
await contains('.o_notification.border-info:contains(Message posted on "Refactoring")');
|
||||
openFormView("res.partner", partnerId);
|
||||
await contains(".o-mail-Message", 2);
|
||||
await contains(".o-mail-Message:contains(Hello)");
|
||||
@@ -1315,11 +1296,7 @@ QUnit.test("Channel is added to discuss after invitation", async (assert) => {
|
||||
name: "General",
|
||||
channel_member_ids: [Command.create({ partner_id: partnerId })],
|
||||
});
|
||||
const { env, openDiscuss } = await start({
|
||||
services: {
|
||||
notification: makeFakeNotificationService((message) => assert.step(message)),
|
||||
},
|
||||
});
|
||||
const { env, openDiscuss } = await start();
|
||||
openDiscuss();
|
||||
await contains(".o-mail-DiscussSidebarCategory-channel");
|
||||
await contains(".o-mail-DiscussSidebarChannel:contains(General)", 0);
|
||||
@@ -1329,7 +1306,7 @@ QUnit.test("Channel is added to discuss after invitation", async (assert) => {
|
||||
})
|
||||
);
|
||||
await contains(".o-mail-DiscussSidebarChannel:contains(General)");
|
||||
assert.verifySteps(["You have been invited to #General"]);
|
||||
await contains(".o_notification.border-info:contains(You have been invited to #General)");
|
||||
});
|
||||
|
||||
QUnit.test("select another mailbox", async (assert) => {
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
} from "@mail/../tests/helpers/test_utils";
|
||||
|
||||
import { getOrigin } from "@web/core/utils/urls";
|
||||
import { makeFakeNotificationService } from "@web/../tests/helpers/mock_services";
|
||||
import { nextTick } from "@web/../tests/helpers/utils";
|
||||
|
||||
QUnit.module("discuss sidebar");
|
||||
@@ -995,18 +994,16 @@ QUnit.test("Can unpin chat channel", async () => {
|
||||
await contains(".o-mail-DiscussSidebarChannel:contains(Mitchell Admin)", 0);
|
||||
});
|
||||
|
||||
QUnit.test("Unpinning chat should display notification", async (assert) => {
|
||||
QUnit.test("Unpinning chat should display notification", async () => {
|
||||
const pyEnv = await startServer();
|
||||
pyEnv["discuss.channel"].create({ channel_type: "chat" });
|
||||
const { openDiscuss } = await start({
|
||||
services: {
|
||||
notification: makeFakeNotificationService((message) => assert.step(message)),
|
||||
},
|
||||
});
|
||||
const { openDiscuss } = await start();
|
||||
openDiscuss();
|
||||
await click(".o-mail-DiscussSidebarChannel [title='Unpin Conversation']");
|
||||
await contains(".o-mail-DiscussSidebarChannel", 0);
|
||||
assert.verifySteps(["You unpinned your conversation with Mitchell Admin"]);
|
||||
await contains(
|
||||
".o_notification.border-info:contains(You unpinned your conversation with Mitchell Admin)"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Can leave channel", async () => {
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
} from "@mail/../tests/helpers/test_utils";
|
||||
|
||||
import { browser } from "@web/core/browser/browser";
|
||||
import { makeFakeNotificationService } from "@web/../tests/helpers/mock_services";
|
||||
import { patchWithCleanup, triggerEvent } from "@web/../tests/helpers/utils";
|
||||
|
||||
QUnit.module("messaging menu");
|
||||
@@ -94,35 +93,27 @@ QUnit.test("rendering without OdooBot has a request (accepted)", async () => {
|
||||
await contains(".o-mail-NotificationItem", 0);
|
||||
});
|
||||
|
||||
QUnit.test("respond to notification prompt (denied)", async (assert) => {
|
||||
QUnit.test("respond to notification prompt (denied)", async () => {
|
||||
patchBrowserNotification("default", "denied");
|
||||
await start({
|
||||
services: {
|
||||
notification: makeFakeNotificationService(() => {
|
||||
assert.step("confirmation_denied_toast");
|
||||
}),
|
||||
},
|
||||
});
|
||||
await start();
|
||||
await click(".o_menu_systray i[aria-label='Messages']");
|
||||
await click(".o-mail-NotificationItem");
|
||||
assert.verifySteps(["confirmation_denied_toast"]);
|
||||
await contains(
|
||||
".o_notification.border-warning:contains(Odoo will not send notifications on this device.)"
|
||||
);
|
||||
await contains(".o-mail-MessagingMenu-counter", 0);
|
||||
await click(".o_menu_systray i[aria-label='Messages']");
|
||||
await contains(".o-mail-NotificationItem", 0);
|
||||
});
|
||||
|
||||
QUnit.test("respond to notification prompt (granted)", async (assert) => {
|
||||
QUnit.test("respond to notification prompt (granted)", async () => {
|
||||
patchBrowserNotification("default", "granted");
|
||||
await start({
|
||||
services: {
|
||||
notification: makeFakeNotificationService(() => {
|
||||
assert.step("confirmation_granted_toast");
|
||||
}),
|
||||
},
|
||||
});
|
||||
await start();
|
||||
await click(".o_menu_systray i[aria-label='Messages']");
|
||||
await click(".o-mail-NotificationItem");
|
||||
assert.verifySteps(["confirmation_granted_toast"]);
|
||||
await contains(
|
||||
".o_notification.border-success:contains(Odoo will send notifications on this device!)"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("no 'OdooBot has a request' in mobile app", async () => {
|
||||
|
||||
Reference in New Issue
Block a user