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 PeopleFlowDocInfo docInfo = peopleFlowCreateNew(); 075 076 waitAndClickBlanketApprove(); 077 waitAndClickConfirmBlanketApproveOk(); 078 Thread.sleep(3000); 079 acceptAlert(); 080 Thread.sleep(3000); 081 checkForIncidentReport(); 082 jGrowl("Blanket Approve"); 083 Thread.sleep(5000); 084 085 //Close the Doc 086 //findElement(By.id("uif-close")).click(); 087 //Thread.sleep(3000); 088 driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString()); 089 findElement(By.cssSelector("img[alt=\"doc search\"]")).click(); 090 Thread.sleep(5000); 091 jGrowl("Document Search is " + docInfo.getDocId() + " present?"); 092 selectFrameIframePortlet(); 093 waitAndTypeByName("documentId", docInfo.getDocId()); 094 jGrowl("Click search"); 095 findElement(By.cssSelector("td.infoline > input[name=\"methodToCall.search\"]")).click(); 096 waitForTextPresent(DOC_STATUS_FINAL); 097 } 098 099 protected void testPeopleFlowCreateNew() throws Exception { 100 PeopleFlowDocInfo docInfo = peopleFlowCreateNew(); 101 102 waitAndClickSubmitByText(); 103 waitAndClickConfirmSubmitOk(); 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 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 * 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}