-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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#148835 X-original-commit: 8b0aff1 Signed-off-by: Xavier Bol (xbo) <[email protected]>
- Loading branch information
Showing
3 changed files
with
116 additions
and
2 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
addons/project/static/tests/project_status_with_color_selection_tests.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
addons/project/static/tests/project_task_priority_switch_tests.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
}); | ||
}); | ||
}); |