001/**
002 * Copyright 2005-2011 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package edu.samplu.admin.test;
018
019import edu.samplu.common.SmokeTestBase;
020import org.junit.Test;
021
022import edu.samplu.common.ITUtil;
023
024/**
025 * test that repeated ajax refreshes work
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 */
028public class AgendaEditRuleRefreshSmokeTest extends SmokeTestBase {
029
030    public static final String BOOKMARK_URL =ITUtil.PORTAL+"?channelTitle=Agenda%20Lookup&channelUrl="
031            + ITUtil.getBaseUrlString() + ITUtil.KRAD_LOOKUP_METHOD
032            + "org.kuali.rice.krms.impl.repository.AgendaBo"
033            + ITUtil.SHOW_MAINTENANCE_LINKS
034            + "&returnLocation=" + ITUtil.PORTAL_URL + ITUtil.HIDE_RETURN_LINK;
035
036    @Override
037    protected String getBookmarkUrl() {
038        return BOOKMARK_URL;
039    }
040
041    @Override
042    protected void navigate() throws Exception {
043        waitAndClickByLinkText(AGENDA_LOOKUP_LINK_TEXT);
044        waitForPageToLoad();
045    }
046
047    protected void testAgendaEditRuleRefresh() throws Exception {
048        selectFrameIframePortlet();
049        waitAndClickButtonByText("Search");
050        //        waitAndClickByXpath("//div[@class='uif-boxLayout uif-horizontalBoxLayout clearfix']/button[1]"); //  jiraAwareWaitAndClick("id=32");
051        Thread.sleep(3000);
052        waitAndClickByXpath("//a[@title='edit Agenda Definition with Agenda Id=T1000']",
053                "Does user have edit permissions?"); // jiraAwareWaitAndClick("id=194_line0");
054        checkForIncidentReport("");
055        Thread.sleep(3000);
056        waitAndClickByXpath("//li/a[@class='agendaNode ruleNode']"); // jiraAwareWaitAndClick("//li[@id='473_node_0_parent_root']/a");
057        waitAndClickByXpath("//li/a[@class='agendaNode logicNode whenTrueNode']");
058        waitAndClickByLinkText("[-] collapse all");
059
060        // click refresh  several times
061        for (int i = 0; i < 6; i++) {
062            for (int second = 0;; second++) {
063                if (second >= waitSeconds)
064                    failableFail(TIMEOUT_MESSAGE);
065                try {
066                    if (isElementPresent(".kr-refresh-button"))
067                        break;
068                } catch (Exception e) {}
069                Thread.sleep(1000);
070            }
071            waitAndClick("button.kr-refresh-button");
072        }
073        passed();
074    }
075
076    /**
077     * test that repeated ajax refreshes work
078     */
079    @Test
080    public void testAgendaEditRuleRefreshBookmark() throws Exception {
081        testAgendaEditRuleRefresh();
082    }
083
084    /**
085     * test that repeated ajax refreshes work
086     */
087    @Test
088    public void testAgendaEditRuleRefreshNav() throws Exception {
089        testAgendaEditRuleRefresh();
090    }
091}
092