Files
odoo_source/addons/mail/static/tests/web/command_palette_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

48 lines
1.9 KiB
JavaScript

/* @odoo-module */
import { afterNextRender, click, start, startServer } from "@mail/../tests/helpers/test_utils";
import { commandService } from "@web/core/commands/command_service";
import { registry } from "@web/core/registry";
import { editSearchBar } from "@web/../tests/core/commands/command_service_tests";
import { nextTick, triggerHotkey } from "@web/../tests/helpers/utils";
const serviceRegistry = registry.category("services");
const commandSetupRegistry = registry.category("command_setup");
QUnit.module("command palette", {
async beforeEach() {
serviceRegistry.add("command", commandService);
registry.category("command_categories").add("default", { label: "default" });
},
});
QUnit.test("open the chatWindow of a user from the command palette", async (assert) => {
const { advanceTime } = await start({ hasTimeControl: true });
triggerHotkey("control+k");
await nextTick();
// Switch to partners
await editSearchBar("@");
await afterNextRender(() => advanceTime(commandSetupRegistry.get("@").debounceDelay));
await click(".o_command.focused");
assert.containsOnce($, ".o-mail-ChatWindow");
});
QUnit.test("open the chatWindow of a channel from the command palette", async (assert) => {
const pyEnv = await startServer();
pyEnv["discuss.channel"].create({ name: "general" });
pyEnv["discuss.channel"].create({ name: "project" });
const { advanceTime } = await start({ hasTimeControl: true });
triggerHotkey("control+k");
await nextTick();
// Switch to channels
await editSearchBar("#");
await afterNextRender(() => advanceTime(commandSetupRegistry.get("#").debounceDelay));
assert.containsOnce($, ".o_command:contains(general)");
assert.containsOnce($, ".o_command:contains(project)");
await click(".o_command.focused");
assert.containsOnce($, ".o-mail-ChatWindow");
assert.containsOnce($, ".o-mail-ChatWindow-name:contains(general)");
});