editResourceViewTest.js revision 75d0e6897931d0d08f4d64dc1420ce03576b49cb
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2014-2015 ForgeRock AS. All Rights Reserved
*
* 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
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*/
/*global require, define, QUnit, $ */
define([
"../mocks/editResource"
], function (
conf,
) {
return {
module('Edit Resource Data UI Functions');
}),
}),
deleteTest = function() {
editRoleView.deleteRole(null,function() {
});
QUnit.ok($(".bootstrap-dialog-title").text().indexOf("Confirm") > -1, "Delete confirmation dialog opened");
});
};
//managed/role is an example of an edit view override that allows custom editing of a specific managed object
//make sure that the ResourceEditViewRegistry is returning the proper view
QUnit.ok(registrySpy.calledWith("role"), "ResourceEditViewRegistry.getEditViewModule() called with the 'role' as the resource argument");
QUnit.equal(childView.template, "templates/admin/role/EditRoleViewTemplate.html", "The GenericEditResourceView is properly overridden by EditRoleView");
QUnit.ok(_.isEqual(editRoleSpy.args[0][0],args), "EditRoleView gets the correct arguments from resourceEditViewRegistry");
QUnit.ok(childView.data.newRole,"Based on the args passed to the EditRoleView the 'newRole' variable was properly set to true");
QUnit.ok(!editRoleView.$el.find("[href=#role-entitlements]").is(":visible") && !editRoleView.$el.find("[href=#role-users]").is(":visible"), "Entitlements and Users tabs hidden");
QUnit.equal(location.hash, "#resource/managed/role/edit/" + _.last(editRoleView.data.args), "URL route changed to the correct value after save");
QUnit.ok(editRoleView.$el.find("[href=#role-entitlements]").is(":visible") && editRoleView.$el.find("[href=#role-users]").is(":visible"), "Entitlements and Users tabs visible");
QUnit.ok(_.isEqual(roleEntitlementsEditRenderStub.args[0], [editRoleView.data.args,editRoleView.data.role,null, roleEntitlementsListView]), "RoleEntitlementsEditView.render passed the correct arguments");
roleEntitlementsEditView.render(editRoleView.data.args,editRoleView.data.role,null, roleEntitlementsListView, function() {
QUnit.ok($(".bootstrap-dialog-title").text().indexOf("Add an Entitlement") > -1, "Add entitlement dialog opened");
roleEntitlementsEditView.saveAssignment(function() {
QUnit.ok(_.has(editRoleView.data.role.assignments,"myEntitlement"), "New Entitlement successfully saved")
deleteTest();
});
});
});
});
this.saveRole(null);
}, editRoleView));
});
});
deleteTest = function() {
genericEditResourceView.deleteObject(null,function() {
});
QUnit.ok($(".bootstrap-dialog-title").text().indexOf("Confirm") > -1, "Delete confirmation dialog opened");
});
};
//managed/role is an example of an edit view override that allows custom editing of a specific managed object
QUnit.equal(childView.template, "templates/admin/resource/EditResourceViewTemplate.html", "The GenericEditResourceView loaded")
QUnit.ok(_.isEqual(editResourceSpy.args[0][0],args), "GenericEditResourceView gets the correct arguments from resourceEditViewRegistry");
QUnit.ok(childView.data.newObject,"Based on the args passed to the GenericEditResourceView the 'newObject' variable was properly set to true");
QUnit.ok(!editRoleView.$el.find("#linkedSystemsTabHeader").is(":visible"), "Linked Systems tab hidden");
this.save(null, function() {
QUnit.ok(_.isEqual(genericEditResourceView.data.args,editResourceSpy.args[0][0]), "New User successfully saved");
QUnit.equal(location.hash, "#resource/managed/user/edit/" + _.last(genericEditResourceView.data.args), "URL route changed to the correct value after save");
//duplicated server calls giving me the already edited object
//change the properties that we will test to the actual oldObject values
genericEditResourceView.save(null, function() {
deleteTest();
});
});
}, genericEditResourceView));
})
});
}
};
});