Files
odoo_source/addons/mail/static/tests/thread/file_upload_tests.js
T
Sébastien Theys 9dba4e0d77 [REF] mail, *: reorganize JS files
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>
2023-06-08 21:52:44 +02:00

74 lines
2.5 KiB
JavaScript

/* @odoo-module */
import { afterNextRender, click, start, startServer } from "@mail/../tests/helpers/test_utils";
import { editInput } from "@web/../tests/helpers/utils";
import { file } from "web.test_utils";
const { createFile } = file;
QUnit.module("file upload");
QUnit.test("no conflicts between file uploads", async (assert) => {
const pyEnv = await startServer();
const partnerId = pyEnv["res.partner"].create({});
const channelId = pyEnv["discuss.channel"].create({});
pyEnv["mail.message"].create({
body: "not empty",
model: "discuss.channel",
res_id: channelId,
});
const { openView } = await start();
// Uploading file in the first thread: res.partner chatter.
await openView({
res_id: partnerId,
res_model: "res.partner",
views: [[false, "form"]],
});
await click("button:contains(Send message)");
const file1 = await createFile({
name: "text1.txt",
content: "hello, world",
contentType: "text/plain",
});
await afterNextRender(() =>
editInput(document.body, ".o-mail-Chatter .o-mail-Composer input[type=file]", file1)
);
// Uploading file in the second thread: discuss.channel in chatWindow.
await click("i[aria-label='Messages']");
await click(".o-mail-NotificationItem");
const file2 = await createFile({
name: "text2.txt",
content: "hello, world",
contentType: "text/plain",
});
await afterNextRender(() =>
editInput(document.body, ".o-mail-ChatWindow input[type=file]", file2)
);
assert.containsOnce($, ".o-mail-Chatter .o-mail-AttachmentCard");
assert.containsOnce($, ".o-mail-ChatWindow .o-mail-AttachmentCard");
});
QUnit.test("Attachment shows spinner during upload", async (assert) => {
const pyEnv = await startServer();
const channelId = pyEnv["discuss.channel"].create({ name: "channel_1" });
const { openDiscuss } = await start({
async mockRPC(route) {
if (route === "/mail/attachment/upload") {
// never fulfill the attachment upload promise.
await new Promise(() => {});
}
},
});
await openDiscuss(channelId);
const file = await createFile({
name: "text2.txt",
content: "hello, world",
contentType: "text/plain",
});
await afterNextRender(() =>
editInput(document.body, ".o-mail-Composer input[type=file]", file)
);
assert.containsOnce($, ".o-mail-AttachmentCard .fa-spinner");
});