From baae272ffdbb3b723ce9d2f09dfe720b8bbde27b Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 17 Nov 2017 15:34:13 +0100 Subject: [REF] web: tests: make load_views RPCs go through mockRPC This allows to inspect those RPCs and the given arguments as well. --- .../static/tests/fields/relational_fields_tests.js | 27 ++++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'addons/web/static/tests/fields') diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js index cc5f3d31ef5..462ea74ac89 100644 --- a/addons/web/static/tests/fields/relational_fields_tests.js +++ b/addons/web/static/tests/fields/relational_fields_tests.js @@ -415,7 +415,7 @@ QUnit.module('relational_fields', { }); QUnit.test('onchanges on many2ones trigger when editing record in form view', function (assert) { - assert.expect(9); + assert.expect(10); this.data.partner.onchanges.user_id = function () {}; this.data.user.fields.other_field = {string: "Other Field", type: "char"}; @@ -454,12 +454,12 @@ QUnit.module('relational_fields', { // save the modal and make sure an onchange is triggered $('.modal .modal-footer .btn-primary').first().click(); - assert.verifySteps(['read', 'get_formview_id', 'read', 'write', 'onchange', 'read']); + assert.verifySteps(['read', 'get_formview_id', 'load_views', 'read', 'write', 'onchange', 'read']); // save the main record, and check that no extra rpcs are done (record // is not dirty, only a related record was modified) form.$buttons.find('.o_form_button_save').click(); - assert.verifySteps(['read', 'get_formview_id', 'read', 'write', 'onchange', 'read']); + assert.verifySteps(['read', 'get_formview_id', 'load_views', 'read', 'write', 'onchange', 'read']); form.destroy(); }); @@ -5902,7 +5902,7 @@ QUnit.module('relational_fields', { // should omit require fields that aren't in the view as they (obviously) // have no value, when checking the validity of required fields // shouldn't consider numerical fields with value 0 as unset - assert.expect(11); + assert.expect(12); this.data.turtle.fields.turtle_foo.required = true; this.data.turtle.fields.turtle_qux.required = true; // required field not in the view @@ -5951,13 +5951,13 @@ QUnit.module('relational_fields', { form.$('.o_field_x2many_list_row_add a').click(); assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "0", "int_field should still be 0 (no onchange should have been done yet)"); - assert.verifySteps(['read', 'default_get'], "no onchange should have been applied"); + assert.verifySteps(['load_views', 'read', 'default_get'], "no onchange should have been applied"); // fill turtle_foo field form.$('.o_field_widget[name="turtle_foo"]').val("some text").trigger('input'); assert.strictEqual(form.$('.o_field_widget[name="int_field"]').val(), "0", "int_field should still be 0 (no onchange should have been done yet)"); - assert.verifySteps(['read', 'default_get'], "no onchange should have been applied"); + assert.verifySteps(['load_views', 'read', 'default_get'], "no onchange should have been applied"); // fill partner_ids field with a tag (all required fields will then be set) var $m2mInput = form.$('.o_field_widget[name=partner_ids] input'); @@ -7140,7 +7140,9 @@ QUnit.module('relational_fields', { }, res_id: 1, mockRPC: function (route, args) { - assert.step(_.last(route.split('/'))); + if (args.method !== 'load_views') { + assert.step(_.last(route.split('/'))); + } if (args.method === 'write' && args.model === 'partner') { assert.deepEqual(args.args[1].timmy, [ [6, false, [12, 15]], @@ -7238,7 +7240,9 @@ QUnit.module('relational_fields', { 'partner_type,false,search': '', }, mockRPC: function (route, args) { - assert.step(_.last(route.split('/'))); + if (args.method !== 'load_views') { + assert.step(_.last(route.split('/'))); + } if (args.method === 'write') { assert.deepEqual(args.args[1].timmy, [ [6, false, [12, 15]], @@ -7544,7 +7548,9 @@ QUnit.module('relational_fields', { '', }, mockRPC: function (route, args) { - assert.step(_.last(route.split('/')) + ' on ' + args.model); + if (args.method !== 'load_views') { + assert.step(_.last(route.split('/')) + ' on ' + args.model); + } if (args.model === 'turtle') { assert.step(args.args[0]); // the read ids } @@ -7629,7 +7635,7 @@ QUnit.module('relational_fields', { }); QUnit.test('many2many list with onchange and edition of a record', function (assert) { - assert.expect(7); + assert.expect(8); this.data.partner.fields.turtles.type = "many2many"; this.data.partner.onchanges.turtles = function () {}; @@ -7666,6 +7672,7 @@ QUnit.module('relational_fields', { assert.verifySteps([ 'read', // read initial record (on partner) 'read', // read many2many turtles + 'load_views', // load arch of turtles form view 'read', // read missing field when opening record in modal form view 'write', // when saving the modal 'onchange', // onchange should be triggered on partner -- cgit v1.2.3