From b47a06c617bc3a658f6e5c09c19f72981d02c98f Mon Sep 17 00:00:00 2001 From: tsm-odoo Date: Fri, 16 Sep 2022 12:59:20 +0000 Subject: [PATCH] [FIX] bus: fix channels subscription ater disconnection test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, the `channels subscription after disconnect` bus test failed randomly. This occured when the websocket reconnection happened before the first subscription. Indeed, the first subscription is made only if the resulting channel list differs from the last one we sent. This commit fixes the issue by wating for the first subscription before disconnecting the websocket. closes odoo/odoo#100391 Signed-off-by: Alexandre Kühn (aku) --- addons/bus/static/tests/bus_tests.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/bus/static/tests/bus_tests.js b/addons/bus/static/tests/bus_tests.js index 9e20716f7e2..9743f9ee6f5 100644 --- a/addons/bus/static/tests/bus_tests.js +++ b/addons/bus/static/tests/bus_tests.js @@ -287,16 +287,20 @@ QUnit.module('Bus', { patchWithCleanup(window, { setTimeout: fn => fn(), }); + const firstSubscribeDeferred = makeDeferred(); const worker = patchWebsocketWorkerWithCleanup({ _sendToServer({ event_name, data }) { assert.step(`${event_name} - [${data.channels.toString()}]`); + if (event_name === 'subscribe') { + firstSubscribeDeferred.resolve(); + } }, }); await makeTestEnv(); // wait for the websocket to connect and the first subscription // to occur. - await nextTick(); + await firstSubscribeDeferred; worker.websocket.close(WEBSOCKET_CLOSE_CODES.KEEP_ALIVE_TIMEOUT); // wait for the websocket to re-connect. await nextTick();