Files
odoo_source/addons/mail/static/tests/web/follow_button_tests.js
T
7710c3331e [REF] mail, *: refactor Discuss
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>
2023-03-17 11:47:09 +01:00

80 lines
2.6 KiB
JavaScript

/** @odoo-module **/
import { afterNextRender, click, start, startServer } from "@mail/../tests/helpers/test_utils";
QUnit.module("follow button");
QUnit.test("base rendering not editable", async (assert) => {
const { openView, pyEnv } = await start();
await openView({
res_id: pyEnv.currentPartnerId,
res_model: "res.partner",
views: [[false, "form"]],
});
assert.containsOnce($, ".o-mail-Chatter-follow");
});
QUnit.test("hover following button", async (assert) => {
const pyEnv = await startServer();
const threadId = pyEnv["res.partner"].create({});
const followerId = pyEnv["mail.followers"].create({
is_active: true,
partner_id: pyEnv.currentPartnerId,
res_id: threadId,
res_model: "res.partner",
});
pyEnv["res.partner"].write([pyEnv.currentPartnerId], {
message_follower_ids: [followerId],
});
const { openView } = await start();
await openView({
res_id: threadId,
res_model: "res.partner",
views: [[false, "form"]],
});
assert.containsOnce($, "button:contains(Following)");
assert.containsNone($, ".fa-times + span:contains(Following)");
assert.containsOnce($, ".fa-check + span:contains(Following)");
await afterNextRender(() => {
$("button:contains(Following)")[0].dispatchEvent(new window.MouseEvent("mouseenter"));
});
assert.containsOnce($, "button:contains(Unfollow)");
assert.containsOnce($, ".fa-times + span:contains(Unfollow)");
assert.containsNone($, ".fa-check + span:contains(Unfollow)");
});
QUnit.test('click on "follow" button', async (assert) => {
const { openView, pyEnv } = await start();
await openView({
res_id: pyEnv.currentPartnerId,
res_model: "res.partner",
views: [[false, "form"]],
});
assert.containsOnce($, "button:contains(Follow)");
await click("button:contains(Follow)");
assert.containsOnce($, "button:contains(Following)");
});
QUnit.test('click on "unfollow" button', async (assert) => {
const pyEnv = await startServer();
const threadId = pyEnv["res.partner"].create({});
pyEnv["mail.followers"].create({
is_active: true,
partner_id: pyEnv.currentPartnerId,
res_id: threadId,
res_model: "res.partner",
});
const { openView } = await start();
await openView({
res_id: threadId,
res_model: "res.partner",
views: [[false, "form"]],
});
assert.containsOnce($, "button:contains(Following)");
await click("button:contains(Following)");
assert.containsOnce($, "button:contains(Follow)");
});