diff options
| author | Aaron Bohy <aab@odoo.com> | 2020-01-14 09:03:21 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2020-01-21 07:17:31 +0000 |
| commit | 671a5471cd891ac87a2cffc8a0e7ebac1b519725 (patch) | |
| tree | 058f8ad61c5789d385f97b9502b506679d67f380 /addons/web/static/tests/helpers/test_env.js | |
| parent | 45246a3b96e0b41e4072c2703473185abe28d840 (diff) | |
[IMP] web: Owl compatibility: add ComponentAdapter
This commit adds the ComponentAdapter, an Owl component meant to
be used as universal adapter for Owl components that embed Odoo
legacy widgets.
This component will be a precious tool during the transition phase
of converting our JS codebase from the legacy (widget) framework to
Owl.
Diffstat (limited to 'addons/web/static/tests/helpers/test_env.js')
| -rw-r--r-- | addons/web/static/tests/helpers/test_env.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/addons/web/static/tests/helpers/test_env.js b/addons/web/static/tests/helpers/test_env.js index 417350ef65b..fabe52ff444 100644 --- a/addons/web/static/tests/helpers/test_env.js +++ b/addons/web/static/tests/helpers/test_env.js @@ -1,8 +1,10 @@ odoo.define('web.test_env', async function (require) { "use strict"; - const { buildQuery } = require("web.rpc"); + const AbstractStorageService = require('web.AbstractStorageService'); const Bus = require("web.Bus"); + const RamStorage = require('web.RamStorage'); + const { buildQuery } = require("web.rpc"); const session = require('web.session'); /** @@ -45,6 +47,10 @@ odoo.define('web.test_env', async function (require) { */ function makeTestEnvironment(env = {}, providedRPC = null) { const proxiedEnv = _proxify(env, 'env'); + const RamStorageService = AbstractStorageService.extend({ + storage: new RamStorage(), + }); + let testEnv = {}; const defaultEnv = { _t: env._t || (s => s), _lt: env._lt || (s => s), @@ -54,11 +60,22 @@ odoo.define('web.test_env', async function (require) { }, env.device), qweb: new owl.QWeb({ templates: session.owlTemplates }), services: Object.assign({ + ajax: { // for legacy subwidgets + rpc() { + const prom = testEnv.session.rpc(...arguments); + prom.abort = function () { + throw new Error("Can't abort this request"); + }; + return prom; + }, + }, getCookie() { }, rpc(params, options) { const query = buildQuery(params); return testEnv.session.rpc(query.route, query.params, options); }, + local_storage: new RamStorageService(), + session_storage: new RamStorageService(), }, env.services), session: Object.assign({ rpc(route, params, options) { @@ -69,7 +86,7 @@ odoo.define('web.test_env', async function (require) { }, }, env.session), }; - const testEnv = Object.assign(proxiedEnv, defaultEnv); + testEnv = Object.assign(proxiedEnv, defaultEnv); return testEnv; } |
