From 591baa9003065bc952efa3130af208114129308e Mon Sep 17 00:00:00 2001 From: tsm-odoo Date: Fri, 2 Sep 2022 09:09:00 +0000 Subject: [PATCH] [FIX] mail: fix indeterministic chat window manager test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this PR, some mail tests relying on DOM elements being present but that are added after the messaging initialization could fail unpredictability. This commit fixes this issue by waiting the next render following the initialization of messaging. closes odoo/odoo#99461 Signed-off-by: Sébastien Theys (seb) --- .../mail/static/tests/helpers/test_utils.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/addons/mail/static/tests/helpers/test_utils.js b/addons/mail/static/tests/helpers/test_utils.js index b23c6bca529..5e94b2d7152 100644 --- a/addons/mail/static/tests/helpers/test_utils.js +++ b/addons/mail/static/tests/helpers/test_utils.js @@ -258,7 +258,17 @@ async function start(param0 = {}) { param0.serverData = param0.serverData || getActionManagerServerData(); param0.serverData.models = { ...pyEnv.getData(), ...param0.serverData.models }; param0.serverData.views = { ...pyEnv.getViews(), ...param0.serverData.views }; - const webClient = await getWebClientReady({ ...param0, messagingBus, testSetupDoneDeferred }); + let webClient; + await afterNextRender(async () => { + webClient = await getWebClientReady({ ...param0, messagingBus, testSetupDoneDeferred }); + if (waitUntilMessagingCondition === 'created') { + await webClient.env.services.messaging.modelManager.messagingCreatedPromise; + } + if (waitUntilMessagingCondition === 'initialized') { + await webClient.env.services.messaging.modelManager.messagingCreatedPromise; + await webClient.env.services.messaging.modelManager.messagingInitializedPromise; + } + }); registerCleanup(async () => { await webClient.env.services.messaging.modelManager.messagingInitializedPromise; @@ -268,13 +278,6 @@ async function start(param0 = {}) { delete owl.Component.env[wowlServicesSymbol].messaging; delete owl.Component.env; }); - if (waitUntilMessagingCondition === 'created') { - await webClient.env.services.messaging.modelManager.messagingCreatedPromise; - } - if (waitUntilMessagingCondition === 'initialized') { - await webClient.env.services.messaging.modelManager.messagingCreatedPromise; - await webClient.env.services.messaging.modelManager.messagingInitializedPromise; - } const openView = async (action, options) => { action['type'] = action['type'] || 'ir.actions.act_window'; await afterNextRender(() => doAction(webClient, action, { props: options }));