propertyMappingTest.js revision e217869edbae075c18fd85c2d468a7ce9050b3b3
/**
* 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([
"sinon",
], function (sinon, browserStorageDelegate, syncDelegate, mappingUtils, addPropertyMappingDialog, editPropertyMappingDialog, mappingBaseView, PropertiesView, propertiesViewLoadMock) {
var mappingName = "systemLdapAccounts_managedUser";
return {
executeAll: function (server) {
module('Property Mapping UI Functions');
var browserStorageDelegate = require("org/forgerock/openidm/ui/admin/delegates/BrowserStorageDelegate"),
//currentMapping() test
QUnit.equal(PropertiesView.currentMapping().name, mappingName, "currentMapping() returns proper value");
//clear changes button test
$("#clearChanges").click();
QUnit.equal(browserStorageDelegate.get(mappingName + "_Properties"), null, "Clear Changes button clears changed mapping properties from session storage");
QUnit.equal($("div.changesPending:visible").length, 0,"Changes Pending message successfully hidden");
//PropertiesGrid tests
QUnit.equal(PropertiesView.$el.find(".ui-jqgrid tr:gt(1)").length, PropertiesView.currentMapping().properties.length, "Correct number of properties displayed in grid");
//row click test
QUnit.equal(window.location.hash,"#property/" + mappingName + "/displayName","Clicking grid row changes address to proper route");
//numRepresentativeProperties tests
QUnit.equal(browserStorageDelegate.get(mappingName + "_numRepresentativeProps",true), 2, "Number of representative properties successfully changed");
QUnit.equal(setNumRepresentativePropsLineSpy.called, true, "setNumRepresentativePropsLine successfully called after change to Number of representative properties");
//remove property tests
QUnit.notEqual(browserStorageDelegate.get(mappingName + "_Properties").length, PropertiesView.currentMapping().properties.length, "Property successfully removed from current mapping properties");
//add property button test
$(".addProperty").click();
QUnit.ok(_.contains(window.location.hash, "_new"), "Add Property button successfully changes address to appropriate route");
});
});
var browserStorageDelegate = require("org/forgerock/openidm/ui/admin/delegates/BrowserStorageDelegate");
mappingBaseView.data = {};
delete PropertiesView.route;
//addPropertyMappingDialog tests
QUnit.equal(_.last(browserStorageDelegate.get(mappingName + "_Properties")).target,"test","Property mapping successfully added");
QUnit.equal(window.location.hash, "#property/" + mappingName + "/test","After adding new property mapping the url changes to correct route");
});
});
});
var browserStorageDelegate = require("org/forgerock/openidm/ui/admin/delegates/BrowserStorageDelegate");
mappingBaseView.data = {};
delete PropertiesView.route;
//editPropertyMappingDialog tests
QUnit.equal(editPropertyMappingDialog.$el.find("#Property_List").find(".validation-message").text(),"You must select a valid property name.","Invalid property message displayed correctly");
QUnit.ok(editPropertyMappingDialog.$el.find("#Property_List").find("input[type=submit]:disabled").length > 0, "Submit button properly disabled");
QUnit.equal(editPropertyMappingDialog.data.property.source,"sn","Property mapping source successfully changed");
QUnit.equal(editPropertyMappingDialog.$el.find("#Property_List").find("input[type=submit]:disabled").length,0, "Submit button properly enabled");
QUnit.notDeepEqual(browserStorageDelegate.get(mappingName + "_Properties"),propsBefore,"Property mapping successfully updated");
});
});
});
}
};
});