addMappingTest.js revision 1e80314f6b8449684f9baac9e8bcae33f0b4e507
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * The contents of this file are subject to the terms
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * of the Common Development and Distribution License
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * (the License). You may not use this file except in
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * compliance with the License.
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * You can obtain a copy of the License at
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * See the License for the specific language governing
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * permission and limitations under the License.
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * When distributing Covered Code, include this CDDL
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * Header Notice in each file and include the License file
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * at http://forgerock.org/license/CDDLv1.0.html
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * If applicable, add the following below the CDDL Header,
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * with the fields enclosed by brackets [] replaced by
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * your own identifying information:
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne * "Portions Copyrighted [year] [name of copyright owner]"
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne/*global require, define, QUnit, $ */
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne "org/forgerock/commons/ui/common/util/Constants",
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne "org/forgerock/commons/ui/common/main/EventManager",
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne "org/forgerock/openidm/ui/admin/mapping/AddMappingView",
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel "org/forgerock/openidm/ui/admin/MapResourceView",
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne "org/forgerock/openidm/ui/admin/ResourcesView",
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel], function (constants, router, eventManager, addMappingView, MapResourceView, resourcesView, addMapping) {
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne QUnit.asyncTest("Add Mapping View", function () {
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel * Mocks include:
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel * config/sync (mappings: systemLdapAccounts_managedUser and managedUser_systemLdapAccounts)
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel * config/managed (objects: role, apple, user, test)
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel * system?_action=test (resources: ldap - account, group;)
1e80314f6b8449684f9baac9e8bcae33f0b4e507Jason Browne QUnit.equal(addMappingView.$el.find(".help-link").length, 1, "Help successfully detected");
1e80314f6b8449684f9baac9e8bcae33f0b4e507Jason Browne QUnit.equal(addMappingView.$el.find(".back-bar a").length, 1, "Return link loaded");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne QUnit.equal(addMappingView.$el.find("#resourceConnectorContainer .resource-body").length, 1, "Resources successfully loaded");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne QUnit.equal(addMappingView.$el.find("#resourceManagedContainer .resource-body").length, 4, "Managed Objects successfully loaded");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne addMappingView.$el.find("#resourceConnectorContainer .resource-body:first .add-resource-button").trigger("click");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne addMappingView.$el.find("#resourceManagedContainer .resource-body:first .add-resource-button").trigger("click");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.equal(addMappingView.$el.find("#mappingSource .mapping-resource:visible .resource-given-name").text(), 'ldap', "Source system successfully selected");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.equal(addMappingView.$el.find("#mappingTarget .mapping-resource:visible .resource-given-name").text(), 'apple', "Target system successfully selected");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel addMappingView.$el.find(".mapping-swap").trigger("click");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.equal(addMappingView.$el.find("#mappingTarget .mapping-resource:visible .resource-given-name").text(), 'ldap', "Swap successful");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.equal($(".bootstrap-dialog:visible .bootstrap-dialog-title").text(), "Create mapping.", "Create mapping dialog successfully shown");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.equal($(".bootstrap-dialog .mappingName").val(), "managedApple_sourceLdapAccount", "Mapping name auto generated successfully");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel $(".bootstrap-dialog").one("hidden.bs.modal", function () {
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.equal($(".bootstrap-dialog").length, 0, "Create mapping dialog closed");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel MapResourceView.$el.find("#mappingSource .select-resource").trigger("click");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel MapResourceView.$el.find("#mappingTarget .select-resource").trigger("click");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.equal(addMappingView.$el.find("#mappingSource .mapping-resource-empty:visible").length, 1, "Removal of source successful");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.equal(addMappingView.$el.find("#mappingTarget .mapping-resource-empty:visible").length, 1, "Removal of target successful");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel $(".bootstrap-dialog #mappingSaveCancel").click();
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel MapResourceView.$el.find("#createMapping").trigger("click");