From 5c0234270467bb6a20af16e20cc9cb09c6fb36a5 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 11 Aug 2022 11:33:12 +0000 Subject: [PATCH] [FIX] auth_totp: fix the incomplete fix The previous pass in #97567 missed a small window of race condition in *closing the fecking dialog*. Apparently that's still not instantaneous enough and it's possible to have the check trigger in the interval between clicking the button and the dialog being completely torn down. Add an explicit test for this to the existing `closeProfileDialog` utility function. closes odoo/odoo#97969 Signed-off-by: Xavier Morel (xmo) --- addons/auth_totp/static/tests/totp_flow.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/addons/auth_totp/static/tests/totp_flow.js b/addons/auth_totp/static/tests/totp_flow.js index 4ba92d65101..136cae5702b 100644 --- a/addons/auth_totp/static/tests/totp_flow.js +++ b/addons/auth_totp/static/tests/totp_flow.js @@ -59,6 +59,17 @@ function closeProfileDialog({content, totp_state}) { $modal.find('button[name=preference_cancel]').click() } } + }, { + trigger: 'body', + async run() { + while (document.querySelector('.o_dialog_container .o_dialog')) { + await Promise.resolve(); + } + this.$anchor.addClass('dialog-closed'); + }, + }, { + trigger: 'body.dialog-closed', + run() {}, }]; }