[IMP] Project: add JS tests for widgets
Added JS tests for the following widgets: - status_with_color (project.project, project.update) - name_with_subtask_count (project.task) - priority_switch (project.task) Task-3660956 closes odoo/odoo#148104 Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { getFixture } from "@web/../tests/helpers/utils";
|
||||
import { makeView, setupViewRegistries } from "@web/../tests/views/helpers";
|
||||
|
||||
let makeViewParams, target;
|
||||
|
||||
QUnit.module("Project", (hooks) => {
|
||||
hooks.beforeEach(() => {
|
||||
makeViewParams = {
|
||||
type: "kanban",
|
||||
resModel: "project.update",
|
||||
serverData: {
|
||||
models: {
|
||||
"project.update": {
|
||||
fields: {
|
||||
id: {string: "Id", type: "integer"},
|
||||
status: {
|
||||
string: "Status",
|
||||
type: "selection",
|
||||
selection: [
|
||||
["on_track", "On Track"],
|
||||
["at_risk", "At Risk"],
|
||||
["off_track", "Off Track"],
|
||||
["on_hold", "On Hold"],
|
||||
["done", "Done"],
|
||||
],
|
||||
},
|
||||
},
|
||||
records: [
|
||||
{id: 1, status: "on_track"},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
arch: `
|
||||
<kanban class="o_kanban_test">
|
||||
<field name="status"/>
|
||||
<field name="id"/>
|
||||
<template>
|
||||
<t t-name="kanban-box">
|
||||
<div>
|
||||
<field name="status" widget="status_with_color" readonly="1" status_label="test status label"/>
|
||||
</div>
|
||||
</t>
|
||||
</template>
|
||||
</kanban>`,
|
||||
};
|
||||
target = getFixture();
|
||||
setupViewRegistries();
|
||||
});
|
||||
QUnit.module("Components", (hooks) => {
|
||||
QUnit.module("ProjectStatusWithColorSelection");
|
||||
QUnit.test("Check that ProjectStatusWithColorSelectionField is displaying the correct informations", async function (assert) {
|
||||
await makeView(makeViewParams);
|
||||
|
||||
assert.containsOnce(target, 'div[name="status"] .o_color_bubble_20', "In readonly a status bubble should be displayed")
|
||||
assert.containsOnce(target, 'div[name="status"] .o_stat_text:contains("test status label")', "If the status_label prop has been set, its value should be displayed as well")
|
||||
assert.containsOnce(target, 'div[name="status"] .o_stat_value:contains("On Track")', "The value of the selection should be displayed")
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -51,7 +51,7 @@ QUnit.module('Subtask Kanban List tests', {
|
||||
<templates>
|
||||
<t t-name="kanban-box">
|
||||
<div>
|
||||
<field name="name"/>
|
||||
<field name="name" widget="name_with_subtask_count"/>
|
||||
<field name="user_ids" invisible="1" widget="many2many_avatar_user"/>
|
||||
<field name="state" invisible="1" widget="project_task_state_selection"/>
|
||||
<a t-if="record.closed_subtask_count.raw_value">
|
||||
@@ -79,7 +79,7 @@ QUnit.module('Subtask Kanban List tests', {
|
||||
}
|
||||
}, function () {
|
||||
QUnit.test("Check whether subtask list functionality works as intended", async function (assert) {
|
||||
assert.expect(8);
|
||||
assert.expect(9);
|
||||
|
||||
const views = this.views;
|
||||
const { openView } = await start({ serverData: { views } });
|
||||
@@ -88,6 +88,7 @@ QUnit.module('Subtask Kanban List tests', {
|
||||
views: [[false, "kanban"]],
|
||||
});
|
||||
|
||||
assert.containsOnce(target, '.o_field_name_with_subtask_count:contains("(1/4 sub-tasks)")', "Task title should also display the number of (closed) sub-tasks linked to the task");
|
||||
assert.containsOnce(target, '.subtask_list_button', "Only kanban boxes of parent tasks having open subtasks should have the drawdown button, in this case this is 1");
|
||||
assert.containsNone(target, '.subtask_list', "If the drawdown button is not clicked, the subtasks list should be hidden");
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/* @odoo-module */
|
||||
|
||||
import { getFixture, triggerHotkey } from "@web/../tests/helpers/utils";
|
||||
import { makeView, setupViewRegistries } from "@web/../tests/views/helpers";
|
||||
|
||||
let makeViewParams, target;
|
||||
|
||||
QUnit.module("Project", (hooks) => {
|
||||
hooks.beforeEach(() => {
|
||||
makeViewParams = {
|
||||
type: "form",
|
||||
resModel: "project.task",
|
||||
serverData: {
|
||||
models: {
|
||||
"project.task": {
|
||||
fields: {
|
||||
id: {string: "Id", type: "integer"},
|
||||
priority: {
|
||||
string: "Priority",
|
||||
type: "selection",
|
||||
selection: [
|
||||
["0", "Low"],
|
||||
["1", "High"],
|
||||
],
|
||||
},
|
||||
},
|
||||
records: [
|
||||
{ id: 1, priority: "0" },
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
arch: `
|
||||
<form class="o_kanban_test">
|
||||
<field name="priority" widget="priority_switch"/>
|
||||
</form>`,
|
||||
};
|
||||
target = getFixture();
|
||||
setupViewRegistries();
|
||||
});
|
||||
QUnit.module("Components", (hooks) => {
|
||||
QUnit.module("ProjectTaskPrioritySwitch");
|
||||
QUnit.test("Check whether task priority shortcut works as intended", async function (assert) {
|
||||
await makeView(makeViewParams);
|
||||
|
||||
assert.containsOnce(target, 'div[name="priority"] .fa-star-o', "The low priority should display the fa-star-o (empty) icon");
|
||||
await triggerHotkey("alt+r");
|
||||
assert.containsOnce(target, 'div[name="priority"] .fa-star', "After using the alt+r hotkey the priority should be set to high and the widget should display the fa-star (filled) icon");
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user