[FIX] web: tests: adapt JS tests from forward-port 9c77066f34
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.
This commit is contained in:
@@ -391,7 +391,9 @@ QUnit.module('core', {}, function () {
|
||||
return def;
|
||||
},
|
||||
},
|
||||
services: [AjaxService],
|
||||
services: {
|
||||
ajax: AjaxService
|
||||
},
|
||||
});
|
||||
var widget = new Widget(parent);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user