Files
odoo_source/addons/website_livechat/static/tests/thread_patch_tests.js
T
Sébastien Theys 90cb44e1e1 [REF] mail, *: rename mail.channel to discuss.channel
* = bus, calendar, crm_livechat, hr, hr_holidays, im_livechat, mail_bot,
    mass_mailing, privacy_lookup, test_discuss_full, test_mail,
    test_mail_full, website_crm_livechat, website_livechat, base

In preparation of splitting discuss and mail modules.

Part of task-3265211

closes odoo/odoo#118354

Related: odoo/upgrade#4553
Related: odoo/enterprise#39661
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2023-04-21 02:21:53 +02:00

123 lines
4.9 KiB
JavaScript

/** @odoo-module */
import { start, startServer } from "@mail/../tests/helpers/test_utils";
QUnit.module("thread (patch)");
QUnit.test("Rendering of visitor banner", async (assert) => {
const pyEnv = await startServer();
const countryId = pyEnv["res.country"].create({ code: "BE" });
const visitorId = pyEnv["website.visitor"].create({
country_id: countryId,
display_name: "Visitor #11",
history: "Home → Contact",
is_connected: true,
lang_name: "English",
website_name: "General website",
});
const channelId = pyEnv["discuss.channel"].create({
anonymous_name: "Website Visitor 11",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: pyEnv.publicPartnerId }],
],
channel_type: "livechat",
livechat_operator_id: pyEnv.currentPartnerId,
livechat_visitor_id: visitorId,
});
const { openDiscuss } = await start();
await openDiscuss(channelId);
assert.containsOnce($, ".o-website_livechat-VisitorBanner-avatar img");
assert.containsOnce(
$,
".o-website_livechat-VisitorBanner-avatar img[data-src='/mail/static/src/img/smiley/avatar.jpg']"
);
assert.containsOnce($, ".o-website_livechat-VisitorBanner-avatar .o-mail-ImStatus");
assert.containsOnce($, ".o_country_flag[data-src='/base/static/img/country_flags/be.png']");
assert.containsOnce($, "span:contains(Visitor #11)");
assert.containsOnce($, "span:contains(English)");
assert.containsOnce($, "span>:contains(General website)");
assert.containsOnce($, "span:contains(Home → Contact)");
});
QUnit.test("Livechat with non-logged visitor should show visitor banner", async (assert) => {
const pyEnv = await startServer();
const countryId = pyEnv["res.country"].create({ code: "BE" });
const visitorId = pyEnv["website.visitor"].create({
country_id: countryId,
display_name: "Visitor #11",
history: "Home → Contact",
is_connected: true,
lang_name: "English",
website_name: "General website",
});
const channelId = pyEnv["discuss.channel"].create({
anonymous_name: "Visitor #11",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: pyEnv.publicPartnerId }],
],
channel_type: "livechat",
livechat_operator_id: pyEnv.currentPartnerId,
livechat_visitor_id: visitorId,
});
const { openDiscuss } = await start();
await openDiscuss(channelId);
assert.containsOnce($, ".o-website_livechat-VisitorBanner");
});
QUnit.test("Livechat with logged visitor should show visitor banner", async (assert) => {
const pyEnv = await startServer();
const resCountryId1 = pyEnv["res.country"].create({ code: "BE" });
const partnerId = pyEnv["res.partner"].create({ name: "Partner Visitor" });
const visitorId = pyEnv["website.visitor"].create({
country_id: resCountryId1,
display_name: "Visitor #11",
history: "Home → Contact",
is_connected: true,
lang_name: "English",
partner_id: partnerId,
website_name: "General website",
});
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
],
channel_type: "livechat",
livechat_operator_id: pyEnv.currentPartnerId,
livechat_visitor_id: visitorId,
});
const { openDiscuss } = await start();
await openDiscuss(channelId);
assert.containsOnce($, ".o-website_livechat-VisitorBanner");
assert.containsOnce($, ".o-website_livechat-VisitorBanner:contains(Partner Visitor)");
});
QUnit.test("Livechat without visitor should not show visitor banner", async (assert) => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({ name: "Harry" });
const channelId = pyEnv["discuss.channel"].create({
anonymous_name: "Visitor #11",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
],
channel_type: "livechat",
livechat_operator_id: pyEnv.currentPartnerId,
});
const { openDiscuss } = await start();
await openDiscuss(channelId);
assert.containsOnce($, ".o-mail-Thread");
assert.containsNone($, ".o-website_livechat-VisitorBanner");
});
QUnit.test("Non-livechat channel should not show visitor banner", async (assert) => {
const pyEnv = await startServer();
const channelId = pyEnv["discuss.channel"].create({ name: "General" });
const { openDiscuss } = await start();
await openDiscuss(channelId);
assert.containsOnce($, ".o-mail-Thread");
assert.containsNone($, ".o-website_livechat-VisitorBanner");
});