summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/chrome/action_manager_tests.js
diff options
context:
space:
mode:
authorRobot Odoo <xmo+roboto@odoo.com>2018-11-19 15:38:25 +0100
committerGitHub <noreply@github.com>2018-11-19 15:38:25 +0100
commit7c3d5dc067c7c331dcc0b52bafbdfd067087a3c4 (patch)
tree6058f8a893815bf0ed2495649c125523f4def762 /addons/web/static/tests/chrome/action_manager_tests.js
parent8fc246da31aa2a1c770732ae97e0cb4e840f07cf (diff)
parentabf32b8b21394491040e5c11c1fea809c1d7c62c (diff)
[MERGE][REF] *: update js test suite to use helpers
This rev. introduces robust helpers to use in the JS tests suite to interact with DOM and components, and starts using them (almost) everywhere. All the helpers are exposed though testUtils.js. There are 2 kinds of helpers: 1. Assertions ------------- * assert.containsNone, containsN, containsOnce check that the DOM (or a specific part of the DOM) contains a `selector`. It generates a correct error message automatically. ex: assert.notOk(form.$('button').hasClass('btn-primary')); -> assert.doesNotHaveClass(form.$('button'), 'btn-primary'); * assert.isVisible, isNotVisible check that the DOM has an element visible or not. They also check that the element is actually in the DOM (before most tests didn't verify this). * assert.hasClass, doesNotHaveClass, hasAttrVAlue, check specific properties of a DOM element, and also validate that it is applied on a single existing DOM element (before most tests didn't verify this). 2. Utilities ------------ The goal of the utilities is to centralize the definition of many standard components and interactions, ensuring that when we refactor the JS framework, we do not need to change all the tests. Existing mock utilities (addMockEnvironment, intercept, path, patchDate, unpatch and fieldsViewGet) are moved to 'testUtils.mock.*'. Existing DOM utilities are moved to 'testUtils.dom.*'. New dom utilities are created for opendDatePicker, click, clickFirst and clickLast. Helper `click` verifies that there is exactly 1 element visible in the DOM you click on, `clickFirst` and `clickLast` verify that there are more than one element on the DOM. ex: form.$('button').click(); -> testUtils.dom.click(form.$('button')); New Form utilities: (testUtils.form.*) clickEdit, clickSave, clickCreate, clickDiscard, all clicks on the control panel buttons of the form. `reload` reloads the form data. New modal, graph, kanban and pivot utils (testUtils.pivot.*, testUtils.kanban.*, etc.). New fields utils: (testUtils.fields.*) * editInput, editSelect: allow to change the value of a field, using a selector to identify it. They validate that the input exists and trigger the change event automatically. * editAndTrigger: allow to modify a field and trigger specific events after the value change * many2one (testUtils.fields.many2one.*) clickOpenDropdown, clickHighlightedItem, clickItem, searchAndClickItem: use a field name instead of a selector and do all the complex mechanism to open, filter and highlight many2one fields. Joint work with aab, dam, ged, mge, svs and vsc. closes odoo/odoo#28784
Diffstat (limited to 'addons/web/static/tests/chrome/action_manager_tests.js')
-rw-r--r--addons/web/static/tests/chrome/action_manager_tests.js470
1 files changed, 234 insertions, 236 deletions
diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js
index 7424d31f365..3eea9bda3a0 100644
--- a/addons/web/static/tests/chrome/action_manager_tests.js
+++ b/addons/web/static/tests/chrome/action_manager_tests.js
@@ -176,7 +176,7 @@ QUnit.module('ActionManager', {
assert.expect(1);
var delta = 0;
- testUtils.patch(Widget, {
+ testUtils.mock.patch(Widget, {
init: function () {
delta++;
this._super.apply(this, arguments);
@@ -197,23 +197,23 @@ QUnit.module('ActionManager', {
var n = delta;
actionManager.doAction(4);
// kanban view is loaded, switch to list view
- $('.o_control_panel .o_cp_switch_list').click();
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_list'));
// open a record in form view
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
// go back to action 7 in breadcrumbs
- $('.o_control_panel .breadcrumb a:first').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb a:first'));
assert.strictEqual(delta, n,
"should have properly destroyed all other widgets");
actionManager.destroy();
- testUtils.unpatch(Widget);
+ testUtils.mock.unpatch(Widget);
});
QUnit.test('no widget memory leaks when executing actions in dialog', function (assert) {
assert.expect(1);
var delta = 0;
- testUtils.patch(Widget, {
+ testUtils.mock.patch(Widget, {
init: function () {
delta++;
this._super.apply(this, arguments);
@@ -240,7 +240,7 @@ QUnit.module('ActionManager', {
"should have properly destroyed all widgets");
actionManager.destroy();
- testUtils.unpatch(Widget);
+ testUtils.mock.unpatch(Widget);
});
QUnit.test('no memory leaks when executing an action while switching view', function (assert) {
@@ -248,7 +248,7 @@ QUnit.module('ActionManager', {
var def;
var delta = 0;
- testUtils.patch(Widget, {
+ testUtils.mock.patch(Widget, {
init: function () {
delta += 1;
this._super.apply(this, arguments);
@@ -279,7 +279,7 @@ QUnit.module('ActionManager', {
// switch to the form view (this request is blocked)
def = $.Deferred();
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
// execute another action meanwhile (don't block this request)
actionManager.doAction(4, {clear_breadcrumbs: true});
@@ -291,7 +291,7 @@ QUnit.module('ActionManager', {
"all widgets of action 3 should have been destroyed");
actionManager.destroy();
- testUtils.unpatch(Widget);
+ testUtils.mock.unpatch(Widget);
});
QUnit.test('no memory leaks when executing an action while loading views', function (assert) {
@@ -299,7 +299,7 @@ QUnit.module('ActionManager', {
var def;
var delta = 0;
- testUtils.patch(Widget, {
+ testUtils.mock.patch(Widget, {
init: function () {
delta += 1;
this._super.apply(this, arguments);
@@ -339,7 +339,7 @@ QUnit.module('ActionManager', {
"all widgets of action 3 should have been destroyed");
actionManager.destroy();
- testUtils.unpatch(Widget);
+ testUtils.mock.unpatch(Widget);
});
QUnit.test('no memory leaks when executing an action while loading data of default view', function (assert) {
@@ -347,7 +347,7 @@ QUnit.module('ActionManager', {
var def;
var delta = 0;
- testUtils.patch(Widget, {
+ testUtils.mock.patch(Widget, {
init: function () {
delta += 1;
this._super.apply(this, arguments);
@@ -387,7 +387,7 @@ QUnit.module('ActionManager', {
"all widgets of action 3 should have been destroyed");
actionManager.destroy();
- testUtils.unpatch(Widget);
+ testUtils.mock.unpatch(Widget);
});
QUnit.test('action with "no_breadcrumbs" set to true', function (assert) {
@@ -423,11 +423,11 @@ QUnit.module('ActionManager', {
// execute action 3 and open a record in form view
actionManager.doAction(3);
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
// execute action 4 without 'on_reverse_breadcrumb' handler, then go back
actionManager.doAction(4);
- $('.o_control_panel .breadcrumb a:first').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb a:first'));
assert.verifySteps([]);
// execute action 4 with an 'on_reverse_breadcrumb' handler, then go back
@@ -436,7 +436,7 @@ QUnit.module('ActionManager', {
assert.step('on_reverse_breadcrumb');
}
});
- $('.o_control_panel .breadcrumb a:first').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb a:first'));
assert.verifySteps(['on_reverse_breadcrumb']);
actionManager.destroy();
@@ -495,7 +495,7 @@ QUnit.module('ActionManager', {
// go back using the breadcrumbs
assert.step('go back to action 3');
- $('.o_control_panel .breadcrumb a').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb a'));
assert.verifySteps([
'execute action 3',
@@ -534,7 +534,7 @@ QUnit.module('ActionManager', {
});
actionManager.doAction(4);
actionManager.doAction(8);
- actionManager.$('tr.o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('tr.o_data_row:first'));
actionManager.destroy();
});
@@ -610,10 +610,10 @@ QUnit.module('ActionManager', {
});
actionManager.doAction(8);
assert.verifySteps(['push_state']);
- actionManager.$('tr.o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('tr.o_data_row:first'));
assert.verifySteps(['push_state']);
// we make sure here that the list view is still in the dom
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"there should still be a list view in dom");
actionManager.destroy();
@@ -694,7 +694,7 @@ QUnit.module('ActionManager', {
assert.strictEqual($('.o_control_panel').length, 1,
"should have rendered a control panel");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should have rendered a kanban view");
assert.verifySteps([
@@ -723,7 +723,7 @@ QUnit.module('ActionManager', {
model: 'partner',
});
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"should have rendered a form view");
assert.strictEqual($('.o_control_panel .breadcrumb-item').text(), 'Second record',
"should have opened the second record");
@@ -753,9 +753,9 @@ QUnit.module('ActionManager', {
view_type: 'kanban',
});
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"should not have rendered a list view");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should have rendered a kanban view");
assert.verifySteps([
@@ -785,9 +785,9 @@ QUnit.module('ActionManager', {
view_type: 'form',
});
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"should not have rendered a list view");
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"should have rendered a form view");
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 2,
"there should be two controllers in the breadcrumbs");
@@ -795,10 +795,10 @@ QUnit.module('ActionManager', {
"breadcrumbs should contain the display_name of the opened record");
// go back to Lst
- $('.o_control_panel .breadcrumb a').click();
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ testUtils.dom.click($('.o_control_panel .breadcrumb a'));
+ assert.containsOnce(actionManager, '.o_list_view',
"should now display the list view");
- assert.strictEqual(actionManager.$('.o_form_view').length, 0,
+ assert.containsNone(actionManager, '.o_form_view',
"should not display the form view anymore");
assert.verifySteps([
@@ -818,7 +818,6 @@ QUnit.module('ActionManager', {
actions: this.actions,
archs: this.archs,
data: this.data,
- debug: 1,
});
actionManager.doAction(4);
@@ -838,7 +837,7 @@ QUnit.module('ActionManager', {
"the breadcrumb elements should be correctly ordered");
// go back to List
- $('.o_control_panel .breadcrumb a:last').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb a:last'));
assert.strictEqual($('.o_control_panel .breadcrumb li').length, 2,
"there should be two controllers in the breadcrumbs");
@@ -862,7 +861,7 @@ QUnit.module('ActionManager', {
});
actionManager.doAction(3);
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"should have rendered a list view");
// switch to kanban view
@@ -871,9 +870,9 @@ QUnit.module('ActionManager', {
view_type: 'kanban',
});
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"should not display the list view anymore");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should have switched to the kanban view");
// switch to form view, open record 4
@@ -883,9 +882,9 @@ QUnit.module('ActionManager', {
view_type: 'form',
});
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 0,
+ assert.containsNone(actionManager, '.o_kanban_view',
"should not display the kanban view anymore");
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"should have switched to the form view");
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 2,
"there should be two controllers in the breadcrumbs");
@@ -921,9 +920,9 @@ QUnit.module('ActionManager', {
// execute action 3 and open the first record in a form view
actionManager.doAction(3);
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"should have rendered a form view");
assert.strictEqual($('.o_control_panel .breadcrumb-item:last').text(), 'First record',
"should have opened the first record");
@@ -935,7 +934,7 @@ QUnit.module('ActionManager', {
view_type: 'form',
});
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"should still display the form view");
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 2,
"there should be two controllers in the breadcrumbs");
@@ -973,7 +972,7 @@ QUnit.module('ActionManager', {
assert.verifySteps([], "should not push the loaded state");
- actionManager.$('tr.o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('tr.o_data_row:first'));
assert.verifySteps(['push_state'],
"should push the state of it changes afterwards");
@@ -1023,7 +1022,7 @@ QUnit.module('ActionManager', {
assert.verifySteps([], "should not push the loaded state");
- actionManager.$('button').click();
+ testUtils.dom.click(actionManager.$('button'));
assert.verifySteps(['push_state'],
"should push the state of it changes afterwards");
@@ -1104,7 +1103,7 @@ QUnit.module('ActionManager', {
},
});
- testUtils.intercept(actionManager, 'call_service', function (ev) {
+ testUtils.mock.intercept(actionManager, 'call_service', function (ev) {
if (ev.data.service === 'session_storage') {
assert.step(ev.data.method);
}
@@ -1112,7 +1111,7 @@ QUnit.module('ActionManager', {
actionManager.doAction(4);
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should display a kanban view");
assert.strictEqual($('.o_control_panel .breadcrumb-item').text(), 'Partners Action 4',
"breadcrumbs should display the display_name of the action");
@@ -1124,9 +1123,9 @@ QUnit.module('ActionManager', {
assert.strictEqual($('.o_control_panel .breadcrumb-item').text(), 'Partners Action 4',
"should still be in the same action");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 0,
+ assert.containsNone(actionManager, '.o_kanban_view',
"should no longer display a kanban view");
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"should display a list view");
assert.verifySteps([
@@ -1168,7 +1167,7 @@ QUnit.module('ActionManager', {
def.resolve();
// action 4 loads a kanban view first, 6 loads a list view. We want a list
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
'there should be a list view in DOM');
assert.verifySteps([
@@ -1204,11 +1203,11 @@ QUnit.module('ActionManager', {
actionManager.doAction(4);
// kanban view is loaded, switch to list view
- $('.o_control_panel .o_cp_switch_list').click();
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_list'));
// here, list view is not ready yet, because def is not resolved
// switch back to kanban view
- $('.o_control_panel .o_cp_switch_kanban').click();
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_kanban'));
// here, we want the kanban view to reload itself, regardless of list view
assert.verifySteps([
@@ -1222,9 +1221,9 @@ QUnit.module('ActionManager', {
// we resolve def => list view is now ready (but we want to ignore it)
def.resolve();
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"there should be a kanban view in dom");
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"there should not be a list view in dom");
actionManager.destroy();
@@ -1278,7 +1277,7 @@ QUnit.module('ActionManager', {
// create a situation with 3 breadcrumbs: kanban/form/list
actionManager.doAction(4);
- actionManager.$('.o_kanban_record:first').click();
+ testUtils.dom.click(actionManager.$('.o_kanban_record:first'));
actionManager.doAction(8);
// now, the next read operations will be deferred (this is the read
@@ -1287,8 +1286,8 @@ QUnit.module('ActionManager', {
// click on the breadcrumbs for the form view, then on the kanban view
// before the form view is fully reloaded
- $('.o_control_panel .breadcrumb-item:eq(1)').click();
- $('.o_control_panel .breadcrumb-item:eq(0)').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb-item:eq(1)'));
+ testUtils.dom.click($('.o_control_panel .breadcrumb-item:eq(0)'));
// resolve the form view read
def.resolve();
@@ -1322,22 +1321,22 @@ QUnit.module('ActionManager', {
view_type: 'form',
});
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"should display the form view of action 4");
// click to go back to Kanban (this request is blocked)
def = $.Deferred();
- $('.o_control_panel .breadcrumb a').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb a'));
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"should still display the form view of action 4");
// execute another action meanwhile (don't block this request)
actionManager.doAction(8, {clear_breadcrumbs: true});
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"should display action 8");
- assert.strictEqual(actionManager.$('.o_form_view').length, 0,
+ assert.containsNone(actionManager, '.o_form_view',
"should no longer display the form view");
assert.verifySteps([
@@ -1353,9 +1352,9 @@ QUnit.module('ActionManager', {
// unblock the switch to Kanban in action 4
def.resolve();
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"should still display action 8");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 0,
+ assert.containsNone(actionManager, '.o_kanban_view',
"should not display the kanban view of action 4");
assert.verifySteps([
@@ -1391,23 +1390,23 @@ QUnit.module('ActionManager', {
// execute action 3 and open a record in form view
actionManager.doAction(3);
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"should display the form view of action 3");
// click on 'Call method' button (this request is blocked)
- actionManager.$('.o_form_view button:contains(Call method)').click();
+ testUtils.dom.click(actionManager.$('.o_form_view button:contains(Call method)'));
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"should still display the form view of action 3");
// execute another action
actionManager.doAction(8, {clear_breadcrumbs: true});
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"should display the list view of action 8");
- assert.strictEqual(actionManager.$('.o_form_view').length, 0,
+ assert.containsNone(actionManager, '.o_form_view',
"should no longer display the form view");
assert.verifySteps([
@@ -1424,9 +1423,9 @@ QUnit.module('ActionManager', {
// unblock the call_button request
def.resolve();
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"should still display the list view of action 8");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 0,
+ assert.containsNone(actionManager, '.o_kanban_view',
"should not display action 1");
assert.verifySteps([
@@ -1463,22 +1462,22 @@ QUnit.module('ActionManager', {
actionManager.doAction(3);
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"should display the list view of action 3");
// switch to the form view (this request is blocked)
def = $.Deferred();
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"should still display the list view of action 3");
// execute another action meanwhile (don't block this request)
actionManager.doAction(4, {clear_breadcrumbs: true});
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should display the kanban view of action 8");
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"should no longer display the list view");
assert.verifySteps([
@@ -1494,9 +1493,9 @@ QUnit.module('ActionManager', {
// unblock the switch to the form view in action 3
def.resolve();
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should still display the kanban view of action 8");
- assert.strictEqual(actionManager.$('.o_form_view').length, 0,
+ assert.containsNone(actionManager, '.o_form_view',
"should not display the form view of action 3");
assert.verifySteps([
@@ -1534,16 +1533,16 @@ QUnit.module('ActionManager', {
def = $.Deferred();
actionManager.doAction(3);
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"should not display the list view of action 3");
// execute another action meanwhile (and unlock the RPC)
actionManager.doAction(4);
def.resolve();
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should display the kanban view of action 4");
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"should not display the list view of action 3");
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 1,
"there should be one controller in the breadcrumbs");
@@ -1581,16 +1580,16 @@ QUnit.module('ActionManager', {
def = $.Deferred();
actionManager.doAction(3);
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"should not display the list view of action 3");
// execute another action meanwhile (and unlock the RPC)
actionManager.doAction(4);
def.resolve();
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should display the kanban view of action 4");
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"should not display the list view of action 3");
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 1,
"there should be one controller in the breadcrumbs");
@@ -1626,26 +1625,26 @@ QUnit.module('ActionManager', {
actionManager.doAction(3);
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"should display the list view");
- assert.strictEqual(actionManager.$('.o_list_view .o_data_row').length, 5,
+ assert.containsN(actionManager, '.o_list_view .o_data_row', 5,
"list view should contain 5 records");
assert.strictEqual($('.o_control_panel .o_list_buttons').length, 1,
"list view buttons should be displayed in control panel");
// reload (the search_read RPC will be blocked)
def = $.Deferred();
- $('.o_control_panel .o_cp_switch_list').click(); // click on the switch button
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_list'));
- assert.strictEqual(actionManager.$('.o_list_view .o_data_row').length, 5,
+ assert.containsN(actionManager, '.o_list_view .o_data_row', 5,
"list view should still contain 5 records");
assert.strictEqual($('.o_control_panel .o_list_buttons').length, 1,
"list view buttons should still be displayed in control panel");
// open a record in form view
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"should display the form view");
assert.strictEqual($('.o_control_panel .o_list_buttons').length, 0,
"list view buttons should no longer be displayed in control panel");
@@ -1655,9 +1654,9 @@ QUnit.module('ActionManager', {
// unblock the search_read RPC
def.resolve();
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"should display the form view");
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"should not display the list view");
assert.strictEqual($('.o_control_panel .o_list_buttons').length, 0,
"list view buttons should still not be displayed in control panel");
@@ -1774,7 +1773,7 @@ QUnit.module('ActionManager', {
assert.strictEqual($('ol.breadcrumb').text(), "initial title",
"should have initial title as breadcrumb content");
- actionManager.$('.o_client_action_test').click();
+ testUtils.dom.click(actionManager.$('.o_client_action_test'));
assert.strictEqual($('ol.breadcrumb').text(), "new title",
"should have updated title as breadcrumb content");
@@ -1805,7 +1804,7 @@ QUnit.module('ActionManager', {
assert.strictEqual($('.o_control_panel:visible').length, 1,
"should have rendered a control panel");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should have rendered a kanban view");
assert.verifySteps([
'/web/action/load',
@@ -2013,7 +2012,7 @@ QUnit.module('ActionManager', {
// usecase, using removeSRCAttribute doesn't work as the RPC is
// triggered as soon as the iframe is in the DOM, even if its src
// attribute is removed right after)
- testUtils.patch(ReportClientAction, {
+ testUtils.mock.patch(ReportClientAction, {
start: function () {
var self = this;
return this._super.apply(this, arguments).then(function () {
@@ -2053,7 +2052,7 @@ QUnit.module('ActionManager', {
});
actionManager.doAction(7);
- assert.strictEqual(actionManager.$('.o_report_iframe').length, 1,
+ assert.containsOnce(actionManager, '.o_report_iframe',
"should have opened the report client action");
assert.verifySteps([
@@ -2064,7 +2063,7 @@ QUnit.module('ActionManager', {
]);
actionManager.destroy();
- testUtils.unpatch(ReportClientAction);
+ testUtils.mock.unpatch(ReportClientAction);
});
QUnit.module('Window Actions');
@@ -2085,7 +2084,7 @@ QUnit.module('ActionManager', {
assert.strictEqual($('.o_control_panel').length, 1,
"should have rendered a control panel");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should have rendered a kanban view");
assert.verifySteps([
'/web/action/load',
@@ -2110,37 +2109,37 @@ QUnit.module('ActionManager', {
});
actionManager.doAction(3);
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"should display the list view");
// switch to kanban view
- $('.o_control_panel .o_cp_switch_kanban').click();
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_kanban'));
+ assert.containsNone(actionManager, '.o_list_view',
"should no longer display the list view");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should display the kanban view");
// switch back to list view
- $('.o_control_panel .o_cp_switch_list').click();
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_list'));
+ assert.containsOnce(actionManager, '.o_list_view',
"should display the list view");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 0,
+ assert.containsNone(actionManager, '.o_kanban_view',
"should no longer display the kanban view");
// open a record in form view
- actionManager.$('.o_list_view .o_data_row:first').click();
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
+ assert.containsNone(actionManager, '.o_list_view',
"should no longer display the list view");
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"should display the form view");
assert.strictEqual(actionManager.$('.o_field_widget[name=foo]').text(), 'yop',
"should have opened the correct record");
// go back to list view using the breadcrumbs
- $('.o_control_panel .breadcrumb a').click();
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ testUtils.dom.click($('.o_control_panel .breadcrumb a'));
+ assert.containsOnce(actionManager, '.o_list_view',
"should display the list view");
- assert.strictEqual(actionManager.$('.o_form_view').length, 0,
+ assert.containsNone(actionManager, '.o_form_view',
"should no longer display the form view");
assert.verifySteps([
@@ -2172,28 +2171,28 @@ QUnit.module('ActionManager', {
"breadcrumbs should display the display_name of the action");
// switch to kanban view
- $('.o_control_panel .o_cp_switch_kanban').click();
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_kanban'));
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 1,
"there should still be one controller in the breadcrumbs");
assert.strictEqual($('.o_control_panel .breadcrumb-item').text(), 'Partners',
"breadcrumbs should still display the display_name of the action");
// switch back to list view
- $('.o_control_panel .o_cp_switch_list').click();
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_list'));
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 1,
"there should still be one controller in the breadcrumbs");
assert.strictEqual($('.o_control_panel .breadcrumb-item').text(), 'Partners',
"breadcrumbs should still display the display_name of the action");
// open a record in form view
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 2,
"there should be two controllers in the breadcrumbs");
assert.strictEqual($('.o_control_panel .breadcrumb-item:last').text(), 'First record',
"breadcrumbs should contain the display_name of the opened record");
// go back to list view using the breadcrumbs
- $('.o_control_panel .breadcrumb a').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb a'));
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 1,
"there should be one controller in the breadcrumbs");
assert.strictEqual($('.o_control_panel .breadcrumb-item').text(), 'Partners',
@@ -2216,39 +2215,39 @@ QUnit.module('ActionManager', {
"should have two switch buttons (list and kanban)");
assert.strictEqual($('.o_control_panel .o_cp_switch_buttons button.active').length, 1,
"should have only one active button");
- assert.ok($('.o_control_panel .o_cp_switch_buttons button:first').hasClass('o_cp_switch_list'),
+ assert.hasClass($('.o_control_panel .o_cp_switch_buttons button:first'),'o_cp_switch_list',
"list switch button should be the first one");
- assert.ok($('.o_control_panel .o_cp_switch_list').hasClass('active'),
+ assert.hasClass($('.o_control_panel .o_cp_switch_list'),'active',
"list should be the active view");
// switch to kanban view
- $('.o_control_panel .o_cp_switch_kanban').click();
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_kanban'));
assert.strictEqual($('.o_control_panel .o_cp_switch_buttons button').length, 2,
"should still have two switch buttons (list and kanban)");
assert.strictEqual($('.o_control_panel .o_cp_switch_buttons button.active').length, 1,
"should still have only one active button");
- assert.ok($('.o_control_panel .o_cp_switch_buttons button:first').hasClass('o_cp_switch_list'),
+ assert.hasClass($('.o_control_panel .o_cp_switch_buttons button:first'),'o_cp_switch_list',
"list switch button should still be the first one");
- assert.ok($('.o_control_panel .o_cp_switch_kanban').hasClass('active'),
+ assert.hasClass($('.o_control_panel .o_cp_switch_kanban'),'active',
"kanban should now be the active view");
// switch back to list view
- $('.o_control_panel .o_cp_switch_list').click();
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_list'));
assert.strictEqual($('.o_control_panel .o_cp_switch_buttons button').length, 2,
"should still have two switch buttons (list and kanban)");
- assert.ok($('.o_control_panel .o_cp_switch_list').hasClass('active'),
+ assert.hasClass($('.o_control_panel .o_cp_switch_list'),'active',
"list should now be the active view");
// open a record in form view
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
assert.strictEqual($('.o_control_panel .o_cp_switch_buttons button').length, 0,
"should not have any switch buttons");
// go back to list view using the breadcrumbs
- $('.o_control_panel .breadcrumb a').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb a'));
assert.strictEqual($('.o_control_panel .o_cp_switch_buttons button').length, 2,
"should have two switch buttons (list and kanban)");
- assert.ok($('.o_control_panel .o_cp_switch_list').hasClass('active'),
+ assert.hasClass($('.o_control_panel .o_cp_switch_list'),'active',
"list should be the active view");
actionManager.destroy();
@@ -2270,28 +2269,28 @@ QUnit.module('ActionManager', {
"limit should be correct for kanban");
// switch to list view
- $('.o_control_panel .o_cp_switch_list').click();
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_list'));
assert.strictEqual($('.o_control_panel .o_pager_value').text(), '1-3',
"value should be correct for list");
assert.strictEqual($('.o_control_panel .o_pager_limit').text(), '5',
"limit should be correct for list");
// open a record in form view
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
assert.strictEqual($('.o_control_panel .o_pager_value').text(), '1',
"value should be correct for form");
assert.strictEqual($('.o_control_panel .o_pager_limit').text(), '3',
"limit should be correct for form");
// go back to list view using the breadcrumbs
- $('.o_control_panel .breadcrumb a').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb a'));
assert.strictEqual($('.o_control_panel .o_pager_value').text(), '1-3',
"value should be correct for list");
assert.strictEqual($('.o_control_panel .o_pager_limit').text(), '5',
"limit should be correct for list");
// switch back to kanban view
- $('.o_control_panel .o_cp_switch_kanban').click();
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_kanban'));
assert.strictEqual($('.o_control_panel .o_pager_value').text(), '1-5',
"value should be correct for kanban");
assert.strictEqual($('.o_control_panel .o_pager_limit').text(), '5',
@@ -2317,60 +2316,60 @@ QUnit.module('ActionManager', {
// switch to kanban view
def = $.Deferred();
- $('.o_control_panel .o_cp_switch_kanban').click();
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_kanban'));
+ assert.containsOnce(actionManager, '.o_list_view',
"should still display the list view");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 0,
+ assert.containsNone(actionManager, '.o_kanban_view',
"shouldn't display the kanban view yet");
def.resolve();
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"shouldn't display the list view anymore");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should now display the kanban view");
// switch back to list view
def = $.Deferred();
- $('.o_control_panel .o_cp_switch_list').click();
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_list'));
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should still display the kanban view");
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"shouldn't display the list view yet");
def.resolve();
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 0,
+ assert.containsNone(actionManager, '.o_kanban_view',
"shouldn't display the kanban view anymore");
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"should now display the list view");
// open a record in form view
def = $.Deferred();
- actionManager.$('.o_list_view .o_data_row:first').click();
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
+ assert.containsOnce(actionManager, '.o_list_view',
"should still display the list view");
- assert.strictEqual(actionManager.$('.o_form_view').length, 0,
+ assert.containsNone(actionManager, '.o_form_view',
"shouldn't display the form view yet");
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 1,
"there should still be one controller in the breadcrumbs");
def.resolve();
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"should no longer display the list view");
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"should display the form view");
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 2,
"there should be two controllers in the breadcrumbs");
// go back to list view using the breadcrumbs
def = $.Deferred();
- $('.o_control_panel .breadcrumb a').click();
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ testUtils.dom.click($('.o_control_panel .breadcrumb a'));
+ assert.containsOnce(actionManager, '.o_form_view',
"should still display the form view");
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"shouldn't display the list view yet");
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 2,
"there should still be two controllers in the breadcrumbs");
def.resolve();
- assert.strictEqual(actionManager.$('.o_form_view').length, 0,
+ assert.containsNone(actionManager, '.o_form_view',
"should no longer display the form view");
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"should display the list view");
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 1,
"there should be one controller in the breadcrumbs");
@@ -2389,16 +2388,16 @@ QUnit.module('ActionManager', {
actionManager.doAction(3);
// open a record in form view
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 2,
"there should be two controllers in the breadcrumbs");
assert.strictEqual($('.o_control_panel .breadcrumb-item:last').text(), 'First record',
"breadcrumbs should contain the display_name of the opened record");
// switch to edit mode and change the display_name
- $('.o_control_panel .o_form_button_edit').click();
- actionManager.$('.o_field_widget[name=display_name]').val('New name').trigger('input');
- $('.o_control_panel .o_form_button_save').click();
+ testUtils.dom.click($('.o_control_panel .o_form_button_edit'));
+ testUtils.fields.editInput(actionManager.$('.o_field_widget[name=display_name]'), 'New name');
+ testUtils.dom.click($('.o_control_panel .o_form_button_save'));
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 2,
"there should still be two controllers in the breadcrumbs");
@@ -2423,13 +2422,13 @@ QUnit.module('ActionManager', {
actionManager.doAction(3);
// create a new record
- $('.o_control_panel .o_list_button_add').click();
- assert.strictEqual(actionManager.$('.o_form_view.o_form_editable').length, 1,
+ testUtils.dom.click($('.o_control_panel .o_list_button_add'));
+ assert.containsOnce(actionManager, '.o_form_view.o_form_editable',
"should have opened the form view in edit mode");
// discard
- $('.o_control_panel .o_form_button_cancel').click();
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ testUtils.dom.click($('.o_control_panel .o_form_button_cancel'));
+ assert.containsOnce(actionManager, '.o_list_view',
"should have switched back to the list view");
assert.verifySteps([
@@ -2472,12 +2471,12 @@ QUnit.module('ActionManager', {
actionManager.doAction(3);
// open a record in form view
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
assert.strictEqual(actionManager.$('.o_field_widget[name=foo]').text(), 'yop',
"check initial value of 'yop' field");
// click on 'Call method' button (should call an Object method)
- actionManager.$('.o_form_view button:contains(Call method)').click();
+ testUtils.dom.click(actionManager.$('.o_form_view button:contains(Call method)'));
assert.strictEqual(actionManager.$('.o_field_widget[name=foo]').text(), 'value changed',
"'yop' has been changed by the server, and should be updated in the UI");
@@ -2508,15 +2507,15 @@ QUnit.module('ActionManager', {
actionManager.doAction(3);
// open a record in form view
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
// click on 'Execute action' button (should execute an action)
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 2,
"there should be two parts in the breadcrumbs");
- actionManager.$('.o_form_view button:contains(Execute action)').click();
+ testUtils.dom.click(actionManager.$('.o_form_view button:contains(Execute action)'));
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 3,
"the returned action should have been stacked over the previous one");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"the returned action should have been executed");
assert.verifySteps([
@@ -2555,11 +2554,11 @@ QUnit.module('ActionManager', {
actionManager.doAction(3);
// open a record in form view
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
// click on 'Call method' button (should call an Object method)
def = $.Deferred();
- actionManager.$('.o_form_view button:contains(Call method)').click();
+ testUtils.dom.click(actionManager.$('.o_form_view button:contains(Call method)'));
// Buttons should be disabled
assert.strictEqual(
@@ -2592,17 +2591,17 @@ QUnit.module('ActionManager', {
actionManager.doAction(3);
// open the first record in form view
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
assert.strictEqual($('.o_control_panel .breadcrumb-item:last').text(), 'First record',
"breadcrumbs should contain the display_name of the opened record");
assert.strictEqual(actionManager.$('.o_field_widget[name=foo]').text(), 'yop',
"should have opened the correct record");
// go back to list view using the breadcrumbs
- $('.o_control_panel .breadcrumb a').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb a'));
// open the second record in form view
- actionManager.$('.o_list_view .o_data_row:nth(1)').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:nth(1)'));
assert.strictEqual($('.o_control_panel .breadcrumb-item:last').text(), 'Second record',
"breadcrumbs should contain the display_name of the opened record");
assert.strictEqual(actionManager.$('.o_field_widget[name=foo]').text(), 'blip',
@@ -2633,23 +2632,23 @@ QUnit.module('ActionManager', {
});
actionManager.doAction(3);
- assert.ok($('.o_control_panel .fa-bar-chart-o').hasClass('active'),
+ assert.hasClass($('.o_control_panel .fa-bar-chart-o'),'active',
"bar chart button is active");
- assert.ok(!$('.o_control_panel .fa-area-chart').hasClass('active'),
+ assert.doesNotHaveClass($('.o_control_panel .fa-area-chart'), 'active',
"line chart button is not active");
// display line chart
- $('.o_control_panel .fa-area-chart').click();
- assert.ok($('.o_control_panel .fa-area-chart').hasClass('active'),
+ testUtils.dom.click($('.o_control_panel .fa-area-chart'));
+ assert.hasClass($('.o_control_panel .fa-area-chart'),'active',
"line chart button is now active");
// switch to kanban and back to graph view
- $('.o_control_panel .o_cp_switch_kanban').click();
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_kanban'));
assert.strictEqual($('.o_control_panel .fa-area-chart').length, 0,
"graph buttons are no longer in control panel");
- $('.o_control_panel .o_cp_switch_graph').click();
- assert.ok($('.o_control_panel .fa-area-chart').hasClass('active'),
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_graph'));
+ assert.hasClass($('.o_control_panel .fa-area-chart'),'active',
"line chart button is still active");
actionManager.destroy();
});
@@ -2669,16 +2668,16 @@ QUnit.module('ActionManager', {
});
actionManager.doAction(3);
- assert.ok($('.o_control_panel .o_cp_switch_list').hasClass('active'),
+ assert.hasClass($('.o_control_panel .o_cp_switch_list'),'active',
"list button in control panel is active");
- assert.ok(!$('.o_control_panel .o_cp_switch_graph').hasClass('active'),
+ assert.doesNotHaveClass($('.o_control_panel .o_cp_switch_graph'), 'active',
"graph button in control panel is not active");
// switch to graph view
- $('.o_control_panel .o_cp_switch_graph').click();
- assert.ok(!$('.o_control_panel .o_cp_switch_list').hasClass('active'),
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_graph'));
+ assert.doesNotHaveClass($('.o_control_panel .o_cp_switch_list'), 'active',
"list button in control panel is not active");
- assert.ok($('.o_control_panel .o_cp_switch_graph').hasClass('active'),
+ assert.hasClass($('.o_control_panel .o_cp_switch_graph'),'active',
"graph button in control panel is active");
actionManager.destroy();
});
@@ -2698,18 +2697,16 @@ QUnit.module('ActionManager', {
});
actionManager.doAction(3);
- assert.ok(!actionManager.$('.o_list_view').hasClass('o_list_view_grouped'),
+ assert.doesNotHaveClass(actionManager.$('.o_list_view'), 'o_list_view_grouped',
"list view is not grouped");
- // open search view sub menus
- $('.o_control_panel .o_searchview_more').click();
// open group by dropdown
- $('.o_control_panel .o_cp_right button:contains(Group By)').click();
+ testUtils.dom.click($('.o_control_panel .o_cp_right button:contains(Group By)'));
// click on first link
- $('.o_control_panel .o_group_by_menu a:first').click();
+ testUtils.dom.click($('.o_control_panel .o_group_by_menu a:first'));
- assert.ok(actionManager.$('.o_list_view').hasClass('o_list_view_grouped'),
+ assert.hasClass(actionManager.$('.o_list_view'),'o_list_view_grouped',
'list view is now grouped');
actionManager.destroy();
@@ -2747,12 +2744,12 @@ QUnit.module('ActionManager', {
actionManager.doAction(3);
// open first record in form view
- actionManager.$('.o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_data_row:first'));
// click on edit
- $('.o_control_panel .o_form_button_edit').click();
+ testUtils.dom.click($('.o_control_panel .o_form_button_edit'));
// click on external button for m2o
- actionManager.$('.o_external_button').click();
+ testUtils.dom.click(actionManager.$('.o_external_button'));
assert.verifySteps([
'/web/action/load', // initial load action
'/web/dataset/call_kw/partner', // load views
@@ -2776,34 +2773,34 @@ QUnit.module('ActionManager', {
actionManager.doAction(4);
// open record in form view
- actionManager.$('.o_kanban_record:first').click();
+ testUtils.dom.click(actionManager.$('.o_kanban_record:first'));
// edit record
- $('.o_control_panel button.o_form_button_edit').click();
- actionManager.$('input[name="foo"]').val('pinkypie').trigger('input');
+ testUtils.dom.click($('.o_control_panel button.o_form_button_edit'));
+ testUtils.fields.editInput(actionManager.$('input[name="foo"]'), 'pinkypie');
// go back to kanban view
- $('.o_control_panel .breadcrumb-item:first a').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb-item:first a'));
assert.strictEqual($('.modal .modal-body').text(),
"The record has been modified, your changes will be discarded. Do you want to proceed?",
"should display a modal dialog to confirm discard action");
// cancel
- $('.modal .modal-footer button.btn-secondary').click();
+ testUtils.dom.click($('.modal .modal-footer button.btn-secondary'));
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"should still be in form view");
// go back again to kanban view
- $('.o_control_panel .breadcrumb-item:first a').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb-item:first a'));
// confirm discard
- $('.modal .modal-footer button.btn-primary').click();
+ testUtils.dom.click($('.modal .modal-footer button.btn-primary'));
- assert.strictEqual(actionManager.$('.o_form_view').length, 0,
+ assert.containsNone(actionManager, '.o_form_view',
"should no longer be in form view");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should be in kanban view");
actionManager.destroy();
@@ -2820,11 +2817,11 @@ QUnit.module('ActionManager', {
});
actionManager.doAction(3);
- assert.strictEqual(actionManager.$('.o_data_row').length, 2,
+ assert.containsN(actionManager, '.o_data_row', 2,
"should only display 2 record");
// switch to kanban view
- $('.o_control_panel .o_cp_switch_kanban').click();
+ testUtils.dom.click($('.o_control_panel .o_cp_switch_kanban'));
assert.strictEqual(actionManager.$('.o_kanban_record:not(.o_kanban_ghost)').length, 2,
"should only display 2 record");
@@ -2843,7 +2840,7 @@ QUnit.module('ActionManager', {
actionManager.doAction(3);
// open a record in form view
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 2,
"there should be two controllers in the breadcrumbs");
assert.strictEqual($('.o_control_panel .breadcrumb-item:last').text(), 'First record',
@@ -2856,7 +2853,7 @@ QUnit.module('ActionManager', {
assert.strictEqual($('.o_control_panel .breadcrumb-item:last').text(), 'Partners Action 4',
"breadcrumbs should contain the name of the current action");
// go back using the breadcrumbs
- $('.o_control_panel .breadcrumb a:nth(1)').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb a:nth(1)'));
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 2,
"there should be two controllers in the breadcrumbs");
assert.strictEqual($('.o_control_panel .breadcrumb-item:last').text(), 'First record',
@@ -2869,7 +2866,7 @@ QUnit.module('ActionManager', {
assert.strictEqual($('.o_control_panel .breadcrumb-item:last').text(), 'Partners Action 4',
"breadcrumbs should contain the name of the current action");
// go back using the breadcrumbs
- $('.o_control_panel .breadcrumb a:first').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb a:first'));
assert.strictEqual($('.o_control_panel .breadcrumb-item').length, 1,
"there should be one controller in the breadcrumbs");
assert.strictEqual($('.o_control_panel .breadcrumb-item:last').text(), 'Partners',
@@ -2920,25 +2917,24 @@ QUnit.module('ActionManager', {
});
actionManager.doAction(3);
- assert.strictEqual(actionManager.$('.o_list_view_grouped').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view_grouped',
"should be grouped");
- assert.strictEqual(actionManager.$('.o_group_header').length, 2,
+ assert.containsN(actionManager, '.o_group_header', 2,
"should be grouped by 'bar' (two groups) at first load");
// groupby 'bar' using the searchview
- $('.o_control_panel .o_searchview_more').click(); // open search view sub menus
- $('.o_control_panel .o_cp_right button:contains(Group By)').click(); // open groupby dropdown
- $('.o_control_panel .o_group_by_menu a:first').click(); // click on 'Foo'
+ testUtils.dom.click($('.o_control_panel .o_cp_right button:contains(Group By)'));
+ testUtils.dom.click($('.o_control_panel .o_group_by_menu a:first'));
- assert.strictEqual(actionManager.$('.o_group_header').length, 5,
+ assert.containsN(actionManager, '.o_group_header', 5,
"should be grouped by 'foo' (five groups)");
// remove the groupby in the searchview
- $('.o_control_panel .o_searchview .o_facet_remove').click();
+ testUtils.dom.click($('.o_control_panel .o_searchview .o_facet_remove'));
- assert.strictEqual(actionManager.$('.o_list_view_grouped').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view_grouped',
"should still be grouped");
- assert.strictEqual(actionManager.$('.o_group_header').length, 2,
+ assert.containsN(actionManager, '.o_group_header', 2,
"should be grouped by 'bar' (two groups) at reload");
actionManager.destroy();
@@ -2966,14 +2962,14 @@ QUnit.module('ActionManager', {
});
actionManager.doAction(33);
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"should display the list view");
// try to open a record in a form view
- actionManager.$('.o_list_view .o_data_row:first').click();
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
+ assert.containsOnce(actionManager, '.o_list_view',
"should still display the list view");
- assert.strictEqual(actionManager.$('.o_form_view').length, 0,
+ assert.containsNone(actionManager, '.o_form_view',
"should not display the form view");
assert.verifySteps([
@@ -2988,7 +2984,7 @@ QUnit.module('ActionManager', {
QUnit.test('save current search', function (assert) {
assert.expect(4);
- testUtils.patch(ListController, {
+ testUtils.mock.patch(ListController, {
getContext: function () {
return {
shouldBeInFilterContext: true,
@@ -3024,21 +3020,22 @@ QUnit.module('ActionManager', {
});
actionManager.doAction(33);
- assert.strictEqual(actionManager.$('.o_data_row').length, 5,
+ assert.containsN(actionManager, '.o_data_row', 5,
"should contain 5 records");
// filter on bar
- $('.o_control_panel .o_filters_menu a:contains(Bar)').click();
+ testUtils.dom.click($('.o_control_panel .o_search_options .o_dropdown_toggler_btn:contains(Filters)'));
+ testUtils.dom.click($('.o_control_panel .o_filters_menu a:contains(Bar)'));
- assert.strictEqual(actionManager.$('.o_data_row').length, 2,
- "should contain 2 records");
+ assert.containsN(actionManager, '.o_data_row', 2);
// save filter
- $('.o_control_panel .o_save_search a').click(); // toggle 'Save current search'
+ testUtils.dom.click($('.o_control_panel .o_search_options .o_dropdown_toggler_btn:contains(Favorites)'));
+ testUtils.dom.click($('.o_control_panel .o_save_search'));
$('.o_control_panel .o_save_name input[type=text]').val('some name'); // name the filter
- $('.o_control_panel .o_save_name button').click(); // click on 'Save'
+ testUtils.dom.click($('.o_control_panel .o_save_name button'));
- testUtils.unpatch(ListController);
+ testUtils.mock.unpatch(ListController);
actionManager.destroy();
});
@@ -3060,7 +3057,7 @@ QUnit.module('ActionManager', {
"the search options should be available");
// go back using the breadcrumbs
- $('.o_control_panel .breadcrumb a:first').click();
+ testUtils.dom.click($('.o_control_panel .breadcrumb a:first'));
assert.strictEqual($('.o_search_options .o_dropdown:visible .o_filters_menu').length, 1,
"the search options should be available");
@@ -3096,7 +3093,8 @@ QUnit.module('ActionManager', {
actionManager.doAction(33);
checkRPC = true;
- $('.o_control_panel .o_filters_menu a:contains(Bar)').click(); // filter on bar
+ testUtils.dom.click($('.o_control_panel .o_search_options .o_dropdown_toggler_btn:contains(Filters)'));
+ testUtils.dom.click($('.o_control_panel .o_filters_menu a:contains(Bar)'));
assert.strictEqual($('.o_control_panel .o_facet_values').text().trim(), 'Bar',
"the filter on Bar should appear in the search view");
@@ -3164,11 +3162,11 @@ QUnit.module('ActionManager', {
// execute an action and open a record in form view
actionManager.doAction(3);
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
// click on 'Execute action' button (it executes an action with a CompoundContext as context)
checkSessionStorage = true;
- actionManager.$('.o_form_view button:contains(Execute action)').click();
+ testUtils.dom.click(actionManager.$('.o_form_view button:contains(Execute action)'));
actionManager.destroy();
});
@@ -3191,9 +3189,9 @@ QUnit.module('ActionManager', {
assert.strictEqual($('.o_technical_modal .o_form_view').length, 1,
"should have rendered a form view in a modal");
- assert.ok($('.o_technical_modal .modal-body').hasClass('o_act_window'),
+ assert.hasClass($('.o_technical_modal .modal-body'),'o_act_window',
"dialog main element should have classname 'o_act_window'");
- assert.ok($('.o_technical_modal .o_form_view').hasClass('o_form_editable'),
+ assert.hasClass($('.o_technical_modal .o_form_view'),'o_form_editable',
"form view should be in edit mode");
assert.verifySteps([
@@ -3305,7 +3303,7 @@ QUnit.module('ActionManager', {
});
actionManager.doAction(6);
- assert.strictEqual(actionManager.$('.o_form_view.o_form_editable').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view.o_form_editable',
"should have rendered a form view in edit mode");
assert.verifySteps([
@@ -3341,7 +3339,7 @@ QUnit.module('ActionManager', {
assert.strictEqual($('.o_control_panel').length, 1,
"should have rendered a control panel");
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
"should have rendered a kanban view");
assert.verifySteps([
'/web/action/load',
@@ -3503,7 +3501,7 @@ QUnit.module('ActionManager', {
actionManager.doAction('slowAction');
actionManager.doAction(4);
slowWillStartDef.resolve();
- assert.strictEqual(actionManager.$('.o_kanban_view').length, 1,
+ assert.containsOnce(actionManager, '.o_kanban_view',
'should have loaded a kanban view');
actionManager.destroy();
@@ -3602,20 +3600,20 @@ QUnit.module('ActionManager', {
// open first record in form view. this will crash and will not
// display a form view
- actionManager.$('.o_list_view .o_data_row:first').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:first'));
readOnFirstRecordDef.reject("not working as intended");
- assert.strictEqual(actionManager.$('.o_list_view').length, 1,
+ assert.containsOnce(actionManager, '.o_list_view',
"there should still be a list view in dom");
// open another record, the read will not crash
- actionManager.$('.o_list_view .o_data_row:eq(2)').click();
+ testUtils.dom.click(actionManager.$('.o_list_view .o_data_row:eq(2)'));
- assert.strictEqual(actionManager.$('.o_list_view').length, 0,
+ assert.containsNone(actionManager, '.o_list_view',
"there should not be a list view in dom");
- assert.strictEqual(actionManager.$('.o_form_view').length, 1,
+ assert.containsOnce(actionManager, '.o_form_view',
"there should be a form view in dom");
actionManager.destroy();