d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne/**
90929d4c6b284dd318f4a78c2aa407afb7423747oliver.bradley * The contents of this file are subject to the terms of the Common Development and
90929d4c6b284dd318f4a78c2aa407afb7423747oliver.bradley * Distribution License (the License). You may not use this file except in compliance with the
90929d4c6b284dd318f4a78c2aa407afb7423747oliver.bradley * License.
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne *
90929d4c6b284dd318f4a78c2aa407afb7423747oliver.bradley * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
90929d4c6b284dd318f4a78c2aa407afb7423747oliver.bradley * specific language governing permission and limitations under the License.
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne *
90929d4c6b284dd318f4a78c2aa407afb7423747oliver.bradley * When distributing Covered Software, include this CDDL Header Notice in each file and include
90929d4c6b284dd318f4a78c2aa407afb7423747oliver.bradley * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
90929d4c6b284dd318f4a78c2aa407afb7423747oliver.bradley * Header, with the fields enclosed by brackets [] replaced by your own identifying
90929d4c6b284dd318f4a78c2aa407afb7423747oliver.bradley * information: "Portions copyright [year] [name of copyright owner]".
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne *
90929d4c6b284dd318f4a78c2aa407afb7423747oliver.bradley * Copyright 2014-2015 ForgeRock AS.
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne */
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne/*global require, define, QUnit, $ */
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Brownedefine([
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne "org/forgerock/commons/ui/common/util/Constants",
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne "org/forgerock/commons/ui/common/main/Router",
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 "../mocks/addMapping"
352c411653c48af103d64372adc7832043da4257Elizabeth Browne], function (constants,
352c411653c48af103d64372adc7832043da4257Elizabeth Browne router,
352c411653c48af103d64372adc7832043da4257Elizabeth Browne eventManager,
352c411653c48af103d64372adc7832043da4257Elizabeth Browne addMappingView,
352c411653c48af103d64372adc7832043da4257Elizabeth Browne MapResourceView,
352c411653c48af103d64372adc7832043da4257Elizabeth Browne addMapping) {
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne return {
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne executeAll: function (server) {
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne module('Add Mapping UI Functions');
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne QUnit.asyncTest("Add Mapping View", function () {
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel /*
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;)
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel */
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne addMapping(server);
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne addMappingView.render([], function () {
1e80314f6b8449684f9baac9e8bcae33f0b4e507Jason Browne QUnit.equal(addMappingView.$el.find(".help-link").length, 1, "Help successfully detected");
1e80314f6b8449684f9baac9e8bcae33f0b4e507Jason Browne
1e80314f6b8449684f9baac9e8bcae33f0b4e507Jason Browne QUnit.equal(addMappingView.$el.find(".back-bar a").length, 1, "Return link loaded");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne QUnit.equal(addMappingView.$el.find("#resourceConnectorContainer .resource-body").length, 1, "Resources successfully loaded");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne QUnit.equal(addMappingView.$el.find("#resourceManagedContainer .resource-body").length, 4, "Managed Objects successfully loaded");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
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");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
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");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel addMappingView.$el.find(".mapping-swap").trigger("click");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.equal(addMappingView.$el.find("#mappingTarget .mapping-resource:visible .resource-given-name").text(), 'ldap', "Swap successful");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel $("body").one("shown.bs.modal", function () {
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.equal($(".bootstrap-dialog:visible .bootstrap-dialog-title").text(), "Create mapping.", "Create mapping dialog successfully shown");
c6acaf789531718f174a4fc5b87aaed163b861dbJason Browne
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.equal($(".bootstrap-dialog .mappingName").val(), "managedApple_sourceLdapAccount", "Mapping name auto generated successfully");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel $(".bootstrap-dialog").one("hidden.bs.modal", function () {
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.equal($(".bootstrap-dialog").length, 0, "Create mapping dialog closed");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel MapResourceView.$el.find("#mappingSource .select-resource").trigger("click");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel MapResourceView.$el.find("#mappingTarget .select-resource").trigger("click");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
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");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.start();
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel });
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel $(".bootstrap-dialog #mappingSaveCancel").click();
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel });
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel MapResourceView.$el.find("#createMapping").trigger("click");
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne });
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne });
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne }
d1a2899a06be1eab885056aeda85adcd67c010b0Jason Browne };
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel});