c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel/**
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.
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel *
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.
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel *
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]".
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel *
90929d4c6b284dd318f4a78c2aa407afb7423747oliver.bradley * Copyright 2014-2015 ForgeRock AS.
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel */
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel
d1e25a21be0403ed5f4ea45f589a3956592befd9Jake Feasel/*global define, QUnit, localStorage, sessionStorage */
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel
01a229e011c0d84be34e967cf517d35a476c541aJake Feaseldefine([
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel "jquery",
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel "underscore",
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel "org/forgerock/commons/ui/common/util/Constants",
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel "org/forgerock/commons/ui/common/main/EventManager",
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel "sinon",
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel "../test/tests/common",
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel "../test/tests/specific"
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel], function ($, _, constants, eventManager, sinon, commonTests, specificTests) {
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel $.doTimeout = function (name, time, func) {
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel func(); // run the function immediately rather than delayed.
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel };
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel return function (server) {
d1e25a21be0403ed5f4ea45f589a3956592befd9Jake Feasel eventManager.registerListener(constants.EVENT_APP_INITIALIZED, function () {
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.testStart(function (testDetails) {
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel console.log("Starting " + testDetails.module + ":" + testDetails.name + "("+ testDetails.testNumber +")");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel // every state needs to be reset at the starat of each test
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel var vm = require("org/forgerock/commons/ui/common/main/ViewManager"),
08b5793948544288f007d40b3391a6f69e2aeb07huck.elliott configDelegate = require("org/forgerock/openidm/ui/common/delegates/ConfigDelegate");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel
08b5793948544288f007d40b3391a6f69e2aeb07huck.elliott configDelegate.clearDelegateCache();
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel
d1e25a21be0403ed5f4ea45f589a3956592befd9Jake Feasel server.responses = [];
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel vm.currentView = null;
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel vm.currentDialog = null;
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel vm.currentViewArgs = null;
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel vm.currentDialogArgs = null;
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel localStorage.clear();
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel sessionStorage.clear();
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel require("org/forgerock/commons/ui/common/main/Configuration").baseTemplate = null;
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel });
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.testDone(function () {
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel // various widgets which get added outside of the fixture and need to be cleaned up
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel $(".modal-backdrop").remove();
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel //$(".modal").remove();
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel $(".ui-autocomplete").remove();
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel $(".ui-helper-hidden-accessible").remove();
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel $("body").removeClass("modal-open");
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel });
e217869edbae075c18fd85c2d468a7ce9050b3b3Jake Feasel
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel QUnit.done(function () {
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel localStorage.clear();
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel sessionStorage.clear();
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel Backbone.history.stop();
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel window.location.hash = "";
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel });
e217869edbae075c18fd85c2d468a7ce9050b3b3Jake Feasel
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel _.delay(function () {
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel QUnit.start();
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel commonTests.executeAll(server);
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel specificTests.executeAll(server);
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel }, 500);
0e2f85c75c270eec9d148bab17911441d8843a2aJake Feasel
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel });
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel };
c54f5c9f018cfaf6792ae351d3f0be15efdd175eJake Feasel
01a229e011c0d84be34e967cf517d35a476c541aJake Feasel});