mirror of
https://github.com/openMF/community-app.git
synced 2026-02-06 14:26:51 +00:00
refactored test initialization. using CORS by default if running from file system
This commit is contained in:
parent
ab42defc7d
commit
52346a28c3
@ -29,14 +29,13 @@
|
||||
var dependencies = _.reduce(_.keys(components), function(list, group) {
|
||||
return list.concat(_.map(components[group], function(name) { return group + "/" + name; }));
|
||||
}, [
|
||||
'test/test_scenario_loader',
|
||||
'test/test_realtime_demo',
|
||||
'test/testInitializer',
|
||||
'routes',
|
||||
'webstorage-configuration'
|
||||
]);
|
||||
|
||||
require(dependencies, function(test) {
|
||||
if (!test) {
|
||||
require(dependencies, function(testMode) {
|
||||
if (!testMode) {
|
||||
angular.bootstrap(document, ["MifosX_Application"]);
|
||||
}
|
||||
});
|
||||
|
||||
@ -1,17 +1,15 @@
|
||||
define(['mifosX', 'services/HttpServiceProvider', 'services/ResourceFactoryProvider'], function() {
|
||||
var regexp = /\?test_demo/;
|
||||
var match = regexp.exec(window.location.search);
|
||||
var demoBaseUrl = "https://demo.openmf.org/mifosng-provider/api/v1";
|
||||
if (match) {
|
||||
define(['mifosX', 'services/HttpServiceProvider', 'services/ResourceFactoryProvider'], {
|
||||
configure: function(url) {
|
||||
var baseUrl = url || "https://demo.openmf.org/mifosng-provider/api/v1";
|
||||
mifosX.ng.services.config(['HttpServiceProvider', 'ResourceFactoryProvider', '$httpProvider', function(httpServiceProvider, resourceFactoryProvider, httpProvider) {
|
||||
resourceFactoryProvider.setBaseUrl(demoBaseUrl);
|
||||
resourceFactoryProvider.setBaseUrl(baseUrl);
|
||||
httpServiceProvider.addRequestInterceptor('demoUrl', function(config) {
|
||||
return _.extend(config, {url: demoBaseUrl + config.url});
|
||||
return _.extend(config, {url: baseUrl + config.url});
|
||||
});
|
||||
|
||||
httpProvider.defaults.headers.common['X-Mifos-Platform-TenantId'] = 'default';
|
||||
}]).run(function($log) {
|
||||
$log.warn("Using live demo server -> " + demoBaseUrl);
|
||||
$log.warn("Using live demo server api -> " + baseUrl);
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -1,8 +1,5 @@
|
||||
define(['angular-mocks'], function() {
|
||||
var regexp = /\?test_scenario=(\w+)/;
|
||||
var match = regexp.exec(window.location.search);
|
||||
if (match) {
|
||||
var scenarioName = match[1];
|
||||
define(['mifosX', 'angular-mocks'], {
|
||||
configure: function(scenarioName) {
|
||||
require(["test/scenarios/" + scenarioName + "_scenario"], function(scenario) {
|
||||
mifosX.ng.application.config(function($provide) {
|
||||
$provide.decorator('$httpBackend', angular.mock.e2e.$httpBackendDecorator);
|
||||
@ -13,7 +10,5 @@ define(['angular-mocks'], function() {
|
||||
});
|
||||
angular.bootstrap(document, ["MifosX_Application"]);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
13
test/functional/testInitializer.js
Normal file
13
test/functional/testInitializer.js
Normal file
@ -0,0 +1,13 @@
|
||||
define(['test/demoTest', 'test/scenarioTest'], function(demoTest, scenarioTest) {
|
||||
var protocol = window.location.protocol;
|
||||
if (protocol === 'file:') {
|
||||
var match = /\?test_scenario=(\w+)/.exec(window.location.search);
|
||||
if (match) {
|
||||
scenarioTest.configure(match[1]);
|
||||
return true;
|
||||
} else {
|
||||
demoTest.configure();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user