From af490aa25dbcad131e065588a51085d005ccf1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Thu, 30 Jul 2020 11:34:41 +0000 Subject: [PATCH] [FIX] web: speed up tests by parsing OWL templates only once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes odoo/odoo#55206 X-original-commit: 9b08be34ac6ffda091a36ebc72fd05374a9d661c Signed-off-by: Aaron Bohy (aab) Signed-off-by: Sébastien Theys (seb) --- addons/web/static/tests/helpers/test_env.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/web/static/tests/helpers/test_env.js b/addons/web/static/tests/helpers/test_env.js index c0020ff8308..344fb48dda9 100644 --- a/addons/web/static/tests/helpers/test_env.js +++ b/addons/web/static/tests/helpers/test_env.js @@ -5,6 +5,8 @@ odoo.define('web.test_env', async function (require) { const { buildQuery } = require('web.rpc'); const session = require('web.session'); + let qweb; + /** * Creates a test environment with the given environment object. * Any access to a key that has not been explicitly defined in the given environment object @@ -15,6 +17,11 @@ odoo.define('web.test_env', async function (require) { * @returns {Proxy} */ function makeTestEnvironment(env = {}, providedRPC = null) { + if (!qweb) { + // avoid parsing templates at every test because it takes a lot of + // time and they never change + qweb = new owl.QWeb({ templates: session.owlTemplates }); + } const database = { parameters: { code: "en_US", @@ -40,7 +47,7 @@ odoo.define('web.test_env', async function (require) { bus: env.bus || new Bus(), device: Object.assign({ isMobile: false }, env.device), isDebug: env.isDebug || (() => false), - qweb: new owl.QWeb({ templates: session.owlTemplates }), + qweb, services: Object.assign({ ajax: { rpc() {