diff --git a/addons/web/static/tests/helpers/mock_env.js b/addons/web/static/tests/helpers/mock_env.js index 7433fe0e098..00696b41476 100644 --- a/addons/web/static/tests/helpers/mock_env.js +++ b/addons/web/static/tests/helpers/mock_env.js @@ -53,7 +53,7 @@ function prepareRegistriesWithCleanup() { cloneRegistryWithCleanup(registry.category("command_setup")); cloneRegistryWithCleanup(registry.category("view_widgets")); cloneRegistryWithCleanup(registry.category("fields")); - cloneRegistryWithCleanup(registry.category('wowlToLegacyServiceMappers')); + cloneRegistryWithCleanup(registry.category("wowlToLegacyServiceMappers")); cloneRegistryWithCleanup(registry.category("main_components")); cloneRegistryWithCleanup(registry.category("fields")); @@ -64,7 +64,7 @@ function prepareRegistriesWithCleanup() { clearRegistryWithCleanup(registry.category("error_dialogs")); clearRegistryWithCleanup(registry.category("favoriteMenu")); clearRegistryWithCleanup(registry.category("ir.actions.report handlers")); - clearRegistryWithCleanup(registry.category('wowlToLegacyServiceMappers')); + clearRegistryWithCleanup(registry.category("wowlToLegacyServiceMappers")); clearRegistryWithCleanup(registry.category("services")); clearServicesMetadataWithCleanup(); @@ -122,9 +122,11 @@ export async function makeTestEnv(config = {}) { FormController.prototype.multiClickTime = initialQuickEditDelay; }); - const env = makeEnv(); - owl.Component.env = env; - env.config = config.config || {}; + let env = makeEnv(); await startServices(env); + owl.Component.env = env; + if ("config" in config) { + env = Object.assign(Object.create(env), { config: config.config }); + } return env; } diff --git a/addons/web/static/tests/search/helpers.js b/addons/web/static/tests/search/helpers.js index ee1faf90e5b..3c282ef9040 100644 --- a/addons/web/static/tests/search/helpers.js +++ b/addons/web/static/tests/search/helpers.js @@ -78,8 +78,9 @@ export async function makeWithSearch(params) { `; Parent.components = { Component: params.Component, WithSearch }; - const env = await makeTestEnv({ serverData, mockRPC, config }); - const parent = await mount(Parent, getFixture(), { env, props }); + const env = await makeTestEnv({ serverData, mockRPC }); + const searchEnv = Object.assign(Object.create(env), { config }); + const parent = await mount(Parent, getFixture(), { env: searchEnv, props }); const parentNode = parent.__owl__; const withSearchNode = getUniqueChild(parentNode); const componentNode = getUniqueChild(withSearchNode); diff --git a/addons/web/static/tests/search/with_search_tests.js b/addons/web/static/tests/search/with_search_tests.js index 2cb8f966ce9..afd7a1d12aa 100644 --- a/addons/web/static/tests/search/with_search_tests.js +++ b/addons/web/static/tests/search/with_search_tests.js @@ -322,6 +322,7 @@ QUnit.module("Search", (hooks) => { class Parent extends Component { setup() { + owl.useSubEnv({ config: {} }); this.searchState = useState({ resModel: "animal", domain: [["type", "=", "carnivorous"]], diff --git a/addons/web/static/tests/views/helpers.js b/addons/web/static/tests/views/helpers.js index 0b9495260f5..a78f7b1d8b0 100644 --- a/addons/web/static/tests/views/helpers.js +++ b/addons/web/static/tests/views/helpers.js @@ -61,7 +61,7 @@ export async function makeView(params) { delete props.searchViewArch; } - const env = await makeTestEnv({ serverData, mockRPC, config }); + const env = await makeTestEnv({ serverData, mockRPC }); Object.assign(env, createDebugContext(env)); // This is needed if the views are in debug mode /** Legacy Environment, for compatibility sakes @@ -81,7 +81,8 @@ export async function makeView(params) { await addLegacyMockEnvironment(env, legacyParams); const target = getFixture(); - const view = await mount(View, target, { env, props }); + const viewEnv = Object.assign(Object.create(env), { config }); + const view = await mount(View, target, { env: viewEnv, props }); await mount(MainComponentsContainer, target, { env, props }); const viewNode = view.__owl__; diff --git a/addons/web/static/tests/views/layout_tests.js b/addons/web/static/tests/views/layout_tests.js index dcc5a303533..3578b21279c 100644 --- a/addons/web/static/tests/views/layout_tests.js +++ b/addons/web/static/tests/views/layout_tests.js @@ -58,8 +58,9 @@ QUnit.module("Views", (hooks) => { `; ToyComponent.components = { Layout }; - const env = await makeTestEnv({ config: {} }); - await mount(ToyComponent, getFixture(), { env }); + const env = await makeTestEnv(); + const toyEnv = Object.assign(Object.create(env), { config: {} }); + await mount(ToyComponent, getFixture(), { env: toyEnv }); assert.containsOnce(target, ".o_view_sample_data"); assert.containsNone(target, ".o_control_panel");