diff options
| author | Aaron Bohy <aab@odoo.com> | 2020-06-08 11:50:24 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2020-07-13 12:55:07 +0000 |
| commit | af85bb5e13b9c97d022a721bd782a37d718e4496 (patch) | |
| tree | 731c1983542ec3fc07b3b70832659d5ad803252d /addons/web/static/tests | |
| parent | ce3c7d8714c330b8344ffb76245c364045cbf62f (diff) | |
[IMP] web,*: do not deploy services in tests
*mail,point_of_sale,web_editor,website
In the tests, required services are deployed for each test
independently. There is no need to have, in additon, all services
deployed globally. Worse, it could conflict and lead to unexpected
results.
This commit ensures services are no longer deployed globally in
tests. It turns the module 'web.env' into a declarative module with
no side-effect, by moving the service deployment to main.js, which
isn't added to the tests page.
Task 2287397
closes odoo/odoo#53817
Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
Diffstat (limited to 'addons/web/static/tests')
| -rw-r--r-- | addons/web/static/tests/main_tests.js | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/addons/web/static/tests/main_tests.js b/addons/web/static/tests/main_tests.js index 97d9b051bbb..30164cea61b 100644 --- a/addons/web/static/tests/main_tests.js +++ b/addons/web/static/tests/main_tests.js @@ -3,14 +3,23 @@ odoo.define('web.web_client', async function (require) { "use strict"; const session = require("web.session"); - const WebClient = require('web.WebClient'); + const { bus } = require('web.core'); - owl.config.mode = "dev"; + // listen to unhandled rejected promises, and when the rejection is not due + // to a crash, prevent the browser from displaying an 'unhandledrejection' + // error in the console, which would make tests crash on each Promise.reject() + // something similar is done by the CrashManagerService, but by default, it + // isn't deployed in tests + bus.on('crash_manager_unhandledrejection', this, function (ev) { + if (!ev.reason || !(ev.reason instanceof Error)) { + ev.stopPropagation(); + ev.stopImmediatePropagation(); + ev.preventDefault(); + } + }); - const webClient = new WebClient(); + owl.config.mode = "dev"; await session.is_bound; session.owlTemplates = session.owlTemplates.replace(/t-transition/g, 'transition'); - - return webClient; }); |
