mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-24 00:41:48 -05:00
initial files for license diff directive
awLicenseFeature with show/hide changed file locations changing file location adjusting controller logic to only return list of features leveraging $rootScope instead of local storage adding awFeature directive for lists/forms for activity stream button Adding route resolvers and service for getting license In order to get the license info from the API and not from local storage, the UI needs to hit hte API before loading any pages, therefore I've added route resolvers that will ensure that we have the appropriate data (license features) before navigating to a new page. I've also added the awFeature directive to the organizations list -> add-button and the ldap checkbox on the user form page. adjusting alignment fixing jshint errors commting file for testings adding tests for features service and features controller adding features controller unit test
This commit is contained in:
25
awx/ui/tests/unit/features/features.controller-test.js
Normal file
25
awx/ui/tests/unit/features/features.controller-test.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import featuresController from 'tower/shared/features/features.controller';
|
||||
|
||||
describe('featuresController', function() {
|
||||
|
||||
it('checks if a feature is enabled', inject(['$rootScope', function($rootScope) {
|
||||
var actual;
|
||||
|
||||
$rootScope.features = {
|
||||
activity_streams: true,
|
||||
ldap: false
|
||||
};
|
||||
|
||||
// TODO: extract into test controller in describeModule
|
||||
var Controller = featuresController[1];
|
||||
var controller = new Controller($rootScope);
|
||||
|
||||
actual = controller.isFeatureEnabled('activity_streams');
|
||||
expect(actual).to.be.true;
|
||||
|
||||
actual = controller.isFeatureEnabled('ldap');
|
||||
expect(actual).to.be.false;
|
||||
|
||||
|
||||
}]));
|
||||
})
|
||||
55
awx/ui/tests/unit/features/features.service-test.js
Normal file
55
awx/ui/tests/unit/features/features.service-test.js
Normal file
@@ -0,0 +1,55 @@
|
||||
import features from 'tower/shared/features/main';
|
||||
import {describeModule} from '../describe-module';
|
||||
|
||||
//test that it returns features, as well as test that it is returned in rootScope
|
||||
|
||||
describeModule(features.name)
|
||||
.testService('FeaturesService', function(test, restStub) {
|
||||
|
||||
var service;
|
||||
|
||||
test.withService(function(_service) {
|
||||
service = _service;
|
||||
});
|
||||
|
||||
it('returns list of features', function() {
|
||||
var features = {},
|
||||
result = {
|
||||
data: {
|
||||
license_info: {
|
||||
features: features
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var actual = service.get();
|
||||
|
||||
restStub.succeed(result);
|
||||
restStub.flush();
|
||||
|
||||
return expect(actual).to.eventually.equal(features);
|
||||
|
||||
});
|
||||
|
||||
it('caches in rootScope', inject(['$rootScope',
|
||||
function($rootScope){
|
||||
var features = {},
|
||||
result = {
|
||||
data: {
|
||||
license_info: {
|
||||
features: features
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var actual = service.get();
|
||||
|
||||
restStub.succeed(result);
|
||||
restStub.flush();
|
||||
|
||||
return actual.then(function(){
|
||||
expect($rootScope.features).to.equal(features);
|
||||
});
|
||||
}]));
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user