Files
odoo_source/addons/web/static/tests/main_tests.js
T
Aaron Bohy af85bb5e13 [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>
2020-07-13 12:55:07 +00:00

26 lines
998 B
JavaScript

// define the 'web.web_client' module because some other modules require it
odoo.define('web.web_client', async function (require) {
"use strict";
const session = require("web.session");
const { bus } = require('web.core');
// 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();
}
});
owl.config.mode = "dev";
await session.is_bound;
session.owlTemplates = session.owlTemplates.replace(/t-transition/g, 'transition');
});