1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
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  
25  
26  public class PeopleFlowCreateNewAftBase extends MainTmplMthdSTNavBase{
27  
28      
29  
30  
31  
32  
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  
46  
47  
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          
86          
87          
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         waitAndClickConfirmSubmitOk();
104         Thread.sleep(3000);
105         checkForDocError();
106         checkForIncidentReport();
107 
108         
109         
110         
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         
144 
145 
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         
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         waitAndClickConfirmSubmitOk();
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         waitAndClickConfirmSubmitOk();
211         waitForTextPresent("A PeopleFlow already exists with the name");
212     }
213 
214     
215 
216 
217     public static class PeopleFlowDocInfo {
218         private final String docId;
219         private final String namespace;
220         private final String name;
221 
222         
223 
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 
233 
234         public String getDocId() {
235             return docId;
236         }
237 
238         
239 
240 
241         public String getNamespace() {
242             return namespace;
243         }
244 
245         
246 
247 
248         public String getName() {
249             return name;
250         }
251     }
252 }