diff options
Diffstat (limited to 'addons/web/static/tests/chrome')
5 files changed, 263 insertions, 277 deletions
diff --git a/addons/web/static/tests/chrome/action_manager_mobile_tests.js b/addons/web/static/tests/chrome/action_manager_mobile_tests.js index 86738330add..b105c861c26 100644 --- a/addons/web/static/tests/chrome/action_manager_mobile_tests.js +++ b/addons/web/static/tests/chrome/action_manager_mobile_tests.js @@ -65,18 +65,14 @@ QUnit.module('ActionManager', { // should default on a mobile-friendly view (kanban) for action 1 actionManager.doAction(1); - assert.strictEqual(actionManager.$('.o_list_view').length, 0, - "should not have rendered the list view"); - assert.strictEqual(actionManager.$('.o_kanban_view').length, 1, - "should have rendered the kanban view"); + assert.containsNone(actionManager, '.o_list_view'); + assert.containsOnce(actionManager, '.o_kanban_view'); // there is no mobile-friendly view for action 2, should use the first one (list) actionManager.doAction(2); - assert.strictEqual(actionManager.$('.o_list_view').length, 1, - "should have rendered the list view"); - assert.strictEqual(actionManager.$('.o_kanban_view').length, 0, - "there should be no kanban view in the DOM"); + assert.containsOnce(actionManager, '.o_list_view'); + assert.containsNone(actionManager, '.o_kanban_view'); actionManager.destroy(); }); @@ -98,21 +94,15 @@ QUnit.module('ActionManager', { view_type: 'form', }); - assert.strictEqual(actionManager.$('.o_list_view').length, 0, - "should not have rendered a list view"); - assert.strictEqual(actionManager.$('.o_kanban_view').length, 0, - "should not have rendered a kanban view either"); - assert.strictEqual(actionManager.$('.o_form_view').length, 1, - "should have rendered a form view"); + assert.containsNone(actionManager, '.o_list_view'); + assert.containsNone(actionManager, '.o_kanban_view'); + assert.containsOnce(actionManager, '.o_form_view'); // go back to lazy loaded view - $('.o_control_panel .breadcrumb a').click(); - assert.strictEqual(actionManager.$('.o_form_view').length, 0, - "should not display the form view anymore"); - assert.strictEqual(actionManager.$('.o_list_view').length, 0, - "should not display the list view either"); - assert.strictEqual(actionManager.$('.o_kanban_view').length, 1, - "should have lazy loaded the kanban view"); + testUtils.dom.click($('.o_control_panel .breadcrumb .breadcrumb-item:first')); + assert.containsNone(actionManager, '.o_form_view'); + assert.containsNone(actionManager, '.o_list_view'); + assert.containsOnce(actionManager, '.o_kanban_view'); assert.verifySteps([ '/web/action/load', @@ -135,12 +125,9 @@ QUnit.module('ActionManager', { actionManager.doAction(1); - assert.ok($('.o_control_panel .o_cp_switch_buttons button[data-toggle="dropdown"]').length, 1, - "view switcher button should be displayed"); - assert.ok($('.o_cp_switch_buttons .o_cp_switch_kanban').hasClass('active'), - "kanban should be the active view"); - assert.ok($('.o_cp_switch_buttons .o_switch_view_button_icon').hasClass('fa-th-large'), - "view switcher button icon should be an icon of the kanban"); + assert.containsOnce($('.o_control_panel'), '.o_cp_switch_buttons button[data-toggle="dropdown"]'); + assert.hasClass($('.o_cp_switch_buttons .o_cp_switch_kanban'), 'active'); + assert.hasClass($('.o_cp_switch_buttons .o_switch_view_button_icon'), 'fa-th-large'); actionManager.destroy(); }); 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(); diff --git a/addons/web/static/tests/chrome/pager_tests.js b/addons/web/static/tests/chrome/pager_tests.js index 48c4ce6ed89..e089929abbc 100644 --- a/addons/web/static/tests/chrome/pager_tests.js +++ b/addons/web/static/tests/chrome/pager_tests.js @@ -3,6 +3,7 @@ odoo.define('web.pager_tests', function (require) { var Pager = require('web.Pager'); var concurrency = require('web.concurrency'); +var testUtils = require('web.test_utils'); QUnit.module('chrome', {}, function () { @@ -18,7 +19,7 @@ QUnit.module('chrome', {}, function () { "current_min should be set to 1"); // click on next - pager.$('.o_pager_next').click(); + testUtils.dom.click(pager.$('.o_pager_next')); assert.strictEqual(pager.state.current_min, 5, "current_min should now be 5"); @@ -32,8 +33,8 @@ QUnit.module('chrome', {}, function () { pager.appendTo($('#qunit-fixture')); // enter edition - pager.$('.o_pager_value').click(); - assert.strictEqual(pager.$('input').length, 1, + testUtils.dom.click(pager.$('.o_pager_value')); + assert.containsOnce(pager, 'input', "the pager should contain an input"); assert.strictEqual(pager.$('input').val(), '1-4', "the input should have correct value"); @@ -62,16 +63,16 @@ QUnit.module('chrome', {}, function () { pager.disable(); // try to go to the next or previous pages - pager.$('.o_pager_next').click(); + testUtils.dom.click(pager.$('.o_pager_next')); assert.strictEqual(pager.state.current_min, 1, "current_min should still be 1"); - pager.$('.o_pager_previous').click(); + testUtils.dom.click(pager.$('.o_pager_previous')); assert.strictEqual(pager.state.current_min, 1, "current_min should still be 1"); // try to change the limit - pager.$('.o_pager_value').click(); - assert.strictEqual(pager.$('input').length, 0, + testUtils.dom.click(pager.$('.o_pager_value')); + assert.containsNone(pager, 'input', "the pager should not contain an input"); // a common use is to disable the pager before reloading the data, and @@ -86,7 +87,7 @@ QUnit.module('chrome', {}, function () { }); }); pager.enable(); - pager.$('.o_pager_next').click(); + testUtils.dom.click(pager.$('.o_pager_next')); }); }); diff --git a/addons/web/static/tests/chrome/search_view_mobile_tests.js b/addons/web/static/tests/chrome/search_view_mobile_tests.js index 1508f45952c..05e2cd09a73 100644 --- a/addons/web/static/tests/chrome/search_view_mobile_tests.js +++ b/addons/web/static/tests/chrome/search_view_mobile_tests.js @@ -62,18 +62,18 @@ QUnit.module('Mobile Search view Screen', { assert.ok(!$('.o_mobile_search').is(':visible'), 'mobile search view is not visible'); // open the search view - $('button.o_enable_searchview').click(); + testUtils.dom.click($('button.o_enable_searchview')); assert.ok($('.o_mobile_search').is(':visible'), 'mobile search view is visible'); // open filter sub menu - $('button.o_dropdown_toggler_btn').first().click(); + testUtils.dom.click($('button.o_dropdown_toggler_btn').first()); filterActiveFlag = true; // click on Active filter - $('.o_filters_menu a:contains(Active)').click(); + testUtils.dom.click($('.o_filters_menu a:contains(Active)')); actionManager.destroy(); }); diff --git a/addons/web/static/tests/chrome/user_menu_tests.js b/addons/web/static/tests/chrome/user_menu_tests.js index f05a8a48120..600ac125dd4 100644 --- a/addons/web/static/tests/chrome/user_menu_tests.js +++ b/addons/web/static/tests/chrome/user_menu_tests.js @@ -13,15 +13,15 @@ QUnit.module('chrome', {}, function () { var parent = new Widget(); - testUtils.addMockEnvironment(parent, {}); + testUtils.mock.addMockEnvironment(parent, {}); var userMenu = new UserMenu(parent); userMenu.appendTo($('body')); assert.strictEqual($('.o_user_menu').length, 1, "should have a user menu in the DOM"); - assert.ok(userMenu.$el.hasClass('o_user_menu'), + assert.hasClass(userMenu.$el,'o_user_menu', "user menu in DOM should be from user menu widget instantiation"); - assert.strictEqual(userMenu.$('.dropdown-item[data-menu="shortcuts"]').length, 1, + assert.containsOnce(userMenu, '.dropdown-item[data-menu="shortcuts"]', "should have a 'Shortcuts' item"); userMenu.destroy(); |
