Update node packages and styling
With the update of some linting packages, several style fixes were needed to conform with the updated style guidelines. Change-Id: If73036a6d4a3a2f6e93b15d1fa6ed3d253fdc7b1
This commit is contained in:
parent
33eb6586cf
commit
6d473eed7d
@ -57,6 +57,8 @@
|
|||||||
"no-extra-boolean-cast": 0,
|
"no-extra-boolean-cast": 0,
|
||||||
"operator-linebreak": 0,
|
"operator-linebreak": 0,
|
||||||
"require-jsdoc": 2,
|
"require-jsdoc": 2,
|
||||||
|
"quote-props": 0,
|
||||||
|
"valid-jsdoc": 0,
|
||||||
|
|
||||||
// Stylistic
|
// Stylistic
|
||||||
"indent": [2, 4, {SwitchCase: 1}],
|
"indent": [2, 4, {SwitchCase: 1}],
|
||||||
|
24
package.json
24
package.json
@ -5,24 +5,22 @@
|
|||||||
"description": "A user interface for RefStack",
|
"description": "A user interface for RefStack",
|
||||||
"license": "Apache2",
|
"license": "Apache2",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bower": "1.3.12",
|
"bower": "1.7.5",
|
||||||
"eslint": "1.5.1",
|
"eslint": "^3.0.0",
|
||||||
"eslint-config-openstack": "1.2.1",
|
"eslint-config-openstack": "4.0.1",
|
||||||
"eslint-plugin-angular": "0.12.0",
|
"eslint-plugin-angular": "1.4.0",
|
||||||
"http-server": "^0.6.1",
|
"jasmine-core": "2.8.0",
|
||||||
"karma": "^0.12.23",
|
"karma": "^1.7.1",
|
||||||
"karma-chrome-launcher": "^0.1.5",
|
"karma-chrome-launcher": "^2.2.0",
|
||||||
"karma-cli": "0.0.4",
|
"karma-cli": "1.0.1",
|
||||||
"karma-jasmine": "^0.2.2",
|
"karma-jasmine": "^1.1.0"
|
||||||
"protractor": "~1.0.0"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "bower install --config.interactive=false",
|
"postinstall": "bower install --config.interactive=false",
|
||||||
"prestart": "npm install",
|
"prestart": "npm install",
|
||||||
"start": "http-server ./refstack-ui/app -a 0.0.0.0 -p 8080",
|
|
||||||
"pretest": "npm install",
|
"pretest": "npm install",
|
||||||
"test": "karma start ./refstack-ui/tests/karma.conf.js --single-run",
|
"test": "if [ -z $CHROME_BIN ];then export CHROME_BIN=/usr/bin/chromium-browser;fi && karma start ./refstack-ui/tests/karma.conf.js --single-run",
|
||||||
"test-auto-watch": "karma start ./refstack-ui/tests/karma.conf.js --auto-watch",
|
"test-auto-watch": "if [ -z $CHROME_BIN ];then export CHROME_BIN=/usr/bin/chromium-browser;fi && karma start ./refstack-ui/tests/karma.conf.js --auto-watch",
|
||||||
"lint": "eslint -c ./.eslintrc --no-color ./refstack-ui"
|
"lint": "eslint -c ./.eslintrc --no-color ./refstack-ui"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,7 @@
|
|||||||
var hash = $location.hash();
|
var hash = $location.hash();
|
||||||
if (hash && hash in ctrl.options) {
|
if (hash && hash in ctrl.options) {
|
||||||
ctrl.selectOption(hash);
|
ctrl.selectOption(hash);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ctrl.selectOption('about');
|
ctrl.selectOption('about');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,8 +94,7 @@
|
|||||||
data.metadata.os_trademark_approval.releases;
|
data.metadata.os_trademark_approval.releases;
|
||||||
ctrl.guidelineStatus =
|
ctrl.guidelineStatus =
|
||||||
data.metadata.os_trademark_approval.status;
|
data.metadata.os_trademark_approval.status;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ctrl.schema = data.schema;
|
ctrl.schema = data.schema;
|
||||||
ctrl.criteria = data.criteria;
|
ctrl.criteria = data.criteria;
|
||||||
ctrl.releases = data.releases;
|
ctrl.releases = data.releases;
|
||||||
@ -121,6 +120,7 @@
|
|||||||
ctrl.targetCapabilities = {};
|
ctrl.targetCapabilities = {};
|
||||||
var components = ctrl.guidelines.components;
|
var components = ctrl.guidelines.components;
|
||||||
var targetCaps = ctrl.targetCapabilities;
|
var targetCaps = ctrl.targetCapabilities;
|
||||||
|
var targetComponents = null;
|
||||||
|
|
||||||
// The 'platform' target is comprised of multiple components, so
|
// The 'platform' target is comprised of multiple components, so
|
||||||
// we need to get the capabilities belonging to each of its
|
// we need to get the capabilities belonging to each of its
|
||||||
@ -133,15 +133,14 @@
|
|||||||
'object': 'OpenStack Powered Storage'
|
'object': 'OpenStack Powered Storage'
|
||||||
};
|
};
|
||||||
|
|
||||||
var targetComponents = ctrl.guidelines.platforms[
|
targetComponents = ctrl.guidelines.platforms[
|
||||||
platformsMap[ctrl.target]].components.map(
|
platformsMap[ctrl.target]].components.map(
|
||||||
function(c) {
|
function(c) {
|
||||||
return c.name;
|
return c.name;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
targetComponents = ctrl.guidelines.platform.required;
|
||||||
var targetComponents = ctrl.guidelines.platform.required;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will contain status priority values, where lower
|
// This will contain status priority values, where lower
|
||||||
@ -173,15 +172,13 @@
|
|||||||
statusMap[targetCaps[cap]]) {
|
statusMap[targetCaps[cap]]) {
|
||||||
targetCaps[cap] = status;
|
targetCaps[cap] = status;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
targetCaps[cap] = status;
|
targetCaps[cap] = status;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
angular.forEach(components[ctrl.target],
|
angular.forEach(components[ctrl.target],
|
||||||
function (caps, status) {
|
function (caps, status) {
|
||||||
angular.forEach(caps, function(cap) {
|
angular.forEach(caps, function(cap) {
|
||||||
@ -200,14 +197,14 @@
|
|||||||
*/
|
*/
|
||||||
function filterStatus(capability) {
|
function filterStatus(capability) {
|
||||||
var caps = ctrl.targetCapabilities;
|
var caps = ctrl.targetCapabilities;
|
||||||
return (ctrl.status.required &&
|
return ctrl.status.required &&
|
||||||
caps[capability.id] === 'required') ||
|
caps[capability.id] === 'required' ||
|
||||||
(ctrl.status.advisory &&
|
ctrl.status.advisory &&
|
||||||
caps[capability.id] === 'advisory') ||
|
caps[capability.id] === 'advisory' ||
|
||||||
(ctrl.status.deprecated &&
|
ctrl.status.deprecated &&
|
||||||
caps[capability.id] === 'deprecated') ||
|
caps[capability.id] === 'deprecated' ||
|
||||||
(ctrl.status.removed &&
|
ctrl.status.removed &&
|
||||||
caps[capability.id] === 'removed');
|
caps[capability.id] === 'removed';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -282,8 +279,7 @@
|
|||||||
// Check if the API URL is absolute or relative.
|
// Check if the API URL is absolute or relative.
|
||||||
if (refstackApiUrl.indexOf('http') > -1) {
|
if (refstackApiUrl.indexOf('http') > -1) {
|
||||||
ctrl.url = refstackApiUrl;
|
ctrl.url = refstackApiUrl;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ctrl.url = location.protocol + '//' + location.host +
|
ctrl.url = location.protocol + '//' + location.host +
|
||||||
refstackApiUrl;
|
refstackApiUrl;
|
||||||
}
|
}
|
||||||
@ -333,8 +329,7 @@
|
|||||||
ctrl.testListString = response.data;
|
ctrl.testListString = response.data;
|
||||||
if (!ctrl.testListString) {
|
if (!ctrl.testListString) {
|
||||||
ctrl.testListCount = 0;
|
ctrl.testListCount = 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ctrl.testListCount =
|
ctrl.testListCount =
|
||||||
ctrl.testListString.split('\n').length;
|
ctrl.testListString.split('\n').length;
|
||||||
}
|
}
|
||||||
@ -345,8 +340,7 @@
|
|||||||
response.data.message) {
|
response.data.message) {
|
||||||
ctrl.error = 'Error retrieving test list: ' +
|
ctrl.error = 'Error retrieving test list: ' +
|
||||||
response.data.message;
|
response.data.message;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ctrl.error = 'Unknown error retrieving test list.';
|
ctrl.error = 'Unknown error retrieving test list.';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -232,8 +232,7 @@
|
|||||||
}).error(function (error) {
|
}).error(function (error) {
|
||||||
raiseAlert('danger', error.title, error.detail);
|
raiseAlert('danger', error.title, error.detail);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ctrl.unassociateRequest = $http.delete(metaUrl)
|
ctrl.unassociateRequest = $http.delete(metaUrl)
|
||||||
.success(function () {
|
.success(function () {
|
||||||
ctrl.testsData[index][editFlag] = false;
|
ctrl.testsData[index][editFlag] = false;
|
||||||
@ -446,8 +445,8 @@
|
|||||||
var url = [refstackApiUrl, '/products/', ctrl.product.id].join('');
|
var url = [refstackApiUrl, '/products/', ctrl.product.id].join('');
|
||||||
var properties = propertiesToJson();
|
var properties = propertiesToJson();
|
||||||
var content = {'description': ctrl.product.description,
|
var content = {'description': ctrl.product.description,
|
||||||
'properties': properties};
|
'properties': properties};
|
||||||
if (ctrl.productName != ctrl.product.name) {
|
if (ctrl.productName !== ctrl.product.name) {
|
||||||
content.name = ctrl.product.name;
|
content.name = ctrl.product.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,8 +467,7 @@
|
|||||||
ctrl.showError = true;
|
ctrl.showError = true;
|
||||||
ctrl.error = error.detail;
|
ctrl.error = error.detail;
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ctrl.showSuccess = true;
|
ctrl.showSuccess = true;
|
||||||
$state.reload();
|
$state.reload();
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,14 @@
|
|||||||
.controller('ProductsController', ProductsController);
|
.controller('ProductsController', ProductsController);
|
||||||
|
|
||||||
ProductsController.$inject = [
|
ProductsController.$inject = [
|
||||||
'$rootScope', '$scope', '$http', '$state',
|
'$rootScope', '$scope', '$http', '$state', 'refstackApiUrl'
|
||||||
'refstackApiUrl','raiseAlert'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RefStack Products Controller
|
* RefStack Products Controller
|
||||||
*/
|
*/
|
||||||
function ProductsController($rootScope, $scope, $http, $state,
|
function ProductsController($rootScope, $scope, $http, $state,
|
||||||
refstackApiUrl, raiseAlert) {
|
refstackApiUrl) {
|
||||||
var ctrl = this;
|
var ctrl = this;
|
||||||
|
|
||||||
ctrl.update = update;
|
ctrl.update = update;
|
||||||
@ -82,7 +81,7 @@
|
|||||||
ctrl.showError = false;
|
ctrl.showError = false;
|
||||||
// Construct the API URL based on user-specified filters.
|
// Construct the API URL based on user-specified filters.
|
||||||
var contentUrl = refstackApiUrl + '/products';
|
var contentUrl = refstackApiUrl + '/products';
|
||||||
if (typeof ctrl.rawData == 'undefined'
|
if (typeof ctrl.rawData === 'undefined'
|
||||||
|| ctrl.rawData === null) {
|
|| ctrl.rawData === null) {
|
||||||
ctrl.productsRequest =
|
ctrl.productsRequest =
|
||||||
$http.get(contentUrl).success(function (data) {
|
$http.get(contentUrl).success(function (data) {
|
||||||
@ -106,7 +105,8 @@
|
|||||||
function updateData() {
|
function updateData() {
|
||||||
ctrl.data = {};
|
ctrl.data = {};
|
||||||
ctrl.data.products = ctrl.rawData.products.filter(function(s) {
|
ctrl.data.products = ctrl.rawData.products.filter(function(s) {
|
||||||
return ctrl._filterProduct(s); });
|
return ctrl._filterProduct(s);
|
||||||
|
});
|
||||||
ctrl.data.products.sort(function(a, b) {
|
ctrl.data.products.sort(function(a, b) {
|
||||||
return a.name.localeCompare(b.name);
|
return a.name.localeCompare(b.name);
|
||||||
});
|
});
|
||||||
@ -165,7 +165,7 @@
|
|||||||
ctrl.vendors.sort(function(a, b) {
|
ctrl.vendors.sort(function(a, b) {
|
||||||
return a.name.localeCompare(b.name);
|
return a.name.localeCompare(b.name);
|
||||||
});
|
});
|
||||||
if (ctrl.vendors.length == 0) {
|
if (ctrl.vendors.length === 0) {
|
||||||
ctrl.vendors.push({name: 'Create New...', id: ''});
|
ctrl.vendors.push({name: 'Create New...', id: ''});
|
||||||
}
|
}
|
||||||
ctrl.organizationId = ctrl.vendors[0].id;
|
ctrl.organizationId = ctrl.vendors[0].id;
|
||||||
@ -189,9 +189,9 @@
|
|||||||
name: ctrl.name,
|
name: ctrl.name,
|
||||||
description: ctrl.description,
|
description: ctrl.description,
|
||||||
organization_id: ctrl.organizationId,
|
organization_id: ctrl.organizationId,
|
||||||
product_type: parseInt(ctrl.productType)
|
product_type: parseInt(ctrl.productType, 10)
|
||||||
};
|
};
|
||||||
$http.post(url, data).success(function (data) {
|
$http.post(url, data).success(function () {
|
||||||
ctrl.rawData = null;
|
ctrl.rawData = null;
|
||||||
ctrl.showSuccess = true;
|
ctrl.showSuccess = true;
|
||||||
ctrl.name = '';
|
ctrl.name = '';
|
||||||
|
@ -234,8 +234,7 @@
|
|||||||
data.metadata.os_trademark_approval.status;
|
data.metadata.os_trademark_approval.status;
|
||||||
ctrl.releases =
|
ctrl.releases =
|
||||||
data.metadata.os_trademark_approval.releases;
|
data.metadata.os_trademark_approval.releases;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ctrl.schemaVersion = data.schema;
|
ctrl.schemaVersion = data.schema;
|
||||||
ctrl.guidelineStatus = data.status;
|
ctrl.guidelineStatus = data.status;
|
||||||
ctrl.releases = data.releases;
|
ctrl.releases = data.releases;
|
||||||
@ -257,6 +256,7 @@
|
|||||||
function getTargetCapabilities() {
|
function getTargetCapabilities() {
|
||||||
var components = ctrl.guidelineData.components;
|
var components = ctrl.guidelineData.components;
|
||||||
var targetCaps = {};
|
var targetCaps = {};
|
||||||
|
var targetComponents = null;
|
||||||
|
|
||||||
// The 'platform' target is comprised of multiple components, so
|
// The 'platform' target is comprised of multiple components, so
|
||||||
// we need to get the capabilities belonging to each of its
|
// we need to get the capabilities belonging to each of its
|
||||||
@ -269,15 +269,14 @@
|
|||||||
'object': 'OpenStack Powered Storage'
|
'object': 'OpenStack Powered Storage'
|
||||||
};
|
};
|
||||||
|
|
||||||
var targetComponents = ctrl.guidelineData.platforms[
|
targetComponents = ctrl.guidelineData.platforms[
|
||||||
platformsMap[ctrl.target]].components.map(
|
platformsMap[ctrl.target]].components.map(
|
||||||
function(c) {
|
function(c) {
|
||||||
return c.name;
|
return c.name;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
targetComponents = ctrl.guidelineData.platform.required;
|
||||||
var targetComponents = ctrl.guidelineData.platform.required;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will contain status priority values, where lower
|
// This will contain status priority values, where lower
|
||||||
@ -309,15 +308,13 @@
|
|||||||
statusMap[targetCaps[cap]]) {
|
statusMap[targetCaps[cap]]) {
|
||||||
targetCaps[cap] = status;
|
targetCaps[cap] = status;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
targetCaps[cap] = status;
|
targetCaps[cap] = status;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
angular.forEach(components[ctrl.target],
|
angular.forEach(components[ctrl.target],
|
||||||
function (caps, status) {
|
function (caps, status) {
|
||||||
angular.forEach(caps, function(cap) {
|
angular.forEach(caps, function(cap) {
|
||||||
@ -353,8 +350,7 @@
|
|||||||
if (capDetails.flagged.indexOf(testId) > -1) {
|
if (capDetails.flagged.indexOf(testId) > -1) {
|
||||||
cap.passedFlagged.push(testId);
|
cap.passedFlagged.push(testId);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
cap.notPassedTests.push(testId);
|
cap.notPassedTests.push(testId);
|
||||||
if (capDetails.flagged.indexOf(testId) > -1) {
|
if (capDetails.flagged.indexOf(testId) > -1) {
|
||||||
cap.notPassedFlagged.push(testId);
|
cap.notPassedFlagged.push(testId);
|
||||||
@ -393,8 +389,7 @@
|
|||||||
// If the test ID is in the results' test list.
|
// If the test ID is in the results' test list.
|
||||||
if (ctrl.resultsData.results.indexOf(testId) > -1) {
|
if (ctrl.resultsData.results.indexOf(testId) > -1) {
|
||||||
passed = true;
|
passed = true;
|
||||||
}
|
} else if ('aliases' in details) {
|
||||||
else if ('aliases' in details) {
|
|
||||||
var len = details.aliases.length;
|
var len = details.aliases.length;
|
||||||
for (var i = 0; i < len; i++) {
|
for (var i = 0; i < len; i++) {
|
||||||
var alias = details.aliases[i];
|
var alias = details.aliases[i];
|
||||||
@ -412,8 +407,7 @@
|
|||||||
if ('flagged' in details) {
|
if ('flagged' in details) {
|
||||||
cap.passedFlagged.push(testId);
|
cap.passedFlagged.push(testId);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
cap.notPassedTests.push(testId);
|
cap.notPassedTests.push(testId);
|
||||||
if ('flagged' in details) {
|
if ('flagged' in details) {
|
||||||
cap.notPassedFlagged.push(testId);
|
cap.notPassedFlagged.push(testId);
|
||||||
@ -435,18 +429,19 @@
|
|||||||
// objects with details regarding each capability.
|
// objects with details regarding each capability.
|
||||||
ctrl.caps = {
|
ctrl.caps = {
|
||||||
'required': {'caps': [], 'count': 0, 'passedCount': 0,
|
'required': {'caps': [], 'count': 0, 'passedCount': 0,
|
||||||
'flagFailCount': 0, 'flagPassCount': 0},
|
'flagFailCount': 0, 'flagPassCount': 0},
|
||||||
'advisory': {'caps': [], 'count': 0, 'passedCount': 0,
|
'advisory': {'caps': [], 'count': 0, 'passedCount': 0,
|
||||||
'flagFailCount': 0, 'flagPassCount': 0},
|
'flagFailCount': 0, 'flagPassCount': 0},
|
||||||
'deprecated': {'caps': [], 'count': 0, 'passedCount': 0,
|
'deprecated': {'caps': [], 'count': 0, 'passedCount': 0,
|
||||||
'flagFailCount': 0, 'flagPassCount': 0},
|
'flagFailCount': 0, 'flagPassCount': 0},
|
||||||
'removed': {'caps': [], 'count': 0, 'passedCount': 0,
|
'removed': {'caps': [], 'count': 0, 'passedCount': 0,
|
||||||
'flagFailCount': 0, 'flagPassCount': 0}
|
'flagFailCount': 0, 'flagPassCount': 0}
|
||||||
};
|
};
|
||||||
|
var capMethod = null;
|
||||||
|
|
||||||
switch (ctrl.schemaVersion) {
|
switch (ctrl.schemaVersion) {
|
||||||
case '1.2':
|
case '1.2':
|
||||||
var capMethod = 'buildCapabilityV1_2';
|
capMethod = 'buildCapabilityV1_2';
|
||||||
break;
|
break;
|
||||||
case '1.3':
|
case '1.3':
|
||||||
case '1.4':
|
case '1.4':
|
||||||
@ -478,8 +473,8 @@
|
|||||||
ctrl.caps[status].caps.push(cap);
|
ctrl.caps[status].caps.push(cap);
|
||||||
});
|
});
|
||||||
|
|
||||||
ctrl.requiredPassPercent = (ctrl.caps.required.passedCount *
|
ctrl.requiredPassPercent = ctrl.caps.required.passedCount *
|
||||||
100 / ctrl.caps.required.count);
|
100 / ctrl.caps.required.count;
|
||||||
|
|
||||||
ctrl.totalRequiredFailCount = ctrl.caps.required.count -
|
ctrl.totalRequiredFailCount = ctrl.caps.required.count -
|
||||||
ctrl.caps.required.passedCount;
|
ctrl.caps.required.passedCount;
|
||||||
@ -492,8 +487,8 @@
|
|||||||
(ctrl.totalRequiredFailCount -
|
(ctrl.totalRequiredFailCount -
|
||||||
ctrl.caps.required.flagFailCount);
|
ctrl.caps.required.flagFailCount);
|
||||||
|
|
||||||
ctrl.nonFlagRequiredPassPercent = (ctrl.nonFlagPassCount *
|
ctrl.nonFlagRequiredPassPercent = ctrl.nonFlagPassCount *
|
||||||
100 / ctrl.totalNonFlagCount);
|
100 / ctrl.totalNonFlagCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -506,10 +501,10 @@
|
|||||||
if (!capObj) {
|
if (!capObj) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (((ctrl.schemaVersion === '1.2') &&
|
return ctrl.schemaVersion === '1.2' &&
|
||||||
(capObj.flagged.indexOf(test) > -1)) ||
|
capObj.flagged.indexOf(test) > -1 ||
|
||||||
((ctrl.schemaVersion >= '1.3') &&
|
ctrl.schemaVersion >= '1.3' &&
|
||||||
(capObj.tests[test].flagged)));
|
capObj.tests[test].flagged;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -520,19 +515,17 @@
|
|||||||
* @returns {String} reason
|
* @returns {String} reason
|
||||||
*/
|
*/
|
||||||
function getFlaggedReason(test, capObj) {
|
function getFlaggedReason(test, capObj) {
|
||||||
if ((ctrl.schemaVersion === '1.2') &&
|
if (ctrl.schemaVersion === '1.2' &&
|
||||||
(ctrl.isTestFlagged(test, capObj))) {
|
ctrl.isTestFlagged(test, capObj)) {
|
||||||
|
|
||||||
// Return a generic message since schema 1.2 does not
|
// Return a generic message since schema 1.2 does not
|
||||||
// provide flag reasons.
|
// provide flag reasons.
|
||||||
return 'Interop Working Group has flagged this test.';
|
return 'Interop Working Group has flagged this test.';
|
||||||
}
|
} else if (ctrl.schemaVersion >= '1.3' &&
|
||||||
else if ((ctrl.schemaVersion >= '1.3') &&
|
ctrl.isTestFlagged(test, capObj)) {
|
||||||
(ctrl.isTestFlagged(test, capObj))) {
|
|
||||||
|
|
||||||
return capObj.tests[test].flagged.reason;
|
return capObj.tests[test].flagged.reason;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -545,14 +538,14 @@
|
|||||||
* @returns {Boolean} true if capability should be shown
|
* @returns {Boolean} true if capability should be shown
|
||||||
*/
|
*/
|
||||||
function isCapabilityShown(capability) {
|
function isCapabilityShown(capability) {
|
||||||
return ((ctrl.testStatus === 'total') ||
|
return ctrl.testStatus === 'total' ||
|
||||||
(ctrl.testStatus === 'passed' &&
|
ctrl.testStatus === 'passed' &&
|
||||||
capability.passedTests.length > 0) ||
|
capability.passedTests.length > 0 ||
|
||||||
(ctrl.testStatus === 'not passed' &&
|
ctrl.testStatus === 'not passed' &&
|
||||||
capability.notPassedTests.length > 0) ||
|
capability.notPassedTests.length > 0 ||
|
||||||
(ctrl.testStatus === 'flagged' &&
|
ctrl.testStatus === 'flagged' &&
|
||||||
(capability.passedFlagged.length +
|
capability.passedFlagged.length +
|
||||||
capability.notPassedFlagged.length > 0)));
|
capability.notPassedFlagged.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -563,14 +556,14 @@
|
|||||||
* @return {Boolean} true if test should be shown
|
* @return {Boolean} true if test should be shown
|
||||||
*/
|
*/
|
||||||
function isTestShown(test, capability) {
|
function isTestShown(test, capability) {
|
||||||
return ((ctrl.testStatus === 'total') ||
|
return ctrl.testStatus === 'total' ||
|
||||||
(ctrl.testStatus === 'passed' &&
|
ctrl.testStatus === 'passed' &&
|
||||||
capability.passedTests.indexOf(test) > -1) ||
|
capability.passedTests.indexOf(test) > -1 ||
|
||||||
(ctrl.testStatus === 'not passed' &&
|
ctrl.testStatus === 'not passed' &&
|
||||||
capability.notPassedTests.indexOf(test) > -1) ||
|
capability.notPassedTests.indexOf(test) > -1 ||
|
||||||
(ctrl.testStatus === 'flagged' &&
|
ctrl.testStatus === 'flagged' &&
|
||||||
(capability.passedFlagged.indexOf(test) > -1 ||
|
(capability.passedFlagged.indexOf(test) > -1 ||
|
||||||
capability.notPassedFlagged.indexOf(test) > -1)));
|
capability.notPassedFlagged.indexOf(test) > -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -583,18 +576,14 @@
|
|||||||
if (ctrl.testStatus === 'total') {
|
if (ctrl.testStatus === 'total') {
|
||||||
return capability.passedTests.length +
|
return capability.passedTests.length +
|
||||||
capability.notPassedTests.length;
|
capability.notPassedTests.length;
|
||||||
}
|
} else if (ctrl.testStatus === 'passed') {
|
||||||
else if (ctrl.testStatus === 'passed') {
|
|
||||||
return capability.passedTests.length;
|
return capability.passedTests.length;
|
||||||
}
|
} else if (ctrl.testStatus === 'not passed') {
|
||||||
else if (ctrl.testStatus === 'not passed') {
|
|
||||||
return capability.notPassedTests.length;
|
return capability.notPassedTests.length;
|
||||||
}
|
} else if (ctrl.testStatus === 'flagged') {
|
||||||
else if (ctrl.testStatus === 'flagged') {
|
|
||||||
return capability.passedFlagged.length +
|
return capability.passedFlagged.length +
|
||||||
capability.notPassedFlagged.length;
|
capability.notPassedFlagged.length;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -608,22 +597,17 @@
|
|||||||
function getStatusTestCount(status) {
|
function getStatusTestCount(status) {
|
||||||
if (!ctrl.caps) {
|
if (!ctrl.caps) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
} else if (ctrl.testStatus === 'total') {
|
||||||
else if (ctrl.testStatus === 'total') {
|
|
||||||
return ctrl.caps[status].count;
|
return ctrl.caps[status].count;
|
||||||
}
|
} else if (ctrl.testStatus === 'passed') {
|
||||||
else if (ctrl.testStatus === 'passed') {
|
|
||||||
return ctrl.caps[status].passedCount;
|
return ctrl.caps[status].passedCount;
|
||||||
}
|
} else if (ctrl.testStatus === 'not passed') {
|
||||||
else if (ctrl.testStatus === 'not passed') {
|
|
||||||
return ctrl.caps[status].count -
|
return ctrl.caps[status].count -
|
||||||
ctrl.caps[status].passedCount;
|
ctrl.caps[status].passedCount;
|
||||||
}
|
} else if (ctrl.testStatus === 'flagged') {
|
||||||
else if (ctrl.testStatus === 'flagged') {
|
|
||||||
return ctrl.caps[status].flagFailCount +
|
return ctrl.caps[status].flagFailCount +
|
||||||
ctrl.caps[status].flagPassCount;
|
ctrl.caps[status].flagPassCount;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -791,8 +775,8 @@
|
|||||||
* a test result.
|
* a test result.
|
||||||
*/
|
*/
|
||||||
function associateProductVersion() {
|
function associateProductVersion() {
|
||||||
var verId = (ctrl.selectedVersion ?
|
var verId = ctrl.selectedVersion ?
|
||||||
ctrl.selectedVersion.id : null);
|
ctrl.selectedVersion.id : null;
|
||||||
var testId = resultsData.id;
|
var testId = resultsData.id;
|
||||||
var url = refstackApiUrl + '/results/' + testId;
|
var url = refstackApiUrl + '/results/' + testId;
|
||||||
ctrl.associateRequest = $http.put(url, {'product_version_id':
|
ctrl.associateRequest = $http.put(url, {'product_version_id':
|
||||||
@ -822,11 +806,10 @@
|
|||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
ctrl.productVersions = data;
|
ctrl.productVersions = data;
|
||||||
if (ctrl.prodVersionCopy &&
|
if (ctrl.prodVersionCopy &&
|
||||||
ctrl.prodVersionCopy.product_info.id ==
|
ctrl.prodVersionCopy.product_info.id ===
|
||||||
ctrl.selectedProduct.id) {
|
ctrl.selectedProduct.id) {
|
||||||
ctrl.selectedVersion = ctrl.prodVersionCopy;
|
ctrl.selectedVersion = ctrl.prodVersionCopy;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
angular.forEach(data, function(ver) {
|
angular.forEach(data, function(ver) {
|
||||||
if (!ver.version) {
|
if (!ver.version) {
|
||||||
ctrl.selectedVersion = ver;
|
ctrl.selectedVersion = ver;
|
||||||
@ -850,13 +833,13 @@
|
|||||||
var metaFields = ['target', 'guideline', 'shared'];
|
var metaFields = ['target', 'guideline', 'shared'];
|
||||||
var meta = ctrl.metaCopy;
|
var meta = ctrl.metaCopy;
|
||||||
angular.forEach(metaFields, function(field) {
|
angular.forEach(metaFields, function(field) {
|
||||||
var oldMetaValue = (field in ctrl.resultsData.meta) ?
|
var oldMetaValue = field in ctrl.resultsData.meta ?
|
||||||
ctrl.resultsData.meta[field] : '';
|
ctrl.resultsData.meta[field] : '';
|
||||||
if (field in meta && oldMetaValue != meta[field]) {
|
if (field in meta && oldMetaValue !== meta[field]) {
|
||||||
var metaUrl = metaBaseUrl + field;
|
var metaUrl = metaBaseUrl + field;
|
||||||
if (meta[field]) {
|
if (meta[field]) {
|
||||||
ctrl.assocRequest = $http.post(metaUrl, meta[field])
|
ctrl.assocRequest = $http.post(metaUrl, meta[field])
|
||||||
.success(function(data) {
|
.success(function() {
|
||||||
ctrl.resultsData.meta[field] = meta[field];
|
ctrl.resultsData.meta[field] = meta[field];
|
||||||
})
|
})
|
||||||
.error(function (error) {
|
.error(function (error) {
|
||||||
@ -866,10 +849,9 @@
|
|||||||
'Error associating metadata with ' +
|
'Error associating metadata with ' +
|
||||||
'test run: ' + angular.toJson(error);
|
'test run: ' + angular.toJson(error);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ctrl.unassocRequest = $http.delete(metaUrl)
|
ctrl.unassocRequest = $http.delete(metaUrl)
|
||||||
.success(function (data) {
|
.success(function () {
|
||||||
delete ctrl.resultsData.meta[field];
|
delete ctrl.resultsData.meta[field];
|
||||||
delete meta[field];
|
delete meta[field];
|
||||||
})
|
})
|
||||||
|
@ -183,18 +183,16 @@
|
|||||||
}).error(function (error) {
|
}).error(function (error) {
|
||||||
raiseAlert('danger', error.title, error.detail);
|
raiseAlert('danger', error.title, error.detail);
|
||||||
});
|
});
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
ctrl.unassociateRequest = $http.delete(metaUrl)
|
ctrl.unassociateRequest = $http.delete(metaUrl)
|
||||||
.success(function () {
|
.success(function () {
|
||||||
ctrl.data.results[index][editFlag] = false;
|
ctrl.data.results[index][editFlag] = false;
|
||||||
}).error(function (error) {
|
}).error(function (error) {
|
||||||
if (error.code == 404) {
|
if (error.code === 404) {
|
||||||
// Key doesn't exist, so count it as a success,
|
// Key doesn't exist, so count it as a success,
|
||||||
// and don't raise an alert.
|
// and don't raise an alert.
|
||||||
ctrl.data.results[index][editFlag] = false;
|
ctrl.data.results[index][editFlag] = false;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
raiseAlert('danger', error.title, error.detail);
|
raiseAlert('danger', error.title, error.detail);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -273,13 +271,13 @@
|
|||||||
* a test result.
|
* a test result.
|
||||||
*/
|
*/
|
||||||
function associateProductVersion(result) {
|
function associateProductVersion(result) {
|
||||||
var verId = (result.selectedVersion ?
|
var verId = result.selectedVersion ?
|
||||||
result.selectedVersion.id : null);
|
result.selectedVersion.id : null;
|
||||||
var testId = result.id;
|
var testId = result.id;
|
||||||
var url = refstackApiUrl + '/results/' + testId;
|
var url = refstackApiUrl + '/results/' + testId;
|
||||||
ctrl.associateRequest = $http.put(url, {'product_version_id':
|
ctrl.associateRequest = $http.put(url, {'product_version_id':
|
||||||
verId})
|
verId})
|
||||||
.success(function (data) {
|
.success(function () {
|
||||||
result.product_version = result.selectedVersion;
|
result.product_version = result.selectedVersion;
|
||||||
if (result.selectedVersion) {
|
if (result.selectedVersion) {
|
||||||
result.product_version.product_info =
|
result.product_version.product_info =
|
||||||
|
@ -70,10 +70,10 @@
|
|||||||
ctrl.vendor = data;
|
ctrl.vendor = data;
|
||||||
var isAdmin = $rootScope.auth.currentUser.is_admin;
|
var isAdmin = $rootScope.auth.currentUser.is_admin;
|
||||||
ctrl.vendor.canDelete = ctrl.vendor.canEdit =
|
ctrl.vendor.canDelete = ctrl.vendor.canEdit =
|
||||||
ctrl.vendor.type != 0
|
ctrl.vendor.type !== 0
|
||||||
&& (ctrl.vendor.can_manage || isAdmin);
|
&& (ctrl.vendor.can_manage || isAdmin);
|
||||||
ctrl.vendor.canRegister =
|
ctrl.vendor.canRegister =
|
||||||
ctrl.vendor.type == 1;
|
ctrl.vendor.type === 1;
|
||||||
ctrl.vendor.canApprove = isAdmin;
|
ctrl.vendor.canApprove = isAdmin;
|
||||||
ctrl.vendorProperties = angular.fromJson(data.properties);
|
ctrl.vendorProperties = angular.fromJson(data.properties);
|
||||||
}).error(function(error) {
|
}).error(function(error) {
|
||||||
@ -89,7 +89,7 @@
|
|||||||
*/
|
*/
|
||||||
function registerVendor() {
|
function registerVendor() {
|
||||||
var url = [refstackApiUrl, '/vendors/', ctrl.vendorId,
|
var url = [refstackApiUrl, '/vendors/', ctrl.vendorId,
|
||||||
'/action'].join('');
|
'/action'].join('');
|
||||||
$http.post(url, {register: null}).success(function() {
|
$http.post(url, {register: null}).success(function() {
|
||||||
ctrl.getVendor();
|
ctrl.getVendor();
|
||||||
}).error(function(error) {
|
}).error(function(error) {
|
||||||
@ -102,7 +102,7 @@
|
|||||||
*/
|
*/
|
||||||
function approveVendor() {
|
function approveVendor() {
|
||||||
var url = [refstackApiUrl, '/vendors/', ctrl.vendorId,
|
var url = [refstackApiUrl, '/vendors/', ctrl.vendorId,
|
||||||
'/action'].join('');
|
'/action'].join('');
|
||||||
$http.post(url, {approve: null}).success(function() {
|
$http.post(url, {approve: null}).success(function() {
|
||||||
ctrl.getVendor();
|
ctrl.getVendor();
|
||||||
}).error(function(error) {
|
}).error(function(error) {
|
||||||
@ -116,7 +116,7 @@
|
|||||||
function declineVendor() {
|
function declineVendor() {
|
||||||
confirmModal('Please input decline reason', function(reason) {
|
confirmModal('Please input decline reason', function(reason) {
|
||||||
var url = [refstackApiUrl, '/vendors/', ctrl.vendorId,
|
var url = [refstackApiUrl, '/vendors/', ctrl.vendorId,
|
||||||
'/action'].join('');
|
'/action'].join('');
|
||||||
var content = {deny: null, registration_decline_reason: reason};
|
var content = {deny: null, registration_decline_reason: reason};
|
||||||
$http.post(url, content).success(
|
$http.post(url, content).success(
|
||||||
function() {
|
function() {
|
||||||
@ -198,7 +198,7 @@
|
|||||||
*/
|
*/
|
||||||
function removeUserFromVendor(openid) {
|
function removeUserFromVendor(openid) {
|
||||||
var url = [refstackApiUrl, '/vendors/', ctrl.vendorId,
|
var url = [refstackApiUrl, '/vendors/', ctrl.vendorId,
|
||||||
'/users/', btoa(openid)].join('');
|
'/users/', btoa(openid)].join('');
|
||||||
$http.delete(url).success(function () {
|
$http.delete(url).success(function () {
|
||||||
ctrl.getVendorUsers();
|
ctrl.getVendorUsers();
|
||||||
}).error(function (error) {
|
}).error(function (error) {
|
||||||
@ -212,7 +212,7 @@
|
|||||||
*/
|
*/
|
||||||
function addUserToVendor(openid) {
|
function addUserToVendor(openid) {
|
||||||
var url = [refstackApiUrl, '/vendors/', ctrl.vendorId,
|
var url = [refstackApiUrl, '/vendors/', ctrl.vendorId,
|
||||||
'/users/', btoa(openid)].join('');
|
'/users/', btoa(openid)].join('');
|
||||||
$http.put(url).success(function() {
|
$http.put(url).success(function() {
|
||||||
ctrl.userToAdd = '';
|
ctrl.userToAdd = '';
|
||||||
ctrl.getVendorUsers();
|
ctrl.getVendorUsers();
|
||||||
@ -298,8 +298,8 @@
|
|||||||
var url = [refstackApiUrl, '/vendors/', ctrl.vendor.id].join('');
|
var url = [refstackApiUrl, '/vendors/', ctrl.vendor.id].join('');
|
||||||
var properties = propertiesToJson();
|
var properties = propertiesToJson();
|
||||||
var content = {'description': ctrl.vendor.description,
|
var content = {'description': ctrl.vendor.description,
|
||||||
'properties': properties};
|
'properties': properties};
|
||||||
if (ctrl.vendorName != ctrl.vendor.name) {
|
if (ctrl.vendorName !== ctrl.vendor.name) {
|
||||||
content.name = ctrl.vendor.name;
|
content.name = ctrl.vendor.name;
|
||||||
}
|
}
|
||||||
$http.put(url, content).success(function() {
|
$http.put(url, content).success(function() {
|
||||||
|
@ -20,9 +20,7 @@
|
|||||||
.controller('VendorsController', VendorsController);
|
.controller('VendorsController', VendorsController);
|
||||||
|
|
||||||
VendorsController.$inject = [
|
VendorsController.$inject = [
|
||||||
'$rootScope', '$scope', '$http', '$state',
|
'$rootScope', '$scope', '$http', '$state', 'refstackApiUrl'];
|
||||||
'refstackApiUrl','raiseAlert'
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RefStack Vendors Controller
|
* RefStack Vendors Controller
|
||||||
@ -30,7 +28,7 @@
|
|||||||
* where a user can browse a listing of his/her vendors or public vendors.
|
* where a user can browse a listing of his/her vendors or public vendors.
|
||||||
*/
|
*/
|
||||||
function VendorsController($rootScope, $scope, $http, $state,
|
function VendorsController($rootScope, $scope, $http, $state,
|
||||||
refstackApiUrl, raiseAlert) {
|
refstackApiUrl) {
|
||||||
var ctrl = this;
|
var ctrl = this;
|
||||||
|
|
||||||
ctrl.update = update;
|
ctrl.update = update;
|
||||||
@ -81,7 +79,7 @@
|
|||||||
ctrl.data = null;
|
ctrl.data = null;
|
||||||
// Construct the API URL based on user-specified filters.
|
// Construct the API URL based on user-specified filters.
|
||||||
var contentUrl = refstackApiUrl + '/vendors';
|
var contentUrl = refstackApiUrl + '/vendors';
|
||||||
if (typeof ctrl.rawData == 'undefined'
|
if (typeof ctrl.rawData === 'undefined'
|
||||||
|| ctrl.rawData === null) {
|
|| ctrl.rawData === null) {
|
||||||
ctrl.vendorsRequest =
|
ctrl.vendorsRequest =
|
||||||
$http.get(contentUrl).success(function (data) {
|
$http.get(contentUrl).success(function (data) {
|
||||||
@ -123,7 +121,7 @@
|
|||||||
*/
|
*/
|
||||||
function _filterVendor(vendor) {
|
function _filterVendor(vendor) {
|
||||||
if (!ctrl.isUserVendors) {
|
if (!ctrl.isUserVendors) {
|
||||||
return (vendor.type == 0 || vendor.type == 3);
|
return vendor.type === 0 || vendor.type === 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$rootScope.auth || !$rootScope.auth.currentUser) {
|
if (!$rootScope.auth || !$rootScope.auth.currentUser) {
|
||||||
@ -131,7 +129,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($rootScope.auth.currentUser.is_admin) {
|
if ($rootScope.auth.currentUser.is_admin) {
|
||||||
return vendor.type != 1 || ctrl.withPrivate;
|
return vendor.type !== 1 || ctrl.withPrivate;
|
||||||
}
|
}
|
||||||
|
|
||||||
return vendor.can_manage;
|
return vendor.can_manage;
|
||||||
@ -148,7 +146,7 @@
|
|||||||
name: ctrl.name,
|
name: ctrl.name,
|
||||||
description: ctrl.description
|
description: ctrl.description
|
||||||
};
|
};
|
||||||
$http.post(url, data).success(function (data) {
|
$http.post(url, data).success(function () {
|
||||||
ctrl.showSuccess = true;
|
ctrl.showSuccess = true;
|
||||||
ctrl.name = '';
|
ctrl.name = '';
|
||||||
ctrl.description = '';
|
ctrl.description = '';
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
if (path === viewLocation) {
|
if (path === viewLocation) {
|
||||||
// Make sure "/" only matches when viewLocation is "/".
|
// Make sure "/" only matches when viewLocation is "/".
|
||||||
if (!($location.path().substr(0).length > 1 &&
|
if (!($location.path().substr(0).length > 1 &&
|
||||||
viewLocation.length === 1 )) {
|
viewLocation.length === 1)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ module.exports = function (config) {
|
|||||||
'app/components/**/*.js',
|
'app/components/**/*.js',
|
||||||
'app/shared/*.js',
|
'app/shared/*.js',
|
||||||
'app/shared/**/*.js',
|
'app/shared/**/*.js',
|
||||||
'app/assets/js/*.js',
|
|
||||||
|
|
||||||
// Test Specs.
|
// Test Specs.
|
||||||
'tests/unit/*.js'
|
'tests/unit/*.js'
|
||||||
|
@ -20,8 +20,8 @@ describe('Auth', function () {
|
|||||||
it('should show signin url for signed user', function () {
|
it('should show signin url for signed user', function () {
|
||||||
$httpBackend.expectGET(fakeApiUrl +
|
$httpBackend.expectGET(fakeApiUrl +
|
||||||
'/profile').respond({'openid': 'foo@bar.com',
|
'/profile').respond({'openid': 'foo@bar.com',
|
||||||
'email': 'foo@bar.com',
|
'email': 'foo@bar.com',
|
||||||
'fullname': 'foo' });
|
'fullname': 'foo' });
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
$rootScope.auth.doSignIn();
|
$rootScope.auth.doSignIn();
|
||||||
expect($window.location.href).toBe(fakeApiUrl + '/auth/signin');
|
expect($window.location.href).toBe(fakeApiUrl + '/auth/signin');
|
||||||
|
@ -135,15 +135,15 @@ describe('Refstack controllers', function () {
|
|||||||
|
|
||||||
$httpBackend.expectGET(fakeApiUrl +
|
$httpBackend.expectGET(fakeApiUrl +
|
||||||
'/guidelines').respond(['next.json', '2015.03.json',
|
'/guidelines').respond(['next.json', '2015.03.json',
|
||||||
'2015.04.json']);
|
'2015.04.json']);
|
||||||
// Should call request with latest version.
|
// Should call request with latest version.
|
||||||
$httpBackend.expectGET(fakeApiUrl +
|
$httpBackend.expectGET(fakeApiUrl +
|
||||||
'/guidelines/2015.04.json').respond(fakeCaps);
|
'/guidelines/2015.04.json').respond(fakeCaps);
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
// The version list should be sorted latest first.
|
// The version list should be sorted latest first.
|
||||||
expect(ctrl.versionList).toEqual(['next.json',
|
expect(ctrl.versionList).toEqual(['next.json',
|
||||||
'2015.04.json',
|
'2015.04.json',
|
||||||
'2015.03.json']);
|
'2015.03.json']);
|
||||||
expect(ctrl.guidelines).toEqual(fakeCaps);
|
expect(ctrl.guidelines).toEqual(fakeCaps);
|
||||||
// The guideline status should be approved.
|
// The guideline status should be approved.
|
||||||
expect(ctrl.guidelineStatus).toEqual('approved');
|
expect(ctrl.guidelineStatus).toEqual('approved');
|
||||||
@ -201,7 +201,7 @@ describe('Refstack controllers', function () {
|
|||||||
|
|
||||||
$httpBackend.expectGET(fakeApiUrl +
|
$httpBackend.expectGET(fakeApiUrl +
|
||||||
'/guidelines').respond(['next.json', '2015.03.json',
|
'/guidelines').respond(['next.json', '2015.03.json',
|
||||||
'2017.08.json']);
|
'2017.08.json']);
|
||||||
// Should call request with latest version.
|
// Should call request with latest version.
|
||||||
$httpBackend.expectGET(fakeApiUrl +
|
$httpBackend.expectGET(fakeApiUrl +
|
||||||
'/guidelines/2017.08.json').respond(fakeCaps);
|
'/guidelines/2017.08.json').respond(fakeCaps);
|
||||||
@ -280,18 +280,17 @@ describe('Refstack controllers', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('TestListModalController', function () {
|
describe('TestListModalController', function () {
|
||||||
var modalInstance, ctrl, $window;
|
var modalInstance, ctrl;
|
||||||
|
|
||||||
beforeEach(inject(function ($controller, _$window_) {
|
beforeEach(inject(function ($controller) {
|
||||||
modalInstance = {
|
modalInstance = {
|
||||||
dismiss: jasmine.createSpy('modalInstance.dismiss')
|
dismiss: jasmine.createSpy('modalInstance.dismiss')
|
||||||
};
|
};
|
||||||
$window = _$window_;
|
|
||||||
ctrl = $controller('TestListModalController',
|
ctrl = $controller('TestListModalController',
|
||||||
{$uibModalInstance: modalInstance,
|
{$uibModalInstance: modalInstance,
|
||||||
target: 'platform',
|
target: 'platform',
|
||||||
version: '2016.01',
|
version: '2016.01',
|
||||||
status: {required: true, advisory: false}}
|
status: {required: true, advisory: false}}
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -418,15 +417,14 @@ describe('Refstack controllers', function () {
|
|||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
// Expect the list to have the latest guideline first.
|
// Expect the list to have the latest guideline first.
|
||||||
expect(ctrl.versionList).toEqual(['2015.04.json',
|
expect(ctrl.versionList).toEqual(['2015.04.json',
|
||||||
'2015.03.json']);
|
'2015.03.json']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a function to get products manageable by a user',
|
it('should have a function to get products manageable by a user',
|
||||||
function () {
|
function () {
|
||||||
var prodResp = {'products': [{'id': 'abc',
|
var prodResp = {'products': [
|
||||||
'can_manage': true},
|
{'id': 'abc', 'can_manage': true},
|
||||||
{'id': 'foo',
|
{'id': 'foo', 'can_manage': false}]};
|
||||||
'can_manage': false}]};
|
|
||||||
ctrl.products = null;
|
ctrl.products = null;
|
||||||
$httpBackend.expectGET(fakeApiUrl + '/products')
|
$httpBackend.expectGET(fakeApiUrl + '/products')
|
||||||
.respond(200, prodResp);
|
.respond(200, prodResp);
|
||||||
@ -449,8 +447,8 @@ describe('Refstack controllers', function () {
|
|||||||
it('should have a function to associate a product version to a test',
|
it('should have a function to associate a product version to a test',
|
||||||
function () {
|
function () {
|
||||||
var result = {'id': 'bar',
|
var result = {'id': 'bar',
|
||||||
'selectedVersion': {'id': 'foo'},
|
'selectedVersion': {'id': 'foo'},
|
||||||
'selectedProduct': {'id': 'prod'}};
|
'selectedProduct': {'id': 'prod'}};
|
||||||
ctrl.products = null;
|
ctrl.products = null;
|
||||||
$httpBackend.expectPUT(fakeApiUrl + '/results/bar')
|
$httpBackend.expectPUT(fakeApiUrl + '/results/bar')
|
||||||
.respond(201);
|
.respond(201);
|
||||||
@ -463,7 +461,7 @@ describe('Refstack controllers', function () {
|
|||||||
it('should have a function to get product versions',
|
it('should have a function to get product versions',
|
||||||
function () {
|
function () {
|
||||||
var result = {'id': 'bar',
|
var result = {'id': 'bar',
|
||||||
'selectedProduct': {'id': 'prod'}};
|
'selectedProduct': {'id': 'prod'}};
|
||||||
var verResp = [{'id': 'ver1', 'version': '1.0'},
|
var verResp = [{'id': 'ver1', 'version': '1.0'},
|
||||||
{'id': 'ver2', 'version': null}];
|
{'id': 'ver2', 'version': null}];
|
||||||
ctrl.products = null;
|
ctrl.products = null;
|
||||||
@ -530,7 +528,7 @@ describe('Refstack controllers', function () {
|
|||||||
expect(ctrl.resultsData).toEqual(fakeResultResponse);
|
expect(ctrl.resultsData).toEqual(fakeResultResponse);
|
||||||
// The version list should be sorted latest first.
|
// The version list should be sorted latest first.
|
||||||
expect(ctrl.versionList).toEqual(['2015.04.json',
|
expect(ctrl.versionList).toEqual(['2015.04.json',
|
||||||
'2015.03.json']);
|
'2015.03.json']);
|
||||||
expect(ctrl.guidelineData).toEqual(fakeCapabilityResponse);
|
expect(ctrl.guidelineData).toEqual(fakeCapabilityResponse);
|
||||||
// The guideline status should be approved.
|
// The guideline status should be approved.
|
||||||
expect(ctrl.guidelineData.status).toEqual('approved');
|
expect(ctrl.guidelineData.status).toEqual('approved');
|
||||||
@ -643,11 +641,11 @@ describe('Refstack controllers', function () {
|
|||||||
'flagFailCount': 0, 'flagPassCount': 1
|
'flagFailCount': 0, 'flagPassCount': 1
|
||||||
},
|
},
|
||||||
'advisory': {'caps': [], 'count': 0, 'passedCount': 0,
|
'advisory': {'caps': [], 'count': 0, 'passedCount': 0,
|
||||||
'flagFailCount': 0, 'flagPassCount': 0},
|
'flagFailCount': 0, 'flagPassCount': 0},
|
||||||
'deprecated': {'caps': [], 'count': 0, 'passedCount': 0,
|
'deprecated': {'caps': [], 'count': 0, 'passedCount': 0,
|
||||||
'flagFailCount': 0, 'flagPassCount': 0},
|
'flagFailCount': 0, 'flagPassCount': 0},
|
||||||
'removed': {'caps': [], 'count': 0, 'passedCount': 0,
|
'removed': {'caps': [], 'count': 0, 'passedCount': 0,
|
||||||
'flagFailCount': 0, 'flagPassCount': 0}
|
'flagFailCount': 0, 'flagPassCount': 0}
|
||||||
};
|
};
|
||||||
expect(ctrl.caps).toEqual(expectedCapsObject);
|
expect(ctrl.caps).toEqual(expectedCapsObject);
|
||||||
expect(ctrl.requiredPassPercent).toEqual(50);
|
expect(ctrl.requiredPassPercent).toEqual(50);
|
||||||
@ -658,9 +656,9 @@ describe('Refstack controllers', function () {
|
|||||||
'schema version 1.3 and above',
|
'schema version 1.3 and above',
|
||||||
function () {
|
function () {
|
||||||
ctrl.resultsData = {'results': ['test_id_1',
|
ctrl.resultsData = {'results': ['test_id_1',
|
||||||
'old_test_id_3',
|
'old_test_id_3',
|
||||||
'test_id_4']
|
'test_id_4']
|
||||||
};
|
};
|
||||||
ctrl.guidelineData = {
|
ctrl.guidelineData = {
|
||||||
'platform': {'required': ['compute']},
|
'platform': {'required': ['compute']},
|
||||||
'schema': '1.4',
|
'schema': '1.4',
|
||||||
@ -704,8 +702,8 @@ describe('Refstack controllers', function () {
|
|||||||
'caps': [{
|
'caps': [{
|
||||||
'id': 'cap_id_1',
|
'id': 'cap_id_1',
|
||||||
'passedTests': ['test_id_1',
|
'passedTests': ['test_id_1',
|
||||||
'test_id_3',
|
'test_id_3',
|
||||||
'test_id_4'],
|
'test_id_4'],
|
||||||
'notPassedTests': ['test_id_2'],
|
'notPassedTests': ['test_id_2'],
|
||||||
'passedFlagged': ['test_id_1'],
|
'passedFlagged': ['test_id_1'],
|
||||||
'notPassedFlagged': []
|
'notPassedFlagged': []
|
||||||
@ -714,11 +712,11 @@ describe('Refstack controllers', function () {
|
|||||||
'flagFailCount': 0, 'flagPassCount': 1
|
'flagFailCount': 0, 'flagPassCount': 1
|
||||||
},
|
},
|
||||||
'advisory': {'caps': [], 'count': 0, 'passedCount': 0,
|
'advisory': {'caps': [], 'count': 0, 'passedCount': 0,
|
||||||
'flagFailCount': 0, 'flagPassCount': 0},
|
'flagFailCount': 0, 'flagPassCount': 0},
|
||||||
'deprecated': {'caps': [], 'count': 0, 'passedCount': 0,
|
'deprecated': {'caps': [], 'count': 0, 'passedCount': 0,
|
||||||
'flagFailCount': 0, 'flagPassCount': 0},
|
'flagFailCount': 0, 'flagPassCount': 0},
|
||||||
'removed': {'caps': [], 'count': 0, 'passedCount': 0,
|
'removed': {'caps': [], 'count': 0, 'passedCount': 0,
|
||||||
'flagFailCount': 0, 'flagPassCount': 0}
|
'flagFailCount': 0, 'flagPassCount': 0}
|
||||||
};
|
};
|
||||||
expect(ctrl.caps).toEqual(expectedCapsObject);
|
expect(ctrl.caps).toEqual(expectedCapsObject);
|
||||||
expect(ctrl.requiredPassPercent).toEqual(75);
|
expect(ctrl.requiredPassPercent).toEqual(75);
|
||||||
@ -741,7 +739,7 @@ describe('Refstack controllers', function () {
|
|||||||
it('should have a method to determine if a test is flagged',
|
it('should have a method to determine if a test is flagged',
|
||||||
function () {
|
function () {
|
||||||
var capObj = {'flagged': [ 'test1'],
|
var capObj = {'flagged': [ 'test1'],
|
||||||
'tests': ['test1', 'test2']};
|
'tests': ['test1', 'test2']};
|
||||||
|
|
||||||
ctrl.schemaVersion = '1.2';
|
ctrl.schemaVersion = '1.2';
|
||||||
expect(ctrl.isTestFlagged('test1', capObj)).toEqual(true);
|
expect(ctrl.isTestFlagged('test1', capObj)).toEqual(true);
|
||||||
@ -773,7 +771,7 @@ describe('Refstack controllers', function () {
|
|||||||
it('should have a method to get the reason a flagged test is flagged',
|
it('should have a method to get the reason a flagged test is flagged',
|
||||||
function () {
|
function () {
|
||||||
var capObj = {'flagged': [ 'test1'],
|
var capObj = {'flagged': [ 'test1'],
|
||||||
'tests': ['test1', 'test2']};
|
'tests': ['test1', 'test2']};
|
||||||
|
|
||||||
ctrl.schemaVersion = '1.2';
|
ctrl.schemaVersion = '1.2';
|
||||||
expect(ctrl.getFlaggedReason('test1', capObj)).toEqual(
|
expect(ctrl.getFlaggedReason('test1', capObj)).toEqual(
|
||||||
@ -803,17 +801,17 @@ describe('Refstack controllers', function () {
|
|||||||
'be shown',
|
'be shown',
|
||||||
function () {
|
function () {
|
||||||
var caps = [{'id': 'cap_id_1',
|
var caps = [{'id': 'cap_id_1',
|
||||||
'passedTests': ['test_id_1'],
|
'passedTests': ['test_id_1'],
|
||||||
'notPassedTests': [],
|
'notPassedTests': [],
|
||||||
'passedFlagged': ['test_id_1'],
|
'passedFlagged': ['test_id_1'],
|
||||||
'notPassedFlagged': []
|
'notPassedFlagged': []
|
||||||
},
|
},
|
||||||
{'id': 'cap_id_2',
|
{'id': 'cap_id_2',
|
||||||
'passedTests': [],
|
'passedTests': [],
|
||||||
'notPassedTests': ['test_id_4'],
|
'notPassedTests': ['test_id_4'],
|
||||||
'passedFlagged': [],
|
'passedFlagged': [],
|
||||||
'notPassedFlagged': []
|
'notPassedFlagged': []
|
||||||
}];
|
}];
|
||||||
|
|
||||||
// Check that all capabilities are shown by default.
|
// Check that all capabilities are shown by default.
|
||||||
expect(ctrl.isCapabilityShown(caps[0])).toEqual(true);
|
expect(ctrl.isCapabilityShown(caps[0])).toEqual(true);
|
||||||
@ -838,11 +836,11 @@ describe('Refstack controllers', function () {
|
|||||||
it('should have a method to determine whether a test should be shown',
|
it('should have a method to determine whether a test should be shown',
|
||||||
function () {
|
function () {
|
||||||
var cap = {'id': 'cap_id_1',
|
var cap = {'id': 'cap_id_1',
|
||||||
'passedTests': ['test_id_1'],
|
'passedTests': ['test_id_1'],
|
||||||
'notPassedTests': [],
|
'notPassedTests': [],
|
||||||
'passedFlagged': ['test_id_1'],
|
'passedFlagged': ['test_id_1'],
|
||||||
'notPassedFlagged': []
|
'notPassedFlagged': []
|
||||||
};
|
};
|
||||||
|
|
||||||
expect(ctrl.isTestShown('test_id_1', cap)).toEqual(true);
|
expect(ctrl.isTestShown('test_id_1', cap)).toEqual(true);
|
||||||
ctrl.testStatus = 'passed';
|
ctrl.testStatus = 'passed';
|
||||||
@ -857,11 +855,11 @@ describe('Refstack controllers', function () {
|
|||||||
'capability belong under the current test filter',
|
'capability belong under the current test filter',
|
||||||
function () {
|
function () {
|
||||||
var cap = {'id': 'cap_id_1',
|
var cap = {'id': 'cap_id_1',
|
||||||
'passedTests': ['t1', 't2', 't3'],
|
'passedTests': ['t1', 't2', 't3'],
|
||||||
'notPassedTests': ['t4', 't5', 't6', 't7'],
|
'notPassedTests': ['t4', 't5', 't6', 't7'],
|
||||||
'passedFlagged': ['t1'],
|
'passedFlagged': ['t1'],
|
||||||
'notPassedFlagged': ['t3', 't4']
|
'notPassedFlagged': ['t3', 't4']
|
||||||
};
|
};
|
||||||
|
|
||||||
// Should return the count of all tests.
|
// Should return the count of all tests.
|
||||||
expect(ctrl.getCapabilityTestCount(cap)).toEqual(7);
|
expect(ctrl.getCapabilityTestCount(cap)).toEqual(7);
|
||||||
@ -883,8 +881,8 @@ describe('Refstack controllers', function () {
|
|||||||
'belong under the current test filter',
|
'belong under the current test filter',
|
||||||
function () {
|
function () {
|
||||||
ctrl.caps = {'required': {'caps': [], 'count': 10,
|
ctrl.caps = {'required': {'caps': [], 'count': 10,
|
||||||
'passedCount': 6, 'flagFailCount': 3,
|
'passedCount': 6, 'flagFailCount': 3,
|
||||||
'flagPassCount': 2}};
|
'flagPassCount': 2}};
|
||||||
|
|
||||||
// Should return the count of all tests (count).
|
// Should return the count of all tests (count).
|
||||||
expect(ctrl.getStatusTestCount('required')).toEqual(10);
|
expect(ctrl.getStatusTestCount('required')).toEqual(10);
|
||||||
@ -984,7 +982,6 @@ describe('Refstack controllers', function () {
|
|||||||
'target': 'object'
|
'target': 'object'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var fakeProdResp = {'products': [{'id': 1234}]};
|
|
||||||
var fakeVersionResp = [{'id': 'ver1', 'version': '1.0'},
|
var fakeVersionResp = [{'id': 'ver1', 'version': '1.0'},
|
||||||
{'id': 'ver2', 'version': null}];
|
{'id': 'ver2', 'version': null}];
|
||||||
|
|
||||||
@ -997,7 +994,7 @@ describe('Refstack controllers', function () {
|
|||||||
};
|
};
|
||||||
ctrl = $controller('EditTestModalController',
|
ctrl = $controller('EditTestModalController',
|
||||||
{$uibModalInstance: modalInstance, $state: state,
|
{$uibModalInstance: modalInstance, $state: state,
|
||||||
resultsData: fakeResultsData}
|
resultsData: fakeResultsData}
|
||||||
);
|
);
|
||||||
$httpBackend.when('GET', fakeApiUrl +
|
$httpBackend.when('GET', fakeApiUrl +
|
||||||
'/guidelines').respond(['2015.03.json', '2015.04.json']);
|
'/guidelines').respond(['2015.03.json', '2015.04.json']);
|
||||||
@ -1121,7 +1118,7 @@ describe('Refstack controllers', function () {
|
|||||||
var rootScope, scope, stateParams, ctrl;
|
var rootScope, scope, stateParams, ctrl;
|
||||||
var confirmModal = jasmine.createSpy('confirmModal');
|
var confirmModal = jasmine.createSpy('confirmModal');
|
||||||
var fakeResp = {'id': 'fake-id', 'type': 1,
|
var fakeResp = {'id': 'fake-id', 'type': 1,
|
||||||
'can_manage': true, 'properties' : {}};
|
'can_manage': true, 'properties' : {}};
|
||||||
var fakeUsersResp = [{'openid': 'foo'}];
|
var fakeUsersResp = [{'openid': 'foo'}];
|
||||||
var fakeProdResp = {'products': [{'id': 123}]};
|
var fakeProdResp = {'products': [{'id': 123}]};
|
||||||
var fakeWindow = {
|
var fakeWindow = {
|
||||||
@ -1134,13 +1131,13 @@ describe('Refstack controllers', function () {
|
|||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
rootScope = $rootScope.$new();
|
rootScope = $rootScope.$new();
|
||||||
rootScope.auth = {'currentUser' : {'is_admin': false,
|
rootScope.auth = {'currentUser' : {'is_admin': false,
|
||||||
'openid': 'foo'}
|
'openid': 'foo'}
|
||||||
};
|
};
|
||||||
stateParams = {vendorID: 1234};
|
stateParams = {vendorID: 1234};
|
||||||
ctrl = $controller('VendorController',
|
ctrl = $controller('VendorController',
|
||||||
{$rootScope: rootScope, $scope: scope,
|
{$rootScope: rootScope, $scope: scope,
|
||||||
$stateParams: stateParams, $window: fakeWindow,
|
$stateParams: stateParams, $window: fakeWindow,
|
||||||
confirmModal: confirmModal}
|
confirmModal: confirmModal}
|
||||||
);
|
);
|
||||||
|
|
||||||
$httpBackend.when('GET', fakeApiUrl +
|
$httpBackend.when('GET', fakeApiUrl +
|
||||||
@ -1237,7 +1234,7 @@ describe('Refstack controllers', function () {
|
|||||||
describe('VendorEditModalController', function() {
|
describe('VendorEditModalController', function() {
|
||||||
var rootScope, ctrl, modalInstance, state;
|
var rootScope, ctrl, modalInstance, state;
|
||||||
var fakeVendor = {'name': 'Foo', 'description': 'Bar', 'id': '1234',
|
var fakeVendor = {'name': 'Foo', 'description': 'Bar', 'id': '1234',
|
||||||
'properties': {'key1': 'value1', 'key2': 'value2'}};
|
'properties': {'key1': 'value1', 'key2': 'value2'}};
|
||||||
|
|
||||||
beforeEach(inject(function ($controller, $rootScope) {
|
beforeEach(inject(function ($controller, $rootScope) {
|
||||||
modalInstance = {
|
modalInstance = {
|
||||||
@ -1248,12 +1245,12 @@ describe('Refstack controllers', function () {
|
|||||||
};
|
};
|
||||||
rootScope = $rootScope.$new();
|
rootScope = $rootScope.$new();
|
||||||
rootScope.auth = {'currentUser' : {'is_admin': true,
|
rootScope.auth = {'currentUser' : {'is_admin': true,
|
||||||
'openid': 'foo'}
|
'openid': 'foo'}
|
||||||
};
|
};
|
||||||
ctrl = $controller('VendorEditModalController',
|
ctrl = $controller('VendorEditModalController',
|
||||||
{$rootScope: rootScope,
|
{$rootScope: rootScope,
|
||||||
$uibModalInstance: modalInstance, $state: state,
|
$uibModalInstance: modalInstance, $state: state,
|
||||||
vendor: fakeVendor}
|
vendor: fakeVendor}
|
||||||
);
|
);
|
||||||
|
|
||||||
}));
|
}));
|
||||||
@ -1296,17 +1293,17 @@ describe('Refstack controllers', function () {
|
|||||||
describe('VendorsController', function () {
|
describe('VendorsController', function () {
|
||||||
var rootScope, scope, ctrl;
|
var rootScope, scope, ctrl;
|
||||||
var fakeResp = {'vendors': [{'can_manage': true,
|
var fakeResp = {'vendors': [{'can_manage': true,
|
||||||
'type': 3,
|
'type': 3,
|
||||||
'name': 'Foo'},
|
'name': 'Foo'},
|
||||||
{'can_manage': true,
|
{'can_manage': true,
|
||||||
'type': 3,
|
'type': 3,
|
||||||
'name': 'Bar'}]};
|
'name': 'Bar'}]};
|
||||||
beforeEach(inject(function ($controller, $rootScope) {
|
beforeEach(inject(function ($controller, $rootScope) {
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
rootScope = $rootScope.$new();
|
rootScope = $rootScope.$new();
|
||||||
rootScope.auth = {'currentUser' : {'is_admin': false,
|
rootScope.auth = {'currentUser' : {'is_admin': false,
|
||||||
'openid': 'foo'}
|
'openid': 'foo'}
|
||||||
};
|
};
|
||||||
ctrl = $controller('VendorsController',
|
ctrl = $controller('VendorsController',
|
||||||
{$rootScope: rootScope, $scope: scope}
|
{$rootScope: rootScope, $scope: scope}
|
||||||
);
|
);
|
||||||
@ -1328,11 +1325,11 @@ describe('Refstack controllers', function () {
|
|||||||
ctrl.rawData = fakeResp;
|
ctrl.rawData = fakeResp;
|
||||||
ctrl.updateData();
|
ctrl.updateData();
|
||||||
var expectedResponse = {'vendors': [{'can_manage': true,
|
var expectedResponse = {'vendors': [{'can_manage': true,
|
||||||
'type': 3,
|
'type': 3,
|
||||||
'name' : 'Bar'},
|
'name' : 'Bar'},
|
||||||
{'can_manage': true,
|
{'can_manage': true,
|
||||||
'type': 3,
|
'type': 3,
|
||||||
'name': 'Foo'}]};
|
'name': 'Foo'}]};
|
||||||
expect(ctrl.data).toEqual(expectedResponse);
|
expect(ctrl.data).toEqual(expectedResponse);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1363,21 +1360,21 @@ describe('Refstack controllers', function () {
|
|||||||
describe('ProductsController', function() {
|
describe('ProductsController', function() {
|
||||||
var rootScope, scope, ctrl;
|
var rootScope, scope, ctrl;
|
||||||
var vendResp = {'vendors': [{'can_manage': true,
|
var vendResp = {'vendors': [{'can_manage': true,
|
||||||
'type': 3,
|
'type': 3,
|
||||||
'name': 'Foo',
|
'name': 'Foo',
|
||||||
'id': '123'}]};
|
'id': '123'}]};
|
||||||
var prodResp = {'products': [{'id': 'abc',
|
var prodResp = {'products': [{'id': 'abc',
|
||||||
'product_type': 1,
|
'product_type': 1,
|
||||||
'public': 1,
|
'public': 1,
|
||||||
'name': 'Foo Product',
|
'name': 'Foo Product',
|
||||||
'organization_id': '123'}]};
|
'organization_id': '123'}]};
|
||||||
|
|
||||||
beforeEach(inject(function ($controller, $rootScope) {
|
beforeEach(inject(function ($controller, $rootScope) {
|
||||||
scope = $rootScope.$new();
|
scope = $rootScope.$new();
|
||||||
rootScope = $rootScope.$new();
|
rootScope = $rootScope.$new();
|
||||||
rootScope.auth = {'currentUser' : {'is_admin': false,
|
rootScope.auth = {'currentUser' : {'is_admin': false,
|
||||||
'openid': 'foo'}
|
'openid': 'foo'}
|
||||||
};
|
};
|
||||||
ctrl = $controller('ProductsController',
|
ctrl = $controller('ProductsController',
|
||||||
{$rootScope: rootScope, $scope: scope}
|
{$rootScope: rootScope, $scope: scope}
|
||||||
);
|
);
|
||||||
@ -1391,24 +1388,24 @@ describe('Refstack controllers', function () {
|
|||||||
function () {
|
function () {
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
var newVendResp = {'vendors': [{'name': 'Foo',
|
var newVendResp = {'vendors': [{'name': 'Foo',
|
||||||
'id': '123',
|
'id': '123',
|
||||||
'can_manage': true},
|
'can_manage': true},
|
||||||
{'name': 'Bar',
|
{'name': 'Bar',
|
||||||
'id': '345',
|
'id': '345',
|
||||||
'can_manage': false}]};
|
'can_manage': false}]};
|
||||||
$httpBackend.expectGET(fakeApiUrl + '/vendors')
|
$httpBackend.expectGET(fakeApiUrl + '/vendors')
|
||||||
.respond(200, newVendResp);
|
.respond(200, newVendResp);
|
||||||
ctrl.updateVendors();
|
ctrl.updateVendors();
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
expect(ctrl.allVendors).toEqual({'123': {'name': 'Foo',
|
expect(ctrl.allVendors).toEqual({'123': {'name': 'Foo',
|
||||||
'id': '123',
|
'id': '123',
|
||||||
'can_manage': true},
|
'can_manage': true},
|
||||||
'345': {'name': 'Bar',
|
'345': {'name': 'Bar',
|
||||||
'id': '345',
|
'id': '345',
|
||||||
'can_manage': false}});
|
'can_manage': false}});
|
||||||
expect(ctrl.vendors).toEqual([{'name': 'Foo',
|
expect(ctrl.vendors).toEqual([{'name': 'Foo',
|
||||||
'id': '123',
|
'id': '123',
|
||||||
'can_manage': true}]);
|
'can_manage': true}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have a function to get products',
|
it('should have a function to get products',
|
||||||
@ -1424,14 +1421,14 @@ describe('Refstack controllers', function () {
|
|||||||
function () {
|
function () {
|
||||||
$httpBackend.flush();
|
$httpBackend.flush();
|
||||||
ctrl.allVendors = {'123': {'name': 'Foo',
|
ctrl.allVendors = {'123': {'name': 'Foo',
|
||||||
'id': '123',
|
'id': '123',
|
||||||
'can_manage': true}};
|
'can_manage': true}};
|
||||||
ctrl.updateData();
|
ctrl.updateData();
|
||||||
var expectedData = {'products': [{'id': 'abc',
|
var expectedData = {'products': [{'id': 'abc',
|
||||||
'product_type': 1,
|
'product_type': 1,
|
||||||
'public': 1,
|
'public': 1,
|
||||||
'name': 'Foo Product',
|
'name': 'Foo Product',
|
||||||
'organization_id': '123'}]};
|
'organization_id': '123'}]};
|
||||||
expect(ctrl.data).toEqual(expectedData);
|
expect(ctrl.data).toEqual(expectedData);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1449,31 +1446,31 @@ describe('Refstack controllers', function () {
|
|||||||
describe('ProductController', function() {
|
describe('ProductController', function() {
|
||||||
var rootScope, scope, stateParams, ctrl;
|
var rootScope, scope, stateParams, ctrl;
|
||||||
var fakeProdResp = {'product_type': 1,
|
var fakeProdResp = {'product_type': 1,
|
||||||
'product_ref_id': null,
|
'product_ref_id': null,
|
||||||
'name': 'Good Stuff',
|
'name': 'Good Stuff',
|
||||||
'created_at': '2016-01-01 01:02:03',
|
'created_at': '2016-01-01 01:02:03',
|
||||||
'updated_at': '2016-06-15 01:02:04',
|
'updated_at': '2016-06-15 01:02:04',
|
||||||
'properties': null,
|
'properties': null,
|
||||||
'organization_id': 'fake-org-id',
|
'organization_id': 'fake-org-id',
|
||||||
'public': true,
|
'public': true,
|
||||||
'can_manage': true,
|
'can_manage': true,
|
||||||
'created_by_user': 'fake-open-id',
|
'created_by_user': 'fake-open-id',
|
||||||
'type': 0,
|
'type': 0,
|
||||||
'id': '1234',
|
'id': '1234',
|
||||||
'description': 'some description'};
|
'description': 'some description'};
|
||||||
var fakeVersionResp = [{'id': 'asdf',
|
var fakeVersionResp = [{'id': 'asdf',
|
||||||
'cpid': null,
|
'cpid': null,
|
||||||
'version': '1.0',
|
'version': '1.0',
|
||||||
'product_id': '1234'}];
|
'product_id': '1234'}];
|
||||||
var fakeTestsResp = {'pagination': {'current_page': 1,
|
var fakeTestsResp = {'pagination': {'current_page': 1,
|
||||||
'total_pages': 1},
|
'total_pages': 1},
|
||||||
'results':[{'id': 'foo-test'}]};
|
'results':[{'id': 'foo-test'}]};
|
||||||
var fakeVendorResp = {'id': 'fake-org-id',
|
var fakeVendorResp = {'id': 'fake-org-id',
|
||||||
'type': 3,
|
'type': 3,
|
||||||
'can_manage': true,
|
'can_manage': true,
|
||||||
'properties' : {},
|
'properties' : {},
|
||||||
'name': 'Foo Vendor',
|
'name': 'Foo Vendor',
|
||||||
'description': 'foo bar'};
|
'description': 'foo bar'};
|
||||||
var fakeWindow = {
|
var fakeWindow = {
|
||||||
location: {
|
location: {
|
||||||
href: ''
|
href: ''
|
||||||
@ -1485,11 +1482,11 @@ describe('Refstack controllers', function () {
|
|||||||
rootScope = $rootScope.$new();
|
rootScope = $rootScope.$new();
|
||||||
stateParams = {id: 1234};
|
stateParams = {id: 1234};
|
||||||
rootScope.auth = {'currentUser' : {'is_admin': false,
|
rootScope.auth = {'currentUser' : {'is_admin': false,
|
||||||
'openid': 'foo'}
|
'openid': 'foo'}
|
||||||
};
|
};
|
||||||
ctrl = $controller('ProductController',
|
ctrl = $controller('ProductController',
|
||||||
{$rootScope: rootScope, $scope: scope,
|
{$rootScope: rootScope, $scope: scope,
|
||||||
$stateParams: stateParams, $window: fakeWindow}
|
$stateParams: stateParams, $window: fakeWindow}
|
||||||
);
|
);
|
||||||
$httpBackend.when('GET', fakeApiUrl +
|
$httpBackend.when('GET', fakeApiUrl +
|
||||||
'/products/1234').respond(fakeProdResp);
|
'/products/1234').respond(fakeProdResp);
|
||||||
@ -1609,7 +1606,7 @@ describe('Refstack controllers', function () {
|
|||||||
|
|
||||||
var ctrl, modalInstance, state, parent;
|
var ctrl, modalInstance, state, parent;
|
||||||
var fakeVersion = {'id': 'asdf', 'cpid': null,
|
var fakeVersion = {'id': 'asdf', 'cpid': null,
|
||||||
'version': '1.0','product_id': '1234'};
|
'version': '1.0','product_id': '1234'};
|
||||||
|
|
||||||
beforeEach(inject(function ($controller) {
|
beforeEach(inject(function ($controller) {
|
||||||
modalInstance = {
|
modalInstance = {
|
||||||
@ -1620,7 +1617,7 @@ describe('Refstack controllers', function () {
|
|||||||
};
|
};
|
||||||
ctrl = $controller('ProductVersionModalController',
|
ctrl = $controller('ProductVersionModalController',
|
||||||
{$uibModalInstance: modalInstance, $state: state,
|
{$uibModalInstance: modalInstance, $state: state,
|
||||||
version: fakeVersion, parent: parent}
|
version: fakeVersion, parent: parent}
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -1647,9 +1644,9 @@ describe('Refstack controllers', function () {
|
|||||||
describe('ProductEditModalController', function() {
|
describe('ProductEditModalController', function() {
|
||||||
var ctrl, modalInstance, state;
|
var ctrl, modalInstance, state;
|
||||||
var fakeProduct = {'name': 'Foo', 'description': 'Bar', 'id': '1234',
|
var fakeProduct = {'name': 'Foo', 'description': 'Bar', 'id': '1234',
|
||||||
'properties': {'key1': 'value1'}};
|
'properties': {'key1': 'value1'}};
|
||||||
var fakeVersion = {'version': null, 'product_id': '1234',
|
var fakeVersion = {'version': null, 'product_id': '1234',
|
||||||
'cpid': null, 'id': 'asdf'};
|
'cpid': null, 'id': 'asdf'};
|
||||||
|
|
||||||
beforeEach(inject(function ($controller) {
|
beforeEach(inject(function ($controller) {
|
||||||
modalInstance = {
|
modalInstance = {
|
||||||
@ -1660,8 +1657,8 @@ describe('Refstack controllers', function () {
|
|||||||
};
|
};
|
||||||
ctrl = $controller('ProductEditModalController',
|
ctrl = $controller('ProductEditModalController',
|
||||||
{$uibModalInstance: modalInstance, $state: state,
|
{$uibModalInstance: modalInstance, $state: state,
|
||||||
product: fakeProduct,
|
product: fakeProduct,
|
||||||
version: fakeVersion}
|
version: fakeVersion}
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user