Remove "fake" feature sub-folders that make files harder to find.
Note: If there are too many files in the main folder now, a new split
that actually makes sense can be done at a later time: this would not
just be code move, but removing coupling between said feature and the
rest of the code.
Apply consistent structure, where the top level folder is a feature (or
core), and sub-folders are subdivision of the feature depending on
context (closely related to assets bundles).
```
- core
- common
- public
- web
- feature
- common
- public
- web
```
The opportunity is taken to reorganize the top of the files and imports:
- Always use absolute path in imports to be able to find all usages of a
file with a single search.
- Reorganize imports to group them by module, and to sort them
alphabetically by path/feature.
- Always use single asterisk (*) for `odoo-module`: less characters yay!
And double asterisk should be used for JSDoc comments, not for custom
instructions.
Part of task-3265211
closes odoo/odoo#124168
Related: odoo/enterprise#42121
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
93 lines
3.1 KiB
JavaScript
93 lines
3.1 KiB
JavaScript
/* @odoo-module */
|
|
|
|
import { click, start, startServer } from "@mail/../tests/helpers/test_utils";
|
|
|
|
import { nextTick, patchWithCleanup } from "@web/../tests/helpers/utils";
|
|
|
|
QUnit.module("message reply");
|
|
|
|
QUnit.test("click on message in reply to highlight the parent message", async (assert) => {
|
|
const pyEnv = await startServer();
|
|
const channelId = pyEnv["discuss.channel"].create({ name: "general" });
|
|
const messageId = pyEnv["mail.message"].create({
|
|
body: "Hey lol",
|
|
message_type: "comment",
|
|
model: "discuss.channel",
|
|
res_id: channelId,
|
|
});
|
|
pyEnv["mail.message"].create({
|
|
body: "Reply to Hey",
|
|
message_type: "comment",
|
|
model: "discuss.channel",
|
|
parent_id: messageId,
|
|
res_id: channelId,
|
|
});
|
|
const { openDiscuss } = await start();
|
|
await openDiscuss(channelId);
|
|
await click(".o-mail-Message:contains(Reply to Hey) .o-mail-MessageInReply-message");
|
|
assert.containsOnce($, ".o-mail-Message:contains(Hey lol).o-highlighted");
|
|
});
|
|
|
|
QUnit.test("click on message in reply to scroll to the parent message", async (assert) => {
|
|
// make scroll behavior instantaneous.
|
|
patchWithCleanup(Element.prototype, {
|
|
scrollIntoView() {
|
|
return this._super(true);
|
|
},
|
|
});
|
|
const pyEnv = await startServer();
|
|
const channelId = pyEnv["discuss.channel"].create({ name: "general" });
|
|
const [oldestMessageId] = pyEnv["mail.message"].create(
|
|
Array(20)
|
|
.fill(0)
|
|
.map(() => ({
|
|
body: "Non Empty Body ".repeat(25),
|
|
message_type: "comment",
|
|
model: "discuss.channel",
|
|
res_id: channelId,
|
|
}))
|
|
);
|
|
pyEnv["mail.message"].create({
|
|
body: "Response to first message",
|
|
message_type: "comment",
|
|
model: "discuss.channel",
|
|
parent_id: oldestMessageId,
|
|
res_id: channelId,
|
|
});
|
|
const { openDiscuss } = await start();
|
|
await openDiscuss(channelId);
|
|
await click(
|
|
".o-mail-Message:contains(Response to first message) .o-mail-MessageInReply-message"
|
|
);
|
|
await nextTick();
|
|
assert.isVisible($(".o-mail-Message:eq(0)"));
|
|
});
|
|
|
|
QUnit.test("reply shows correct author avatar", async (assert) => {
|
|
const pyEnv = await startServer();
|
|
const channelId = pyEnv["discuss.channel"].create({ name: "general" });
|
|
const messageId = pyEnv["mail.message"].create({
|
|
body: "Hey there",
|
|
message_type: "comment",
|
|
model: "discuss.channel",
|
|
res_id: channelId,
|
|
});
|
|
const partnerId = pyEnv["res.partner"].create({ name: "John Doe" });
|
|
pyEnv["mail.message"].create({
|
|
body: "Howdy",
|
|
message_type: "comment",
|
|
model: "discuss.channel",
|
|
author_id: partnerId,
|
|
parent_id: messageId,
|
|
res_id: channelId,
|
|
});
|
|
const { openDiscuss } = await start();
|
|
await openDiscuss(channelId);
|
|
const replyAvatar = document.querySelector(".o-mail-MessageInReply-avatar");
|
|
assert.ok(
|
|
replyAvatar.dataset["src"].includes(
|
|
`/discuss/channel/${channelId}/partner/${pyEnv.currentPartnerId}/avatar_128`
|
|
)
|
|
);
|
|
});
|