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       * AutomatedFunctionalTestUtils.PORTAL + "?channelTitle=People%20Flow&channelUrl="
30       *  + WebDriverUtils.getBaseUrlString() + AutomatedFunctionalTestUtils.KRAD_LOOKUP_METHOD
31       *  + "org.kuali.rice.kew.impl.peopleflow.PeopleFlowBo"
32       *  + "&returnLocation=" + AutomatedFunctionalTestUtils.AutomatedFunctionalTestUtils + 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          PeopleFlowDocInfo docInfo = peopleFlowCreateNew();
75  
76          waitAndClickBlanketApprove();
77          waitAndClickConfirmBlanketApproveOk();
78          Thread.sleep(3000);
79          acceptAlert();
80          Thread.sleep(3000);
81          checkForIncidentReport();
82          jGrowl("Blanket Approve");
83          Thread.sleep(5000);
84  
85          //Close the Doc
86          //findElement(By.id("uif-close")).click();
87          //Thread.sleep(3000);
88          driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString());
89          findElement(By.cssSelector("img[alt=\"doc search\"]")).click();
90          Thread.sleep(5000);
91          jGrowl("Document Search is " + docInfo.getDocId() + " present?");
92          selectFrameIframePortlet();
93          waitAndTypeByName("documentId", docInfo.getDocId());
94          jGrowl("Click search");
95          findElement(By.cssSelector("td.infoline > input[name=\"methodToCall.search\"]")).click();
96          waitForTextPresent(DOC_STATUS_FINAL);
97      }
98  
99      protected void testPeopleFlowCreateNew() throws Exception {
100         PeopleFlowDocInfo docInfo = peopleFlowCreateNew();
101 
102         waitAndClickSubmitByText();
103         waitAndClickConfirmationOk();
104         Thread.sleep(3000);
105         checkForDocError();
106         checkForIncidentReport();
107 
108         //Close the Doc
109         //findElement(By.id("uif-close")).click();
110         //Thread.sleep(3000);
111         driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString());
112         findElement(By.cssSelector("img[alt=\"doc search\"]")).click();
113         Thread.sleep(5000);
114         jGrowl("Document Search is " + docInfo.getDocId() + " present?");
115         selectFrameIframePortlet();
116         waitAndTypeByName("documentId", docInfo.getDocId());
117         jGrowl("Click search");
118         findElement(By.cssSelector("td.infoline > input[name=\"methodToCall.search\"]")).click();
119         waitForTextPresent(DOC_STATUS_FINAL);
120 
121 
122         jGrowl("Find our PeopleFlow by lookup");
123         driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString());
124         waitAndClick(By.linkText("Main Menu"));
125         Thread.sleep(3000);
126 
127         waitAndClick(By.linkText("People Flow"));
128         waitForPageToLoad();
129         selectFrameIframePortlet();
130         waitAndTypeByName("lookupCriteria[name]", docInfo.getName());
131 
132         jGrowl("Click search");
133         waitAndClickByXpath(SEARCH_XPATH_3);
134         waitForPageToLoad();
135         waitAndClickByLinkText("edit");
136         waitForPageToLoad();
137 
138         jGrowl("verify the forceAction values for our two stops");
139         assertFalse(findElement(By.name("document.newMaintainableObject.dataObject.members[0].forceAction")).isSelected());
140         assertTrue(findElement(By.name("document.newMaintainableObject.dataObject.members[1].forceAction")).isSelected());
141 
142 
143         // TODO: handle graceful cancel from here
144 //        findElement(By.id("ucancel")).click();
145 //        // Say "Yes" to the modal dialog that follows
146     }
147 
148     private PeopleFlowDocInfo peopleFlowCreateNew() throws InterruptedException {
149         selectFrameIframePortlet();
150 
151         waitAndClickByLinkText("Create New");
152         String peopleFlowNamespace = "KUALI - Kuali Systems";
153         String peopleFlowName = "Document Name" +
154                 AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
155 
156         //Save docId
157         waitForElementPresent("div[data-label='Document Number']");
158         String docId = getText("div[data-label='Document Number']");
159         assertTrue(docId != null);
160         jGrowlSticky("Doc Id is " + docId);
161 
162         findElement(By.name("document.documentHeader.documentDescription")).clear();
163         waitAndTypeByName("document.documentHeader.documentDescription", "Description for Document");
164         waitAndSelectByName("document.newMaintainableObject.dataObject.namespaceCode", peopleFlowNamespace);
165         findElement(By.name("document.newMaintainableObject.dataObject.name")).clear();
166         waitAndTypeByName("document.newMaintainableObject.dataObject.name", peopleFlowName);
167 
168         jGrowl("Add Member kr");
169         findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")).clear();
170         waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName", "kr");
171         findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].forceAction")).click();
172         waitAndClick(By.cssSelector("button[data-loadingmessage='Adding Line...']"));
173         Thread.sleep(3000);
174         checkForIncidentReport();
175 
176         jGrowl("Add Member admin");
177         findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].priority")).clear();
178         waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].priority", "2");
179         findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")).clear();
180         waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName", "admin");
181         waitAndClick(By.cssSelector("button[data-loadingmessage='Adding Line...']"));
182         Thread.sleep(3000);
183 
184         return new PeopleFlowDocInfo(docId, peopleFlowNamespace, peopleFlowName);
185     }
186 
187     private void testPeopleFlowDuplicateEntry() throws Exception {
188     	selectFrameIframePortlet();
189         waitAndClickByLinkText("Create New");
190         clearTextByName("document.documentHeader.documentDescription");
191         waitAndTypeByName("document.documentHeader.documentDescription", "Description for Duplicate");
192         waitAndSelectByName("document.newMaintainableObject.dataObject.namespaceCode", "KUALI - Kuali Systems");
193         clearTextByName("document.newMaintainableObject.dataObject.name");
194         String tempValue=AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars();
195         waitAndTypeByName("document.newMaintainableObject.dataObject.name", "Document Name"+tempValue);
196         waitAndClickSubmitByText();
197         waitAndClickConfirmationOk();
198         waitForTextPresent("Document was successfully submitted.");
199         selectTopFrame();
200         waitAndClickByLinkText("Main Menu");
201         waitAndClickByLinkText("People Flow");
202         selectFrameIframePortlet();
203         waitAndClickByLinkText("Create New");
204         clearTextByName("document.documentHeader.documentDescription");
205         waitAndTypeByName("document.documentHeader.documentDescription", "Description for Duplicate");
206         waitAndSelectByName("document.newMaintainableObject.dataObject.namespaceCode", "KUALI - Kuali Systems");
207         clearTextByName("document.newMaintainableObject.dataObject.name");
208         waitAndTypeByName("document.newMaintainableObject.dataObject.name", "Document Name"+tempValue);
209         waitAndClickSubmitByText();
210         waitAndClickConfirmationOk();
211         waitForTextPresent("A PeopleFlow already exists with the name");
212     }
213 
214     /**
215      * holds a few key pieces of info about a PeopleFlow document
216      */
217     public static class PeopleFlowDocInfo {
218         private final String docId;
219         private final String namespace;
220         private final String name;
221 
222         /**
223          * Construct an object with information about a PeopleFlow document
224          */
225         public PeopleFlowDocInfo(String docId, String namespace, String name) {
226             this.docId = docId;
227             this.namespace = namespace;
228             this.name = name;
229         }
230 
231         /**
232          * @return the document ID
233          */
234         public String getDocId() {
235             return docId;
236         }
237 
238         /**
239          * @return the namespace of the PeopleFlow
240          */
241         public String getNamespace() {
242             return namespace;
243         }
244 
245         /**
246          * @return the name of the PeopleFlow
247          */
248         public String getName() {
249             return name;
250         }
251     }
252 }