diff options
| author | Aaron Bohy <aab@odoo.com> | 2021-04-19 13:17:55 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2021-04-19 13:24:40 +0000 |
| commit | b7b83db88c61d7db87045d87b09d7348f3a8a9eb (patch) | |
| tree | 15514c4d44d4f0d04ad3230712e6b448a241253f /addons/web/static/tests/helpers | |
| parent | f1a5ad5f20bf1b885a3c2dc2248b8fb15b2d6565 (diff) | |
[FIX] web: properly unpatch session after each test
Before this commit, `getTZOffset` and `user_has_group` weren't
correctly reset to their initial values after tests. As a
consequence tests executed afterwards might behave unexpectedly.
closes odoo/odoo#69485
Signed-off-by: Géry Debongnie (ged) <ged@openerp.com>
Diffstat (limited to 'addons/web/static/tests/helpers')
| -rw-r--r-- | addons/web/static/tests/helpers/test_utils_mock.js | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/addons/web/static/tests/helpers/test_utils_mock.js b/addons/web/static/tests/helpers/test_utils_mock.js index 962b9610f4b..8474ed22709 100644 --- a/addons/web/static/tests/helpers/test_utils_mock.js +++ b/addons/web/static/tests/helpers/test_utils_mock.js @@ -173,11 +173,12 @@ async function _getMockedOwlEnv(params, mockServer) { function _mockGlobalObjects(params) { // store initial session state (for restoration) const initialSession = Object.assign({}, session); - // patch session - Object.assign(session, { + const sessionPatch = Object.assign({ getTZOffset() { return 0; }, async user_has_group() { return false; }, }, params.session); + // patch session + Object.assign(session, sessionPatch); // patch config let initialConfig; @@ -202,10 +203,8 @@ function _mockGlobalObjects(params) { // build the cleanUp function to restore everything at the end of the test function cleanUp() { let key; - if ('session' in params) { - for (key in session) { - delete session[key]; - } + for (key in sessionPatch) { + delete session[key]; } Object.assign(session, initialSession); if ('config' in params) { |
