summaryrefslogtreecommitdiff
path: root/addons/web/static/tests
diff options
context:
space:
mode:
authorAlexandre Kühn <aku@odoo.com>2018-09-14 16:50:45 +0200
committerAlexandre Kühn <aku@odoo.com>2018-09-14 17:14:33 +0200
commit45d197c2087e61e702f288f76ccbf99bdd9b235d (patch)
tree2206c415966338f9c1d7eac51b76c641bc7ad4bd /addons/web/static/tests
parent9393a0eba88cad6184b5255a11f6a5a2996528cc (diff)
[FIX] web: tests: adapt JS tests from forward-port 9c77066f345360429a0920ca4d17af1f84a7ebea
The test was failing because it was using an old approach to mock services in JS tests. Also, it provides ajax service in the list of services, which was not supported in a mocked environment. With this commit, when an ajax service is provided in the test, it will use this service instead of using mocked RPCs from the mocked server.
Diffstat (limited to 'addons/web/static/tests')
-rw-r--r--addons/web/static/tests/core/widget_tests.js4
-rw-r--r--addons/web/static/tests/helpers/test_utils.js7
2 files changed, 8 insertions, 3 deletions
diff --git a/addons/web/static/tests/core/widget_tests.js b/addons/web/static/tests/core/widget_tests.js
index 9510079e380..f61d4a18f9b 100644
--- a/addons/web/static/tests/core/widget_tests.js
+++ b/addons/web/static/tests/core/widget_tests.js
@@ -391,7 +391,9 @@ QUnit.module('core', {}, function () {
return def;
},
},
- services: [AjaxService],
+ services: {
+ ajax: AjaxService
+ },
});
var widget = new Widget(parent);
diff --git a/addons/web/static/tests/helpers/test_utils.js b/addons/web/static/tests/helpers/test_utils.js
index 7c47bf5574a..5bf8e3d2e1b 100644
--- a/addons/web/static/tests/helpers/test_utils.js
+++ b/addons/web/static/tests/helpers/test_utils.js
@@ -494,7 +494,7 @@ function addMockEnvironment(widget, params) {
// Dispatch service calls
// Note: some services could call other services at init,
// Which is why we have to init services after that
- var services = {ajax: null}; // mocked ajax service already loaded
+ var services = {};
intercept(widget, 'call_service', function (ev) {
var args, result;
if (services[ev.data.service]) {
@@ -502,7 +502,7 @@ function addMockEnvironment(widget, params) {
args = (ev.data.args || []);
result = service[ev.data.method].apply(service, args);
} else if (ev.data.service === 'ajax') {
- // ajax service is already mocked by the server
+ // use ajax service that is mocked by the server
var route = ev.data.args[0];
args = ev.data.args[1];
result = mockServer.performRpc(route, args);
@@ -560,6 +560,9 @@ function addMockEnvironment(widget, params) {
// Deploy services
var done = false;
var servicesToDeploy = _.clone(params.services);
+ if (!servicesToDeploy.ajax) {
+ services.ajax = null; // use mocked ajax from mocked server
+ }
while (!done) {
var serviceName = _.findKey(servicesToDeploy, function (Service) {
return !_.some(Service.prototype.dependencies, function (depName) {