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>
190 lines
6.5 KiB
JavaScript
190 lines
6.5 KiB
JavaScript
/** @odoo-module **/
|
|
|
|
import { click, start, startServer } from "@mail/../tests/helpers/test_utils";
|
|
|
|
import { editInput, makeDeferred, patchWithCleanup } from "@web/../tests/helpers/utils";
|
|
|
|
QUnit.module("follower");
|
|
|
|
QUnit.test("base rendering not editable", async (assert) => {
|
|
const pyEnv = await startServer();
|
|
const [threadId, partnerId] = pyEnv["res.partner"].create([{}, {}]);
|
|
pyEnv["mail.followers"].create({
|
|
is_active: true,
|
|
partner_id: partnerId,
|
|
res_id: threadId,
|
|
res_model: "res.partner",
|
|
});
|
|
const { openView } = await start({
|
|
async mockRPC(route, args, performRpc) {
|
|
if (route === "/mail/thread/data") {
|
|
// mimic user without write access
|
|
const res = await performRpc(...arguments);
|
|
res["hasWriteAccess"] = false;
|
|
return res;
|
|
}
|
|
},
|
|
});
|
|
await openView({
|
|
res_id: threadId,
|
|
res_model: "res.partner",
|
|
views: [[false, "form"]],
|
|
});
|
|
await click(".o-mail-Followers-button");
|
|
assert.containsOnce($, ".o-mail-Follower");
|
|
assert.containsOnce($, ".o-mail-Follower-details");
|
|
assert.containsOnce($, ".o-mail-Follower-avatar");
|
|
assert.containsNone($, ".o-mail-Follower-action");
|
|
});
|
|
|
|
QUnit.test("base rendering editable", async (assert) => {
|
|
const pyEnv = await startServer();
|
|
const [threadId, partnerId] = pyEnv["res.partner"].create([{}, {}]);
|
|
pyEnv["mail.followers"].create({
|
|
is_active: true,
|
|
partner_id: partnerId,
|
|
res_id: threadId,
|
|
res_model: "res.partner",
|
|
});
|
|
const { openView } = await start();
|
|
await openView({
|
|
res_id: threadId,
|
|
res_model: "res.partner",
|
|
views: [[false, "form"]],
|
|
});
|
|
await click(".o-mail-Followers-button");
|
|
assert.containsOnce($, ".o-mail-Follower");
|
|
assert.containsOnce($, ".o-mail-Follower-details");
|
|
assert.containsOnce($, ".o-mail-Follower-avatar");
|
|
assert.containsOnce($, ".o-mail-Follower");
|
|
assert.containsOnce($, "button[title='Edit subscription']");
|
|
assert.containsOnce($, "button[title='Remove this follower']");
|
|
});
|
|
|
|
QUnit.test("click on partner follower details", async (assert) => {
|
|
const pyEnv = await startServer();
|
|
const [threadId, partnerId] = pyEnv["res.partner"].create([{}, {}]);
|
|
pyEnv["mail.followers"].create({
|
|
is_active: true,
|
|
partner_id: partnerId,
|
|
res_id: threadId,
|
|
res_model: "res.partner",
|
|
});
|
|
const openFormDef = makeDeferred();
|
|
const { env, openView } = await start();
|
|
await openView({
|
|
res_id: threadId,
|
|
res_model: "res.partner",
|
|
views: [[false, "form"]],
|
|
});
|
|
patchWithCleanup(env.services.action, {
|
|
doAction(action) {
|
|
assert.step("do_action");
|
|
assert.strictEqual(action.res_id, partnerId);
|
|
assert.strictEqual(action.res_model, "res.partner");
|
|
assert.strictEqual(action.type, "ir.actions.act_window");
|
|
openFormDef.resolve();
|
|
},
|
|
});
|
|
await click(".o-mail-Followers-button");
|
|
assert.containsOnce($, ".o-mail-Follower");
|
|
assert.containsOnce($, ".o-mail-Follower-details");
|
|
|
|
$(".o-mail-Follower-details")[0].click();
|
|
await openFormDef;
|
|
assert.verifySteps(["do_action"], "redirect to partner profile");
|
|
});
|
|
|
|
QUnit.test("click on edit follower", async (assert) => {
|
|
const pyEnv = await startServer();
|
|
const [threadId, partnerId] = pyEnv["res.partner"].create([{}, {}]);
|
|
pyEnv["mail.followers"].create({
|
|
is_active: true,
|
|
partner_id: partnerId,
|
|
res_id: threadId,
|
|
res_model: "res.partner",
|
|
});
|
|
const { openView } = await start({
|
|
async mockRPC(route, args) {
|
|
if (route.includes("/mail/read_subscription_data")) {
|
|
assert.step("fetch_subtypes");
|
|
}
|
|
},
|
|
});
|
|
await openView({
|
|
res_id: threadId,
|
|
res_model: "res.partner",
|
|
views: [[false, "form"]],
|
|
});
|
|
await click(".o-mail-Followers-button");
|
|
assert.containsOnce($, ".o-mail-Follower");
|
|
assert.containsOnce($, "button[title='Edit subscription']");
|
|
|
|
await click("button[title='Edit subscription']");
|
|
assert.verifySteps(["fetch_subtypes"]);
|
|
assert.containsOnce($, ".o-mail-FollowerSubtypeDialog");
|
|
});
|
|
|
|
QUnit.test("edit follower and close subtype dialog", async (assert) => {
|
|
const pyEnv = await startServer();
|
|
const [threadId, partnerId] = pyEnv["res.partner"].create([{}, {}]);
|
|
pyEnv["mail.followers"].create({
|
|
is_active: true,
|
|
partner_id: partnerId,
|
|
res_id: threadId,
|
|
res_model: "res.partner",
|
|
});
|
|
const { openView } = await start({
|
|
async mockRPC(route, args) {
|
|
if (route.includes("/mail/read_subscription_data")) {
|
|
assert.step("fetch_subtypes");
|
|
}
|
|
},
|
|
});
|
|
await openView({
|
|
res_id: threadId,
|
|
res_model: "res.partner",
|
|
views: [[false, "form"]],
|
|
});
|
|
await click(".o-mail-Followers-button");
|
|
assert.containsOnce($, ".o-mail-Follower");
|
|
assert.containsOnce($, "button[title='Edit subscription']");
|
|
|
|
await click("button[title='Edit subscription']");
|
|
assert.verifySteps(["fetch_subtypes"]);
|
|
assert.containsOnce($, ".o-mail-FollowerSubtypeDialog");
|
|
|
|
await click(".o-mail-FollowerSubtypeDialog button:contains(Cancel)");
|
|
assert.containsNone($, ".o-mail-FollowerSubtypeDialog");
|
|
});
|
|
|
|
QUnit.test("remove a follower in a dirty form view", async (assert) => {
|
|
const pyEnv = await startServer();
|
|
const [threadId, partnerId] = pyEnv["res.partner"].create([{}, {}]);
|
|
pyEnv["mail.followers"].create({
|
|
is_active: true,
|
|
partner_id: partnerId,
|
|
res_id: threadId,
|
|
res_model: "res.partner",
|
|
});
|
|
const { openFormView } = await start({
|
|
async mockRPC(route, args) {
|
|
if (args.method === "read") {
|
|
assert.step(`read ${args.args[0][0]}`);
|
|
}
|
|
},
|
|
});
|
|
await openFormView("res.partner", threadId);
|
|
assert.strictEqual($(".o-mail-Followers-counter")[0].innerText, "1");
|
|
assert.verifySteps([`read ${threadId}`]);
|
|
|
|
await editInput(document.body, ".o_field_char[name=name] input", "some value");
|
|
await click(".o-mail-Followers-button");
|
|
assert.containsOnce($, ".o-mail-Follower");
|
|
|
|
await click("button[title='Remove this follower']");
|
|
assert.strictEqual($(".o-mail-Followers-counter")[0].innerText, "0");
|
|
assert.strictEqual($(".o_field_char[name=name] input").val(), "some value");
|
|
assert.verifySteps([`read ${threadId}`]);
|
|
});
|