summaryrefslogtreecommitdiff
path: root/addons/mail/static/tests
diff options
context:
space:
mode:
authorJulien Mougenot <jum@odoo.com>2020-03-11 09:38:27 +0000
committerJulien Mougenot <jum@odoo.com>2020-03-13 11:39:53 +0000
commit0a129284e4856b6485c48a194fd86c3ab5c736e7 (patch)
treedc0adb0c9528605019af5c915ad2c877f9aa1c57 /addons/mail/static/tests
parent72f1633532a586e1ccee4d2a961d745553b9d8b8 (diff)
[IMP] web,*: Enhance test helpers
1. Test utils helpers adapted to properly instantiate the new Owl control panel 2. New file 'test_utils_control_panel' to create a control panel and use helpers 3. New helper: createComponent (creates a generic component, see jsdoc) 4. Use of the new helpers in the current tests (more in sibling commits) 5. Helper 'addMockEnvironment' is now asynchronous 6. Owl config mode set to 'dev' in test suite (props validation) Part of task 2196029 Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Diffstat (limited to 'addons/mail/static/tests')
-rw-r--r--addons/mail/static/tests/helpers/test_utils.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/addons/mail/static/tests/helpers/test_utils.js b/addons/mail/static/tests/helpers/test_utils.js
index 90317900660..f3328c9a1a9 100644
--- a/addons/mail/static/tests/helpers/test_utils.js
+++ b/addons/mail/static/tests/helpers/test_utils.js
@@ -9,11 +9,12 @@ var mailUtils = require('mail.utils');
var AbstractStorageService = require('web.AbstractStorageService');
var Class = require('web.Class');
-var ControlPanelView = require('web.ControlPanelView');
var RamStorage = require('web.RamStorage');
+const makeTestEnvironment = require('web.test_env');
var testUtils = require('web.test_utils');
var Widget = require('web.Widget');
+const { prepareTarget, nextTick } = testUtils;
/**
* Test Utils
*
@@ -37,8 +38,11 @@ async function createDiscuss(params) {
'mail.message,false,search': '<search/>',
};
testUtils.mock.addMockEnvironment(parent, params);
+
+ const env = params.env || {};
+ owl.Component.env = makeTestEnvironment(env);
+
var discuss = new Discuss(parent, params);
- var selector = params.debug ? 'body' : '#qunit-fixture';
// override 'destroy' of discuss so that it calls 'destroy' on the parent
// instead, which is the parent of discuss and the mockServer.
@@ -49,9 +53,9 @@ async function createDiscuss(params) {
parent.destroy();
};
- return discuss.appendTo($(selector)).then(function () {
- return discuss;
- });
+ await discuss.appendTo(prepareTarget(params.debug));
+ await nextTick();
+ return discuss;
}