001/**
002 * Copyright 2005-2014 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 */
016package edu.sampleu.main;
017
018import org.kuali.rice.testtools.common.JiraAwareFailable;
019import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
020import org.kuali.rice.testtools.selenium.WebDriverUtils;
021import org.openqa.selenium.By;
022
023/**
024 * @author Kuali Rice Team (rice.collab@kuali.org)
025 */
026public class PeopleFlowCreateNewAftBase extends MainTmplMthdSTNavBase{
027
028    /**
029     * AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=People%20Flow&channelUrl="
030     *  + WebDriverUtils.getBaseUrlString() + AutomatedFunctionalTestUtils.KRAD_LOOKUP_METHOD
031     *  + "org.kuali.rice.kew.impl.peopleflow.PeopleFlowBo"
032     *  + "&returnLocation=" + AutomatedFunctionalTestUtils.AutomatedFunctionalTestUtils + ITUtil.SHOW_MAINTENANCE_LINKS;
033     */
034    public static final String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=People%20Flow&channelUrl="
035            + WebDriverUtils.getBaseUrlString() + AutomatedFunctionalTestUtils.KRAD_LOOKUP_METHOD
036            + "org.kuali.rice.kew.impl.peopleflow.PeopleFlowBo"
037            + "&returnLocation=" + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.SHOW_MAINTENANCE_LINKS;
038
039    @Override
040    protected String getBookmarkUrl() {
041        return BOOKMARK_URL;
042    }
043
044    /**
045     * {@inheritDoc}
046     * People Flow
047     * @return
048     */
049    @Override
050    protected String getLinkLocator() {
051        return "People Flow";
052    }
053
054    public void testPeopleFlowBlanketApproveBookmark(JiraAwareFailable failable) throws Exception {
055        testPeopleFlowBlanketApprove();
056        passed();
057    }
058    public void testPeopleFlowBlanketApproveNav(JiraAwareFailable failable) throws Exception {
059        testPeopleFlowBlanketApprove();
060        passed();
061    }
062    
063    public void testPeopleFlowDuplicateEntryBookmark(JiraAwareFailable failable) throws Exception {
064        testPeopleFlowDuplicateEntry();
065        passed();
066    }
067    
068    public void testPeopleFlowDuplicateEntryNav(JiraAwareFailable failable) throws Exception {
069        testPeopleFlowDuplicateEntry();
070        passed();
071    }
072
073    protected void testPeopleFlowBlanketApprove() throws Exception {
074        String docId = peopleFlowCreateNew();
075
076        waitAndClickBlanketApprove();
077        waitAndClickConfirmationOk();
078        Thread.sleep(3000);
079        checkForIncidentReport();
080        jGrowl("Blanket Approve");
081        Thread.sleep(5000);
082
083        //Close the Doc
084        //findElement(By.id("uif-close")).click();
085        //Thread.sleep(3000);
086        driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString());
087        findElement(By.cssSelector("img[alt=\"doc search\"]")).click();
088        Thread.sleep(5000);
089        jGrowl("Document Search is " + docId + " present?");
090        selectFrameIframePortlet();
091        waitAndTypeByName("documentId", docId);
092        jGrowl("Click search");
093        findElement(By.cssSelector("td.infoline > input[name=\"methodToCall.search\"]")).click();
094        waitForTextPresent(DOC_STATUS_FINAL);
095    }
096
097    protected void testPeopleFlowCreateNew() throws Exception {
098        String docId = peopleFlowCreateNew();
099
100        waitAndClickSubmitByText();
101        waitAndClickConfirmationOk();
102        Thread.sleep(3000);
103        checkForDocError();
104        checkForIncidentReport();
105
106        //Close the Doc
107        //findElement(By.id("uif-close")).click();
108        //Thread.sleep(3000);
109        driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString());
110        findElement(By.cssSelector("img[alt=\"doc search\"]")).click();
111        Thread.sleep(5000);
112        jGrowl("Document Search is " + docId + " present?");
113        selectFrameIframePortlet();
114        waitAndTypeByName("documentId", docId);
115        jGrowl("Click search");
116        findElement(By.cssSelector("td.infoline > input[name=\"methodToCall.search\"]")).click();
117        waitForTextPresent(DOC_STATUS_FINAL);
118    }
119
120    private String peopleFlowCreateNew() throws InterruptedException {
121        selectFrameIframePortlet();
122
123        waitAndClickByLinkText("Create New");
124
125        //Save docId
126        waitForElementPresent("div[data-label='Document Number']");
127        String docId = getText("div[data-label='Document Number']");
128        assertTrue(docId != null);
129        jGrowlSticky("Doc Id is " + docId);
130
131        findElement(By.name("document.documentHeader.documentDescription")).clear();
132        waitAndTypeByName("document.documentHeader.documentDescription", "Description for Document");
133        waitAndSelectByName("document.newMaintainableObject.dataObject.namespaceCode", "KUALI - Kuali Systems");
134        findElement(By.name("document.newMaintainableObject.dataObject.name")).clear();
135        waitAndTypeByName("document.newMaintainableObject.dataObject.name", "Document Name" +
136                AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars());
137
138        jGrowl("Add Member kr");
139        findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")).clear();
140        waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName", "kr");
141        waitAndClick(By.cssSelector("button[data-loadingmessage='Adding Line...']"));
142        Thread.sleep(3000);
143        checkForIncidentReport();
144
145        jGrowl("Add Member admin");
146        findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")).clear();
147        waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName", "admin");
148        waitAndClick(By.cssSelector("button[data-loadingmessage='Adding Line...']"));
149        Thread.sleep(3000);
150        return docId;
151    }
152
153    private void testPeopleFlowDuplicateEntry() throws Exception {
154        selectFrameIframePortlet();
155        waitAndClickByLinkText("Create New");
156        clearTextByName("document.documentHeader.documentDescription");
157        waitAndTypeByName("document.documentHeader.documentDescription", "Description for Duplicate");
158        waitAndSelectByName("document.newMaintainableObject.dataObject.namespaceCode", "KUALI - Kuali Systems");
159        clearTextByName("document.newMaintainableObject.dataObject.name");
160        String tempValue=AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
161        waitAndTypeByName("document.newMaintainableObject.dataObject.name", "Document Name"+tempValue);
162        waitAndClickSubmitByText();
163        waitAndClickConfirmationOk();
164        waitForTextPresent("Document was successfully submitted.");
165        selectTopFrame();
166        waitAndClickByLinkText("Main Menu");
167        waitAndClickByLinkText("People Flow");
168        selectFrameIframePortlet();
169        waitAndClickByLinkText("Create New");
170        clearTextByName("document.documentHeader.documentDescription");
171        waitAndTypeByName("document.documentHeader.documentDescription", "Description for Duplicate");
172        waitAndSelectByName("document.newMaintainableObject.dataObject.namespaceCode", "KUALI - Kuali Systems");
173        clearTextByName("document.newMaintainableObject.dataObject.name");
174        waitAndTypeByName("document.newMaintainableObject.dataObject.name", "Document Name"+tempValue);
175        waitAndClickSubmitByText();
176        waitAndClickConfirmationOk();
177        waitForTextPresent("A PeopleFlow already exists with the name");
178    }
179}