001/** 002 * Copyright 2005-2015 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 jGrowl("Blanket Approve"); 077 waitAndClickBlanketApprove(); 078 waitAndClickConfirmBlanketApproveOk(); 079 acceptAlertIfPresent(); 080 waitForProgressLoading(); 081 checkForIncidentReport(); 082 083 driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString()); 084 findElement(By.cssSelector("img[alt=\"doc search\"]")).click(); 085 Thread.sleep(5000); 086 jGrowl("Document Search is " + docInfo.getDocId() + " present?"); 087 selectFrameIframePortlet(); 088 waitAndTypeByName("documentId", docInfo.getDocId()); 089 jGrowl("Click search"); 090 findElement(By.cssSelector("td.infoline > input[name=\"methodToCall.search\"]")).click(); 091 waitForTextPresent(DOC_STATUS_FINAL); 092 } 093 094 protected void testPeopleFlowCreateNew() throws Exception { 095 PeopleFlowDocInfo docInfo = peopleFlowCreateNew(); 096 097 waitAndClickSubmitByText(); 098 waitAndClickConfirmSubmitOk(); 099 Thread.sleep(3000); 100 checkForDocError(); 101 checkForIncidentReport(); 102 103 driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString()); 104 findElement(By.cssSelector("img[alt=\"doc search\"]")).click(); 105 Thread.sleep(5000); 106 jGrowl("Document Search is " + docInfo.getDocId() + " present?"); 107 selectFrameIframePortlet(); 108 waitAndTypeByName("documentId", docInfo.getDocId()); 109 jGrowl("Click search"); 110 findElement(By.cssSelector("td.infoline > input[name=\"methodToCall.search\"]")).click(); 111 waitForTextPresent(DOC_STATUS_FINAL); 112 113 114 jGrowl("Find our PeopleFlow by lookup"); 115 driver.switchTo().window(driver.getWindowHandles().toArray()[0].toString()); 116 waitAndClick(By.linkText("Main Menu")); 117 Thread.sleep(3000); 118 119 waitAndClick(By.linkText("People Flow")); 120 waitForPageToLoad(); 121 selectFrameIframePortlet(); 122 waitAndTypeByName("lookupCriteria[name]", docInfo.getName()); 123 124 jGrowl("Click search"); 125 waitAndClickByXpath(SEARCH_XPATH_3); 126 waitForPageToLoad(); 127 waitAndClickByLinkText("edit"); 128 waitForPageToLoad(); 129 130 jGrowl("verify the forceAction values for our two stops"); 131 assertFalse(findElement(By.name("document.newMaintainableObject.dataObject.members[0].forceAction")).isSelected()); 132 assertTrue(findElement(By.name("document.newMaintainableObject.dataObject.members[1].forceAction")).isSelected()); 133 } 134 135 private PeopleFlowDocInfo peopleFlowCreateNew() throws InterruptedException { 136 selectFrameIframePortlet(); 137 138 waitAndClickByLinkText("Create New"); 139 String peopleFlowNamespace = "KUALI - Kuali Systems"; 140 String peopleFlowName = "Document Name" + 141 AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars(); 142 143 //Save docId 144 waitForElementPresent("div[data-label='Document Number']"); 145 String docId = getText("div[data-label='Document Number']"); 146 assertTrue(docId != null); 147 jGrowlSticky("Doc Id is " + docId); 148 149 findElement(By.name("document.documentHeader.documentDescription")).clear(); 150 waitAndTypeByName("document.documentHeader.documentDescription", "Description for Document"); 151 waitAndSelectByName("document.newMaintainableObject.dataObject.namespaceCode", peopleFlowNamespace); 152 findElement(By.name("document.newMaintainableObject.dataObject.name")).clear(); 153 waitAndTypeByName("document.newMaintainableObject.dataObject.name", peopleFlowName); 154 155 jGrowl("Add Member kr"); 156 findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")).clear(); 157 waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName", "kr"); 158 findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].forceAction")).click(); 159 waitAndClick(By.cssSelector("button[data-loadingmessage='Adding Line...']")); 160 Thread.sleep(3000); 161 checkForIncidentReport(); 162 163 jGrowl("Add Member admin"); 164 findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].priority")).clear(); 165 waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].priority", "2"); 166 findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName")).clear(); 167 waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName", "admin"); 168 waitAndClick(By.cssSelector("button[data-loadingmessage='Adding Line...']")); 169 Thread.sleep(3000); 170 171 return new PeopleFlowDocInfo(docId, peopleFlowNamespace, peopleFlowName); 172 } 173 174 private void testPeopleFlowDuplicateEntry() throws Exception { 175 selectFrameIframePortlet(); 176 waitAndClickByLinkText("Create New"); 177 clearTextByName("document.documentHeader.documentDescription"); 178 waitAndTypeByName("document.documentHeader.documentDescription", "Description for Duplicate"); 179 waitAndSelectByName("document.newMaintainableObject.dataObject.namespaceCode", "KUALI - Kuali Systems"); 180 clearTextByName("document.newMaintainableObject.dataObject.name"); 181 String tempValue=AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars(); 182 waitAndTypeByName("document.newMaintainableObject.dataObject.name", "Document Name"+tempValue); 183 waitAndClickSubmitByText(); 184 waitAndClickConfirmSubmitOk(); 185 waitForTextPresent("Document was successfully submitted."); 186 selectTopFrame(); 187 waitAndClickByLinkText("Main Menu"); 188 waitAndClickByLinkText("People Flow"); 189 selectFrameIframePortlet(); 190 waitAndClickByLinkText("Create New"); 191 clearTextByName("document.documentHeader.documentDescription"); 192 waitAndTypeByName("document.documentHeader.documentDescription", "Description for Duplicate"); 193 waitAndSelectByName("document.newMaintainableObject.dataObject.namespaceCode", "KUALI - Kuali Systems"); 194 clearTextByName("document.newMaintainableObject.dataObject.name"); 195 waitAndTypeByName("document.newMaintainableObject.dataObject.name", "Document Name"+tempValue); 196 waitAndClickSubmitByText(); 197 waitAndClickConfirmSubmitOk(); 198 waitForTextPresent("A PeopleFlow already exists with the name"); 199 } 200 201 /** 202 * holds a few key pieces of info about a PeopleFlow document 203 */ 204 public static class PeopleFlowDocInfo { 205 private final String docId; 206 private final String namespace; 207 private final String name; 208 209 /** 210 * Construct an object with information about a PeopleFlow document 211 */ 212 public PeopleFlowDocInfo(String docId, String namespace, String name) { 213 this.docId = docId; 214 this.namespace = namespace; 215 this.name = name; 216 } 217 218 /** 219 * @return the document ID 220 */ 221 public String getDocId() { 222 return docId; 223 } 224 225 /** 226 * @return the namespace of the PeopleFlow 227 */ 228 public String getNamespace() { 229 return namespace; 230 } 231 232 /** 233 * @return the name of the PeopleFlow 234 */ 235 public String getName() { 236 return name; 237 } 238 } 239}