[FIX] *: adapt QUnit tests and tours

[FIX] *: selectors in tours

[FIX][TMP] account: CogMenu selector in tours

[FIX][TMP] web*: Breadcrumb targetting in tours

Adds a `o_breadcrumb` class to target the whole breadcrumb, no matter
how much elements it contains (collapsed parts, visible path, single
name...).

add classname on last breadcrumb item

[FIX][TMP] project: View buttons selector in tours (moved away from CP)

[FIX][TMP] project: Kanban selectors in tours (quick create)

[FIX][TMP] *: SearchBar selectors in tours (toggle menu)

[FIX][TMP] *: ButtonBox selector in tours

[WIP][IMP] web: add toggleSearchBarMenu in search helpers

adapt and unskip 3 list tests

adapt and unskip calendar tests

unskip web_tour test that actually pass

post rebase fix

allow to lose cell focus after multi edition (given to searchbar) - bug reported, to check later

post rebase fixes

fix

Part-of: odoo/odoo#116641
This commit is contained in:
Pierre Paridans
2023-05-12 22:59:22 +02:00
parent 3aaa0bfff1
commit eef262abf4
112 changed files with 3673 additions and 2329 deletions
@@ -341,10 +341,11 @@ QUnit.module("Base Import Tests", (hooks) => {
"button has the right download url"
);
assert.verifySteps(["partner/get_import_templates", "base_import.import/create"]);
// Contains invisible mobile buttons
assert.containsN(
target,
".o_control_panel button",
2,
5,
"only two buttons are visible by default"
);
});
@@ -380,7 +381,7 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.xlsx", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(target, ".o_control_panel_main_buttons .d-none input[type='file']", file);
assert.verifySteps([
"partner/get_import_templates",
"base_import.import/create",
@@ -515,8 +516,10 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.xls", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await click(target.querySelector(".o_control_panel button:first-child"));
await editInput(target, ".o_control_panel_main_buttons .d-none input[type='file']", file);
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:first-child")
);
assert.verifySteps(["execute_import"]);
});
@@ -533,7 +536,7 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.csv", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(target, ".o_control_panel_main_buttons .d-none input[type='file']", file);
assert.containsOnce(
target,
".o_import_data_sidepanel .o_import_formatting",
@@ -563,7 +566,7 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.csv", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(target, ".o_control_panel_main_buttons .d-none input[type='file']", file);
await nextTick();
assert.containsOnce(
@@ -604,7 +607,11 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.xls", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(
target,
".o_control_panel_main_buttons .d-none input[type='file']",
file
);
assert.strictEqual(
target.querySelector(".o_import_data_sidepanel input[type=checkbox]").checked,
true,
@@ -637,7 +644,9 @@ QUnit.module("Base Import Tests", (hooks) => {
"as the column couldn't match with the database, user must make a choice"
);
await click(target.querySelector(".o_control_panel button:first-child"));
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:first-child")
);
assert.containsNone(
target,
".o_notification_body",
@@ -660,7 +669,9 @@ QUnit.module("Base Import Tests", (hooks) => {
);
await editSelectMenu(target, ".o_import_data_content .o_select_menu", "Display name");
await click(target.querySelector(".o_control_panel button:first-child"));
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:first-child")
);
assert.verifySteps([
"base_import.import/execute_import",
"1 records successfully imported",
@@ -700,10 +711,12 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.xlsx", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(target, ".o_control_panel_main_buttons .d-none input[type='file']", file);
// For this test, we force the display of an error message if this field is set
await editSelectMenu(target, ".o_import_data_content .o_select_menu", "Selection");
await click(target.querySelector(".o_control_panel button:nth-child(2)"));
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:nth-child(2)")
);
assert.strictEqual(
target.querySelector(".o_import_data_content .alert-danger").textContent,
"The file contains blocking errors (see below)",
@@ -730,7 +743,9 @@ QUnit.module("Base Import Tests", (hooks) => {
"prevent option is selected by default"
);
editSelect(target, ".o_import_field_selection select", "item_2");
await click(target.querySelector(".o_control_panel button:nth-child(2)"));
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:nth-child(2)")
);
assert.strictEqual(
target.querySelector(".o_import_data_content .alert-info").textContent,
"Everything seems valid.",
@@ -774,10 +789,12 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.xlsx", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(target, ".o_control_panel_main_buttons .d-none input[type='file']", file);
// For this test, we force the display of an error message if this field is set
await editSelectMenu(target, ".o_import_data_content .o_select_menu", "Bar");
await click(target.querySelector(".o_control_panel button:nth-child(2)"));
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:nth-child(2)")
);
assert.strictEqual(
target.querySelector(".o_import_data_content .alert-danger").textContent,
"The file contains blocking errors (see below)",
@@ -789,7 +806,9 @@ QUnit.module("Base Import Tests", (hooks) => {
"options are 'prevent', choose a default boolean value or 'skip'"
);
editSelect(target, ".o_import_field_boolean select", "false");
await click(target.querySelector(".o_control_panel button:nth-child(2)"));
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:nth-child(2)")
);
assert.strictEqual(
target.querySelector(".o_import_data_content .alert-info").textContent,
"Everything seems valid.",
@@ -837,10 +856,12 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.xlsx", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(target, ".o_control_panel_main_buttons .d-none input[type='file']", file);
// For this test, we force the display of an error message if this field is set
await editSelectMenu(target, ".o_import_data_content .o_select_menu", "Many2Many");
await click(target.querySelector(".o_control_panel button:nth-child(2)"));
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:nth-child(2)")
);
assert.strictEqual(
target.querySelector(".o_import_data_content .alert-danger").textContent,
"The file contains blocking errors (see below)",
@@ -852,14 +873,18 @@ QUnit.module("Base Import Tests", (hooks) => {
"options are 'prevent', choose a default boolean value or 'skip'"
);
editSelect(target, ".o_import_field_many2many select", "name_create_enabled_fields");
await click(target.querySelector(".o_control_panel button:nth-child(2)"));
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:nth-child(2)")
);
assert.strictEqual(
target.querySelector(".o_import_data_content .alert-info").textContent,
"Everything seems valid.",
"import is now successful"
);
editSelect(target, ".o_import_field_many2many select", "import_skip_records");
await click(target.querySelector(".o_control_panel button:nth-child(2)"));
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:nth-child(2)")
);
assert.strictEqual(
target.querySelector(".o_import_data_content .alert-info").textContent,
"Everything seems valid.",
@@ -914,8 +939,10 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.xlsx", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await click(target.querySelector(".o_control_panel button:nth-child(1)"));
await editInput(target, ".o_control_panel_main_buttons .d-none input[type='file']", file);
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:nth-child(1)")
);
assert.strictEqual(
target.querySelector(".o_import_data_content .alert-danger").textContent,
"The file contains blocking errors (see below)",
@@ -991,7 +1018,7 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.xls", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(target, ".o_control_panel_main_buttons .d-none input[type='file']", file);
assert.strictEqual(
target.querySelector("input#o_import_batch_limit").value,
"2000",
@@ -1004,7 +1031,9 @@ QUnit.module("Base Import Tests", (hooks) => {
);
await editInput(target, "input#o_import_batch_limit", 1);
await click(target.querySelector(".o_control_panel button:nth-child(2)"));
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:nth-child(2)")
);
assert.strictEqual(
target.querySelector(".o_import_data_content .alert-info").textContent,
"Everything seems valid.",
@@ -1068,9 +1097,11 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.xls", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(target, ".o_control_panel_main_buttons .d-none input[type='file']", file);
await editInput(target, "input#o_import_batch_limit", 1);
await click(target.querySelector(".o_control_panel button:first-child"));
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:first-child")
);
// Since a nextTick is added to each batch, we must wait twice before the end of the second batch
await nextTick();
await nextTick();
@@ -1086,7 +1117,8 @@ QUnit.module("Base Import Tests", (hooks) => {
"a message is shown to indicate the user to resume from the third row"
);
assert.strictEqual(
target.querySelector(".o_control_panel button:first-child").textContent,
target.querySelector(".o_control_panel_main_buttons .d-none button:first-child")
.textContent,
"Resume",
"button contains the right text"
);
@@ -1157,9 +1189,11 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.xls", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(target, ".o_control_panel_main_buttons .d-none input[type='file']", file);
await editInput(target, "input#o_import_batch_limit", 1);
await click(target.querySelector(".o_control_panel button:nth-child(2)"));
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:nth-child(2)")
);
// Since a nextTick is added to each batch, we must wait twice before the end of the second batch
await nextTick();
await nextTick();
@@ -1169,7 +1203,8 @@ QUnit.module("Base Import Tests", (hooks) => {
"Everything seems valid."
);
assert.strictEqual(
target.querySelector(".o_control_panel button:first-child").textContent,
target.querySelector(".o_control_panel_main_buttons .d-none button:first-child")
.textContent,
"Import",
"after testing, 'Resume' text is not shown"
);
@@ -1245,7 +1280,11 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.xls", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(
target,
".o_control_panel_main_buttons .d-none input[type='file']",
file
);
assert.strictEqual(
target.querySelector(
@@ -1261,7 +1300,9 @@ QUnit.module("Base Import Tests", (hooks) => {
"The relational field should be selected by default and the name should be the full path."
);
await click(target.querySelector(".o_control_panel button:first-child"));
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:first-child")
);
}
);
@@ -1320,10 +1361,12 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.xlsx", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(target, ".o_control_panel_main_buttons .d-none input[type='file']", file);
// For this test, we force the display of an error message if this field is set
await editSelectMenu(target, ".o_import_data_content .o_select_menu", "Many2Many");
await click(target.querySelector(".o_control_panel button:nth-child(2)"));
await click(
target.querySelector(".o_control_panel_main_buttons .d-none button:nth-child(2)")
);
assert.strictEqual(
target.querySelector(".o_import_data_content .alert-danger").textContent,
@@ -1387,13 +1430,17 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.csv", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(target, ".o_control_panel_main_buttons .d-none input[type='file']", file);
await editInput(target, ".o_import_date_format#date_format-3", "YYYYMMDD");
// Parse the file again with the updated date format to check that
// the format is correctly formatted in the UI
await click(target.querySelector(".o_import_formatting button"));
await click(target.querySelector(".o_control_panel button:nth-child(2)"));
await click(
$(target).find(
".o_control_panel_main_buttons > div:visible > button:contains(Import)"
)[0]
);
assert.verifySteps(["execute_import"]);
assert.strictEqual(
target.querySelector(".o_import_date_format").value,
@@ -1412,7 +1459,7 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.xlsx", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(target, ".o_control_panel_main_buttons .d-none input[type='file']", file);
await editSelectMenu(target, ".o_import_data_content .o_select_menu", "Bar");
assert.containsN(
target,
@@ -1444,7 +1491,7 @@ QUnit.module("Base Import Tests", (hooks) => {
// Set and trigger the change of a file for the input
const file = new File(["fake_file"], "fake_file.csv", { type: "text/plain" });
await editInput(target, "input[type='file']", file);
await editInput(target, ".o_control_panel_collapsed_create input[type='file']", file);
assert.strictEqual(
target.querySelector(".o_import_date_format").list.id,
"list-3",
@@ -5,10 +5,9 @@ import { importRecordsItem } from "@base_import/import_records/import_records";
import { registry } from "@web/core/registry";
import { click, getFixture, selectDropdownItem } from "@web/../tests/helpers/utils";
import { toggleFavoriteMenu } from "@web/../tests/search/helpers";
import { toggleActionMenu } from "@web/../tests/search/helpers";
import { makeView, setupViewRegistries } from "@web/../tests/views/helpers";
const favoriteMenuRegistry = registry.category("favoriteMenu");
import { clearRegistryWithCleanup } from "@web/../tests/helpers/mock_env";
let serverData;
let target;
@@ -27,12 +26,14 @@ QUnit.module("Base Import Tests", (hooks) => {
},
};
setupViewRegistries();
favoriteMenuRegistry.add("import-menu", importRecordsItem);
const cogMenuRegistry = registry.category("cogMenu");
clearRegistryWithCleanup(cogMenuRegistry);
cogMenuRegistry.add("import-menu", importRecordsItem);
});
QUnit.module("ImportRecords");
QUnit.test("import in favorite dropdown in list", async function (assert) {
QUnit.test("import in cog menu dropdown in list", async function (assert) {
assert.expect(3);
const actionService = {
@@ -56,14 +57,14 @@ QUnit.module("Base Import Tests", (hooks) => {
},
});
await toggleFavoriteMenu(target);
assert.containsOnce(target, ".o_favorite_menu .o-dropdown--menu");
await toggleActionMenu(target);
assert.containsOnce(target, ".o_cp_action_menus .o-dropdown--menu");
assert.containsOnce(target, ".o_import_menu");
await click(target.querySelector(".o_import_menu"));
});
QUnit.test(
'import favorite dropdown item should not be in list with create="0"',
'import should not be available in cog menu dropdown in list with create="0"',
async function (assert) {
await makeView({
type: "list",
@@ -75,14 +76,14 @@ QUnit.module("Base Import Tests", (hooks) => {
},
});
await toggleFavoriteMenu(target);
assert.containsOnce(target, ".o_favorite_menu .o-dropdown--menu");
await toggleActionMenu(target);
assert.containsOnce(target, ".o_cp_action_menus .o-dropdown--menu");
assert.containsNone(target, ".o_import_menu");
}
);
QUnit.test(
'import favorite dropdown item should not be in list with import="0"',
'import should not be available in cog menu dropdown in list with import="0"',
async function (assert) {
await makeView({
type: "list",
@@ -94,13 +95,13 @@ QUnit.module("Base Import Tests", (hooks) => {
},
});
await toggleFavoriteMenu(target);
assert.containsOnce(target, ".o_favorite_menu .o-dropdown--menu");
await toggleActionMenu(target);
assert.containsOnce(target, ".o_cp_action_menus .o-dropdown--menu");
assert.containsNone(target, ".o_import_menu");
}
);
QUnit.test("import in favorite dropdown in kanban", async function (assert) {
QUnit.test("import in cog menu dropdown in kanban", async function (assert) {
assert.expect(3);
const actionService = {
@@ -131,14 +132,14 @@ QUnit.module("Base Import Tests", (hooks) => {
},
});
await toggleFavoriteMenu(target);
assert.containsOnce(target, ".o_favorite_menu .o-dropdown--menu");
await toggleActionMenu(target);
assert.containsOnce(target, ".o_cp_action_menus .o-dropdown--menu");
assert.containsOnce(target, ".o_import_menu");
await click(target.querySelector(".o_import_menu"));
});
QUnit.test(
'import favorite dropdown item should not be in list with create="0"',
'import should not be available in cog menu dropdown in kanban with create="0"',
async function (assert) {
await makeView({
type: "kanban",
@@ -156,15 +157,13 @@ QUnit.module("Base Import Tests", (hooks) => {
actionType: "ir.actions.act_window",
},
});
await toggleFavoriteMenu(target);
assert.containsOnce(target, ".o_favorite_menu .o-dropdown--menu");
assert.containsNone(target, ".o_import_menu");
// Cog menu will not show when empty
assert.containsNone(target, ".o_cp_action_menus");
}
);
QUnit.test(
'import dropdown favorite should not be in kanban with import="0"',
'import should not be available in cog menu dropdown in kanban with import="0"',
async function (assert) {
await makeView({
type: "kanban",
@@ -182,15 +181,13 @@ QUnit.module("Base Import Tests", (hooks) => {
actionType: "ir.actions.act_window",
},
});
await toggleFavoriteMenu(target);
assert.containsOnce(target, ".o_favorite_menu .o-dropdown--menu");
assert.containsNone(target, ".o_import_menu");
// Cog menu will not show when empty
assert.containsNone(target, ".o_cp_action_menus");
}
);
QUnit.test(
"import should not be available in favorite dropdown in pivot (other than kanban or list)",
"import should not be available in cog menu dropdown in pivot (other than kanban or list)",
async function (assert) {
serverData.models.foo.fields.foobar = {
string: "Fubar",
@@ -207,15 +204,13 @@ QUnit.module("Base Import Tests", (hooks) => {
actionType: "ir.actions.act_window",
},
});
await toggleFavoriteMenu(target);
assert.containsOnce(target, ".o_favorite_menu .o-dropdown--menu");
assert.containsNone(target, ".o_import_menu");
// Cog menu will not show when empty
assert.containsNone(target, ".o_cp_action_menus");
}
);
QUnit.test(
"import should not be available in favorite dropdown in dialog view",
"import should not be available in cog menu dropdown in dialog view",
async function (assert) {
serverData.models.bar = {
fields: {
@@ -244,8 +239,8 @@ QUnit.module("Base Import Tests", (hooks) => {
await selectDropdownItem(target, "m2o", "Search More...");
const dialog = target.querySelector(".modal");
await toggleFavoriteMenu(dialog);
assert.containsOnce(dialog, ".o_favorite_menu .o-dropdown--menu");
await toggleActionMenu(dialog);
assert.containsOnce(dialog, ".o_cp_action_menus .o-dropdown--menu");
assert.containsNone(dialog, ".o_import_menu");
}
);