EditTests.js revision 89092dc10fe08b037266c0b4efb94b221f6fffb3
/**
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2015 ForgeRock AS.
*/
/*global require, define, QUnit, $ */
define([
], function (EditAppView, PolicyDelegate, EditPolicyView, CreatedResourcesView, EditResourceTypeView) {
return {
executeAll: function () {
EditAppView.render([], function () {
}
QUnit.ok(EditAppView.$el.find('#reviewName').hasClass('text-danger'), "Name does not pass validation");
QUnit.ok(EditAppView.$el.find('input[name="submitForm"]').is(':disabled'), "Finish button is disabled");
});
});
if (activeTabIndex === -1) {
}
QUnit.ok(EditAppView.$el.find('#appDescription').val() === (entity.description ? entity.description : ''), "Description is set");
// Resource Types
var selected = _.findByValues(EditAppView.data.options.allResourceTypes, 'uuid', EditAppView.data.entity.resourceTypeUuids),
rightItems = EditAppView.resourceTypesListSelectedView.$el.find('.list-table ul li:not(.text-danger)'),
// select and deselect resource types
// add 2
// remove 1
QUnit.equal(entity.resourceTypeUuids.length, initialRight + 1, 'Resource Types can be successfully selected and deselected');
QUnit.ok(EditAppView.$el.find('#reviewName').html().trim() === entity.name, "Correct name is displayed in the review step");
QUnit.ok(!EditAppView.$el.find('#reviewName').parents('.review-row').hasClass('.invalid'), "Validate isn't displayed in the review step");
// both are undefined.
} else {
QUnit.ok(EditAppView.$el.find('#reviewDesc').html().trim() === (entity.description ? entity.description : ''), "Correct description is displayed in the review step");
}
QUnit.ok(!EditAppView.$el.find('input[name="submitForm"]').is(':disabled'), "Finish button isn't disabled");
});
});
}
QUnit.ok(EditPolicyView.$el.find('#reviewName').hasClass('text-danger'), 'Name field is marked as invalid');
QUnit.equal(EditPolicyView.$el.find('#reviewRes').length, 0, 'Resources field is not displayed in review step as it is invalid');
QUnit.ok(EditPolicyView.$el.find('[name="submitForm"]').is(':disabled'), 'Submit button is disabled');
});
});
var appName = 'iPlanetAMWebAgentService',
policyName = 'test';
correctResources = true;
correctResources = correctResources && $(item).text().trim() === item.dataset.resource && _.contains(entity.resources, item.dataset.resource);
});
QUnit.equal(createdResources.length, entity.resources.length, "Correct number of resources are displayed");
// Available Patterns
availablePatterns = [];
});
QUnit.equal(_.difference(availablePatterns, options.availablePatterns).length, 0, "All available patterns are displayed correctly");
values = [],
valid = true,
NEW_STR = 'newResource',
INVALID_STR = 'invalid/Resource';
valid = false;
}
});
valid = valid && $(item).text().trim() === item.dataset.resource && _.contains(entity.resources, item.dataset.resource);
});
// Testing new resource can be added.
// Testing duplication by trying to re-add the previous resource
QUnit.equal(entity.resources.length, _.uniq(entity.resources).length, "Duplicate resource not added");
// checking for invalid inputs
// Delete the NEW_RESOURCE
QUnit.ok(entity.resources.length === resourceLength - 1 && !_.contains(entity.resources, lastAddedItem.data().resource), 'Resource deleted');
});
});
});
var appName = 'iPlanetAMWebAgentService',
policyName = 'test';
// add new static attribute
QUnit.ok(attrsLengthOld + 1 === EditPolicyView.staticAttrsView.data.items.length, "Static attribute can be added");
QUnit.ok(attrsLengthOld + 1 === EditPolicyView.staticAttrsView.data.items.length, "Can't add duplicate static attribute");
// delete static attribute
QUnit.ok(attrsLengthOld === EditPolicyView.staticAttrsView.data.items.length, "Static attribute can be deleted");
QUnit.ok(!_.find(EditPolicyView.staticAttrsView.data.items, { propertyName: "incompleteVal" }), "Static attributes with no key can't be added");
QUnit.ok(!_.find(EditPolicyView.staticAttrsView.data.items, { propertyName: "incompleteKey" }), "Static attributes with no value can't be added");
QUnit.equal(EditPolicyView.$el.find('#userAttrs').find('.selectize-input').find('.item').length, userAttributes.length, 'User attributes are selected correctly');
});
});
});
var appName = 'iPlanetAMWebAgentService',
policyName = 'test';
correctPermissions = true,
});
});
// Selecting individual actions
QUnit.equal(EditPolicyView.data.options.availableActions.length, resourceTypesActionsInitialLength - 1, 'Minus one available action');
QUnit.ok(actionName in EditPolicyView.data.entity.actionValues, 'Selected action is added to the entity');
});
});
var appName = 'iPlanetAMWebAgentService',
policyName = 'test';
"Correct name is displayed in the review step");
// both are undefined.
} else {
QUnit.ok(EditPolicyView.$el.find('#reviewDesc').html().trim() === (entity.description ? entity.description : ''),
"Correct description is displayed in the review step");
}
// Resources
var resources = [];
});
QUnit.ok(_.isEqual(resources, entity.resources), "Correct resources are displayed in the review step");
}
// Subject Conditions
QUnit.equal(EditPolicyView.$el.find('#subjectContainer').find('#addCondition').length, 1, 'Add subject button is present');
QUnit.equal(EditPolicyView.$el.find('#subjectContainer').find('#addOperator').length, 1, 'Add operator button is present');
QUnit.ok(EditPolicyView.$el.find('#subjectContainer').find('#pickUpItem').empty(), 'Pick up item is empty');
QUnit.ok(EditPolicyView.$el.find('#subjectContainer').find('#clear').hasClass('disabled'), 'Clear button is disabled');
QUnit.ok(EditPolicyView.$el.find('#subjectContainer').find('#pickUpItem').children().length > 0, 'Pick up item is not empty');
QUnit.ok(!EditPolicyView.$el.find('#subjectContainer').find('#clear').hasClass('inactive'), 'Clear button is enabled');
QUnit.ok(_.isEqual(reviewSubj, entity.subject), "Correct environment conditions are displayed in the review step");
}
// Environment Conditions
QUnit.equal(EditPolicyView.$el.find('#environmentContainer').find('#addCondition').length, 1, 'Add condition button is present');
QUnit.equal(EditPolicyView.$el.find('#environmentContainer').find('#addOperator').length, 1, 'Add operator button is present');
QUnit.ok(EditPolicyView.$el.find('#environmentContainer').find('#pickUpItem').empty(), 'Pick up item is empty');
QUnit.ok(EditPolicyView.$el.find('#environmentContainer').find('#clear').hasClass('disabled'), 'Clear button is disabled');
QUnit.ok(EditPolicyView.$el.find('#environmentContainer').find('#pickUpItem').children().length > 0, 'Pick up item is not empty');
QUnit.ok(!EditPolicyView.$el.find('#environmentContainer').find('#clear').hasClass('inactive'), 'Clear button is enabled');
QUnit.ok(_.isEqual(reviewEnv, entity.condition), "Correct environment conditions are displayed in the review step");
}
});
});
var appName = 'iPlanetAMWebAgentService',
policyName = 'test';
}
QUnit.ok(EditPolicyView.validationFields && EditPolicyView.validationFields.length > 0, 'Validation is present');
QUnit.equal(EditPolicyView.$el.find('[name="submitForm"]').is(':disabled'), false, 'Submit button is enabled');
QUnit.ok(EditPolicyView.$el.find('#description').val() === (entity.description ? entity.description : ''), "Description is set");
QUnit.equal(EditPolicyView.$el.find('#availableResTypes').val(), entity.resourceTypeUuid, "Resource type is selected");
});
});
EditResourceTypeView.render([], function () {
}
QUnit.ok(EditResourceTypeView.$el.find('#reviewName').hasClass('text-danger'), 'Name field is marked as invalid');
QUnit.equal(EditResourceTypeView.$el.find('#reviewRes').length, 0, 'Resources field is not displayed in review step as it is invalid');
QUnit.ok(EditResourceTypeView.$el.find('[name="submitForm"]').is(':disabled'), 'Submit button is disabled');
});
});
var resTypeUUID = '6a90eabe-9638-4333-b688-3223aec7f58a';
}
// Step 1
QUnit.ok(EditResourceTypeView.validationFields && EditResourceTypeView.validationFields.length > 0, 'Validation is present');
QUnit.equal(EditResourceTypeView.$el.find('[name="submitForm"]').is(':disabled'), false, 'Submit button is enabled');
QUnit.equal(EditResourceTypeView.$el.find('h1 a.btn-default').length, 1, "Cancel button is present");
QUnit.ok(EditResourceTypeView.$el.find('#resTypeDescription').val() === (entity.description ? entity.description : ''),
"Description is set");
// Step 2
resTypeActionsCorrect = true;
});
// last item is 'add new' item
QUnit.equal(resTypeActions.length - 1, EditResourceTypeView.data.actions.length, "Correct number of actions are displayed");
resTypePatternsCorrect = true;
// last item is 'add new' item
QUnit.equal(resTypePatterns.length - 1, entity.patterns.length, "Correct number of patterns are displayed");
});
// Step 3
QUnit.ok(EditResourceTypeView.$el.find('#reviewName').text().trim() === entity.name, "Correct name is displayed in the review step");
// both are undefined.
} else {
QUnit.ok(EditResourceTypeView.$el.find('#reviewDesc').html().trim() === (entity.description ? entity.description : ''),
"Correct description is displayed in the review step");
}
// Patterns
var patterns = [];
});
QUnit.ok(_.isEqual(patterns, entity.patterns), "Correct patterns are displayed in the review step");
}
// Actions
QUnit.ok(_.isEqual(EditResourceTypeView.$el.find('ul#reviewActions').find('li').lenght, entity.actions.length), "Correct count actions are displayed in the review step");
var valid = true;
});
}
});
});
}
}
});