summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/helpers/test_utils_mock.js
diff options
context:
space:
mode:
authorXavier Morel <xmo@odoo.com>2020-07-06 09:37:49 +0000
committerXavier Morel <xmo@odoo.com>2020-07-09 07:23:04 +0000
commit350ed97c4556f6c6ea1a736db0ea5a804b28ba08 (patch)
treefa582e732f3426a1c7a2cda9cb8344e9702b5a0d /addons/web/static/tests/helpers/test_utils_mock.js
parentccea563abbbae48b7b914f5b12e59b02e167d486 (diff)
[FIX] web: async operations should not live in init
Support for the "allow exports" group was implemented by checking the group in init(), which is sync. Move that check over to willStart instead. Also add a default mock for user_has_group (makes it so it always replies that the user doesn't have the group), and override that specifically for the group we're interested in in the export tests, so those tests have access to the Export action / option. closes odoo/odoo#54254 X-original-commit: 30968ac93373990338c23f49e678d272b8e60c6b Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Diffstat (limited to 'addons/web/static/tests/helpers/test_utils_mock.js')
-rw-r--r--addons/web/static/tests/helpers/test_utils_mock.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/addons/web/static/tests/helpers/test_utils_mock.js b/addons/web/static/tests/helpers/test_utils_mock.js
index 1b70673f067..144b05acf74 100644
--- a/addons/web/static/tests/helpers/test_utils_mock.js
+++ b/addons/web/static/tests/helpers/test_utils_mock.js
@@ -168,14 +168,13 @@ async function _getMockedOwlEnv(params, mockServer) {
* end of the test
*/
function _mockGlobalObjects(params) {
+ // store initial session state (for restoration)
+ const initialSession = Object.assign({}, session);
// patch session
- let initialSession = Object.assign({}, session);
- session.getTZOffset = function () {
- return 0; // by default, but may be overridden in specific tests
- };
- if ('session' in params) {
- Object.assign(session, params.session);
- }
+ Object.assign(session, {
+ getTZOffset() { return 0; },
+ async user_has_group() { return false; },
+ }, params.session);
// patch config
let initialConfig;