From 5c67abd0d306f446af9df59cb6bca2428f17f7a9 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 8 Feb 2018 14:43:14 +0100 Subject: [REF] web: tests: move calls to removeSrcAttribute In the tests environment, we listen to the 'DOMNodeInserted' event to remove the src attribute of img and iframe nodes as soon as they are inserted into the DOM, so that they don't perform RPCs. However, this listener was bound in the create(Async)View, and createActionManager helpers only. This rev. moves it to the addMockEnvironment helper which is more global, and basically used by all tests. Moreover, we now listen to the 'DOMNodeInserted' event on the body, instead of on the widget, as it may happen that some content is inserted into the DOM outside the widget itself (e.g. dialogs are appended to the body). --- addons/web/static/tests/fields/basic_fields_tests.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'addons/web/static/tests/fields/basic_fields_tests.js') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 8488076b3f0..32a5c3c975e 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1666,7 +1666,7 @@ QUnit.module('basic_fields', { }); QUnit.test('image fields in subviews are loaded correctly', function (assert) { - assert.expect(5); + assert.expect(6); this.data.partner.records[0].__last_update = '2017-02-08 10:00:00'; this.data.partner.records[0].document = 'myimage'; @@ -1695,6 +1695,10 @@ QUnit.module('basic_fields', { assert.step("The view's image should have been fetched"); return $.when('wow'); } + if (route === 'data:image/png;base64,product_image') { + assert.step("The dialog's image should have been fetched"); + return $.when(); + } return this._super.apply(this, arguments); }, }); @@ -1707,9 +1711,10 @@ QUnit.module('basic_fields', { form.$('tbody td:contains(gold)').click(); assert.strictEqual($('.modal-dialog').length, 1, 'The modal should have opened'); - assert.strictEqual($('.modal-dialog').find('.o_field_image > img')[0].src, - 'data:image/png;base64,product_image', - 'The image of the many2many in its form view should be present'); + assert.verifySteps([ + "The view's image should have been fetched", + "The dialog's image should have been fetched", + ]); form.destroy(); }); -- cgit v1.2.3