1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
odoo.define('web.test_utils_kanban', function (require) {
"use strict";
/**
* Kanban Test Utils
*
* This module defines various utility functions to help testing kanban views.
*
* Note that all methods defined in this module are exported in the main
* testUtils file.
*/
var testUtilsDom = require('web.test_utils_dom');
var testUtilsFields = require('web.test_utils_fields');
/**
* Clicks on the Create button in a kanban view. Note that this method checks that
* the Create button is visible.
*
* @param {KanbanController} kanban
* @returns {Promise}
*/
function clickCreate(kanban) {
return testUtilsDom.click(kanban.$buttons.find('.o-kanban-button-new'));
}
/**
* Open the settings menu for a column (in a grouped kanban view)
*
* @param {jQuery} $column
* @returns {Promise}
*/
function toggleGroupSettings($column) {
var $dropdownToggler = $column.find('.o_kanban_config > a.dropdown-toggle');
if (!$dropdownToggler.is(':visible')) {
$dropdownToggler.css('display', 'block');
}
return testUtilsDom.click($dropdownToggler);
}
/**
* Edit a value in a quickcreate form view (this method assumes that the quick
* create feature is active, and a sub form view is open)
*
* @param {kanbanController} kanban
* @param {string|number} value
* @param {[string]} fieldName
* @returns {Promise}
*/
function quickCreate(kanban, value, fieldName) {
var additionalSelector = fieldName ? ('[name=' + fieldName + ']'): '';
var enterEvent = $.Event(
'keydown',
{
which: $.ui.keyCode.ENTER,
keyCode: $.ui.keyCode.ENTER,
}
);
return testUtilsFields.editAndTrigger(
kanban.$('.o_kanban_quick_create input' + additionalSelector),
value,
['input', enterEvent]
);
}
/**
* Reloads a kanban view.
*
* @param {KanbanController} kanban
* @param {[Object]} params given to the controller reload method
* @returns {Promise}
*/
function reload(kanban, params) {
return kanban.reload(params);
}
/**
* Open the setting dropdown of a kanban record. Note that the template of a
* kanban record is not standardized, so this method will fail if the template
* does not comply with the usual dom structure.
*
* @param {jQuery} $record
* @returns {Promise}
*/
function toggleRecordDropdown($record) {
var $dropdownToggler = $record.find('.o_dropdown_kanban > a.dropdown-toggle');
if (!$dropdownToggler.is(':visible')) {
$dropdownToggler.css('display', 'block');
}
return testUtilsDom.click($dropdownToggler);
}
return {
clickCreate: clickCreate,
quickCreate: quickCreate,
reload: reload,
toggleGroupSettings: toggleGroupSettings,
toggleRecordDropdown: toggleRecordDropdown,
};
});
|