This commit refactors discuss code to use OWL components and new tools and services in web/. Functionally, Discuss app should work relatively the same as before this commit. closes https://github.com/odoo/odoo/pull/110188 Related: https://github.com/odoo/enterprise/pull/38058 https://github.com/odoo/upgrade/pull/4423 closes odoo/odoo#110188 Related: odoo/upgrade#4423 Related: odoo/enterprise#38058 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Co-authored-by: Alexandre (aku) <aku@odoo.com> Co-authored-by: Didier (did) <did@odoo.com> Co-authored-by: Géry (ged) <ged@odoo.com> Co-authored-by: Louis (wil) <wil@odoo.com> Co-authored-by: Maël (mapa) <mapa@odoo.com> Co-authored-by: Maryam (maki) <maki@odoo.com> Co-authored-by: Sébastien (seb) <seb@odoo.com> Co-authored-by: Thanh (tso) <tso@odoo.com> Co-authored-by: Matthieu (tsm) <tsm@odoo.com> Co-authored-by: Zelong (zel) <zel@odoo.com>
123 lines
4.9 KiB
JavaScript
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["mail.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["mail.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["mail.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["mail.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["mail.channel"].create({ name: "General" });
|
|
const { openDiscuss } = await start();
|
|
await openDiscuss(channelId);
|
|
assert.containsOnce($, ".o-mail-Thread");
|
|
assert.containsNone($, ".o-website_livechat-VisitorBanner");
|
|
});
|