View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package edu.sampleu.main;
17  
18  import org.kuali.rice.testtools.common.JiraAwareFailable;
19  import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
20  import org.kuali.rice.testtools.selenium.WebDriverUtils;
21  import org.openqa.selenium.By;
22  
23  /**
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class PeopleFlowCreateNewAftBase extends MainTmplMthdSTNavBase{
27  
28      /**
29       * ITUtil.PORTAL + "?channelTitle=People%20Flow&channelUrl="
30       *  + WebDriverUtils.getBaseUrlString() + ITUtil.KRAD_LOOKUP_METHOD
31       *  + "org.kuali.rice.kew.impl.peopleflow.PeopleFlowBo"
32       *  + "&returnLocation=" + ITUtil.PORTAL_URL + ITUtil.SHOW_MAINTENANCE_LINKS;
33       */
34      public static final String BOOKMARK_URL = AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=People%20Flow&channelUrl="
35              + WebDriverUtils.getBaseUrlString() + AutomatedFunctionalTestUtils.KRAD_LOOKUP_METHOD
36              + "org.kuali.rice.kew.impl.peopleflow.PeopleFlowBo"
37              + "&returnLocation=" + AutomatedFunctionalTestUtils.PORTAL_URL + AutomatedFunctionalTestUtils.SHOW_MAINTENANCE_LINKS;
38  
39      @Override
40      protected String getBookmarkUrl() {
41          return BOOKMARK_URL;
42      }
43  
44      /**
45       * {@inheritDoc}
46       * People Flow
47       * @return
48       */
49      @Override
50      protected String getLinkLocator() {
51          return "People Flow";
52      }
53  
54      public void testPeopleFlowBlanketApproveBookmark(JiraAwareFailable failable) throws Exception {
55          testPeopleFlowBlanketApprove();
56          passed();
57      }
58      public void testPeopleFlowBlanketApproveNav(JiraAwareFailable failable) throws Exception {
59          testPeopleFlowBlanketApprove();
60          passed();
61      }
62      
63      public void testPeopleFlowDuplicateEntryBookmark(JiraAwareFailable failable) throws Exception {
64      	testPeopleFlowDuplicateEntry();
65      	passed();
66      }
67      
68      public void testPeopleFlowDuplicateEntryNav(JiraAwareFailable failable) throws Exception {
69      	testPeopleFlowDuplicateEntry();
70      	passed();
71      }
72  
73      protected void testPeopleFlowBlanketApprove() throws Exception {
74          String docId = peopleFlowCreateNew();
75  
76          waitAndClickButtonByText("blanket approve");
77          Thread.sleep(3000);
78          checkForIncidentReport();
79          jGrowl("Blanket Approve");
80          Thread.sleep(5000);
81  
82          //Close the Doc
83          //findElement(By.id("uif-close")).click();
84          //Thread.sleep(3000);
85          driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString());
86          findElement(By.cssSelector("img[alt=\"doc search\"]")).click();
87          Thread.sleep(5000);
88          jGrowl("Document Search is " + docId + " present?");
89          selectFrameIframePortlet();
90          waitAndTypeByName("documentId", docId);
91          jGrowl("Click search");
92          findElement(By.cssSelector("td.infoline > input[name=\"methodToCall.search\"]")).click();
93          waitForTextPresent(DOC_STATUS_FINAL);
94      }
95  
96      protected void testPeopleFlowCreateNew() throws Exception {
97          String docId = peopleFlowCreateNew();
98  
99          waitAndClickButtonByText("submit");
100         Thread.sleep(3000);
101         checkForDocError();
102         checkForIncidentReport();
103 
104         //Close the Doc
105         //findElement(By.id("uif-close")).click();
106         //Thread.sleep(3000);
107         driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString());
108         findElement(By.cssSelector("img[alt=\"doc search\"]")).click();
109         Thread.sleep(5000);
110         jGrowl("Document Search is " + docId + " present?");
111         selectFrameIframePortlet();
112         waitAndTypeByName("documentId", docId);
113         jGrowl("Click search");
114         findElement(By.cssSelector("td.infoline > input[name=\"methodToCall.search\"]")).click();
115         waitForTextPresent(DOC_STATUS_FINAL);
116     }
117 
118     private String peopleFlowCreateNew() throws InterruptedException {
119         selectFrameIframePortlet();
120 
121         waitAndClickByLinkText("Create New");
122 
123         //Save docId
124         waitForElementPresent("div[data-label='Document Number']");
125         String docId = getText("div[data-label='Document Number']");
126         assertTrue(docId != null);
127         jGrowlSticky("Doc Id is " + docId);
128 
129         findElement(By.name("document.documentHeader.documentDescription")).clear();
130         waitAndTypeByName("document.documentHeader.documentDescription", "Description for Document");
131         waitAndSelectByName("document.newMaintainableObject.dataObject.namespaceCode", "KUALI - Kuali Systems");
132         findElement(By.name("document.newMaintainableObject.dataObject.name")).clear();
133         waitAndTypeByName("document.newMaintainableObject.dataObject.name", "Document Name" +
134                 AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars());
135 
136         jGrowl("Add Member kr");
137         findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")).clear();
138         waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName", "kr");
139         waitAndClick(By.cssSelector("button[data-loadingmessage='Adding Line...']"));
140         Thread.sleep(3000);
141         checkForIncidentReport();
142 
143         jGrowl("Add Member admin");
144         findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")).clear();
145         waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName", "admin");
146         waitAndClick(By.cssSelector("button[data-loadingmessage='Adding Line...']"));
147         Thread.sleep(3000);
148         return docId;
149     }
150 
151     private void testPeopleFlowDuplicateEntry() throws Exception {
152     	selectFrameIframePortlet();
153         waitAndClickByLinkText("Create New");
154         clearTextByName("document.documentHeader.documentDescription");
155         waitAndTypeByName("document.documentHeader.documentDescription", "Description for Duplicate");
156         waitAndSelectByName("document.newMaintainableObject.dataObject.namespaceCode", "KUALI - Kuali Systems");
157         clearTextByName("document.newMaintainableObject.dataObject.name");
158         String tempValue=AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
159         waitAndTypeByName("document.newMaintainableObject.dataObject.name", "Document Name"+tempValue);
160         waitAndClickButtonByText("submit");
161         waitForTextPresent("Document was successfully submitted.");
162         selectTopFrame();
163         waitAndClickByLinkText("Main Menu");
164         waitAndClickByLinkText("People Flow");
165         selectFrameIframePortlet();
166         waitAndClickByLinkText("Create New");
167         clearTextByName("document.documentHeader.documentDescription");
168         waitAndTypeByName("document.documentHeader.documentDescription", "Description for Duplicate");
169         waitAndSelectByName("document.newMaintainableObject.dataObject.namespaceCode", "KUALI - Kuali Systems");
170         clearTextByName("document.newMaintainableObject.dataObject.name");
171         waitAndTypeByName("document.newMaintainableObject.dataObject.name", "Document Name"+tempValue);
172         waitAndClickButtonByText("submit");
173         waitForTextPresent("A PeopleFlow already exists with the name");
174     }
175 }