From 9cbf0c87e2d6705d72ca4613f761b6b2b9901afd Mon Sep 17 00:00:00 2001 From: fwi-odoo Date: Thu, 16 Nov 2017 10:24:15 +0100 Subject: [PATCH] [FIX] web: allow to reexecute functions using _.throttle in the js tests Before this commit, it was not possible to reexecute functions using the _.throttle function in the same test (e.g. drag and drop two elements in the studio tests). --- addons/web/static/tests/helpers/qunit_config.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/addons/web/static/tests/helpers/qunit_config.js b/addons/web/static/tests/helpers/qunit_config.js index 641d3a6f09b..8d2b287ab88 100644 --- a/addons/web/static/tests/helpers/qunit_config.js +++ b/addons/web/static/tests/helpers/qunit_config.js @@ -40,6 +40,17 @@ QUnit.config.hidepassed = (window.location.href.match(/[?&]testId=/) === null); var sortButtonAppended = false; +/** + * We override the _.throttle function to avoid the delay in order to be able to + * chain multiple actions using throttle in the same test. + */ +QUnit.begin(function () { + this._initialThrottle = _.throttle; + var self = this; + _.throttle = function (func, wait, options) { + return self._initialThrottle(func, 0, options); + }; +}); /** * This is the way the testing framework knows that tests passed or failed. It * only look in the phantomJS console and check if there is a ok or an error. @@ -56,6 +67,7 @@ QUnit.done(function(result) { if (!sortButtonAppended) { _addSortButton(); } + _.throttle = this._initialThrottle; }); /**