[FIX] web: speed up tests by parsing OWL templates only once
closes odoo/odoo#55206 X-original-commit: 9b08be34ac6ffda091a36ebc72fd05374a9d661c Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user