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.junit.Before; 019import org.junit.BeforeClass; 020import org.junit.Test; 021import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils; 022import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase; 023import org.kuali.rice.testtools.selenium.WebDriverUtils; 024import org.openqa.selenium.By; 025import static edu.sampleu.main.PeopleFlowCreateNewAftBase.PeopleFlowDocInfo; 026/** 027 * test that checks that rules can be added to agendas 028 * 029 * @author Kuali Rice Team (rice.collab@kuali.org) 030 */ 031public class AgendaEditorAndOrToggleSyncAft extends WebDriverLegacyITBase { 032 public static final String PEOPLE_FLOW_LINK_TEXT = "People Flow"; 033 public static final String BOOKMARK_URL = 034 AutomatedFunctionalTestUtils.PORTAL 035 + "?channelTitle=Agenda%20Lookup&channelUrl=" 036 + WebDriverUtils.getBaseUrlString() 037 + AutomatedFunctionalTestUtils.KRAD_LOOKUP_METHOD 038 + "org.kuali.rice.krms.impl.repository.AgendaBo" 039 + AutomatedFunctionalTestUtils.SHOW_MAINTENANCE_LINKS 040 + "&returnLocation=" 041 + AutomatedFunctionalTestUtils.PORTAL_URL 042 + AutomatedFunctionalTestUtils.HIDE_RETURN_LINK; 043 044 public static final String ID_TEXT = "T1001"; 045 046 private String getPeopleFlowId() throws Exception { 047 selectParentWindow(); 048 waitAndClickMainMenu(); 049 waitAndClickByLinkText(PEOPLE_FLOW_LINK_TEXT); 050 waitForPageToLoad(); 051 052 PeopleFlowDocInfo docInfo = peopleFlowCreateNew(); 053 jGrowl("people flow id is created"); 054 055 selectParentWindow(); 056 waitAndClickMainMenu(); 057 waitAndClickByLinkText(PEOPLE_FLOW_LINK_TEXT); 058 waitForPageToLoad(); 059 jGrowl("ready to search people flow"); 060 061 selectFrameIframePortlet(); 062 selectByName("lookupCriteria[namespaceCode]", "KUALI - Kuali Systems"); 063 waitClearAndType("lookupCriteria[name]", docInfo.getName()); 064 waitAndClickByXpath("//button[contains(text(),'Search')]"); 065 waitForTextPresent("edit"); 066 jGrowl("search people flow search complete"); 067 068 String id = getTextByXpath("(//span[contains(@id,'line0_control')])[1]"); 069 assertTrue(id != null); 070 jGrowl("people flow id is " + id); 071 072 selectParentWindow(); 073 waitAndClickMainMenu(); 074 waitAndClickByLinkText(AGENDA_LOOKUP_LINK_TEXT); 075 waitForPageToLoad(); 076 077 return id; 078 } 079 080 private PeopleFlowDocInfo peopleFlowCreateNew() throws Exception { 081 selectFrameIframePortlet(); 082 083 waitAndClickByLinkText("Create New"); 084 String peopleFlowNamespace = "KUALI - Kuali Systems"; 085 String peopleFlowName = "Document Name" + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomChars(); 086 087 //Save docId 088 waitForElementPresentByXpath("//div[@data-label='Document Number']/span"); 089 String docId = getTextByXpath("//div[@data-label='Document Number']/span"); 090 assertTrue(docId != null); 091 jGrowlSticky("Doc Id is " + docId); 092 093 clearTextByName("document.documentHeader.documentDescription"); 094 waitAndTypeByName("document.documentHeader.documentDescription", "Description for Document"); 095 waitAndSelectByName("document.newMaintainableObject.dataObject.namespaceCode", peopleFlowNamespace); 096 clearTextByName("document.newMaintainableObject.dataObject.name"); 097 waitAndTypeByName("document.newMaintainableObject.dataObject.name", peopleFlowName); 098 099 jGrowl("Add Member kr"); 100 clearTextByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName"); 101 waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName", "kr"); 102 findElement(By.name("newCollectionLines['document.newMaintainableObject.dataObject.members'].forceAction")).click(); 103 waitAndClick(By.cssSelector("button[data-loadingmessage='Adding Line...']")); 104 Thread.sleep(3000); 105 checkForIncidentReport(); 106 107 jGrowl("Add Member admin"); 108 clearTextByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].priority"); 109 waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].priority", "2"); 110 clearTextByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName"); 111 waitAndTypeByName("newCollectionLines['document.newMaintainableObject.dataObject.members'].memberName", "admin"); 112 waitAndClick(By.cssSelector("button[data-loadingmessage='Adding Line...']")); 113 Thread.sleep(3000); 114 115 waitAndClickButtonByExactText("Save"); 116 waitForTextPresent("SAVED", WebDriverUtils.configuredImplicityWait() * 4); 117 waitForTextPresent(" Document was successfully saved."); 118 119 waitAndClickButtonByExactText("Submit"); 120 waitAndClickConfirmSubmitOk(); 121 waitForTextPresent("ENROUTE"); 122 waitForTextPresent("Document was successfully submitted."); 123 124 return new PeopleFlowDocInfo(docId, peopleFlowNamespace, peopleFlowName); 125 } 126 127 @Override 128 protected String getBookmarkUrl() { 129 return BOOKMARK_URL; 130 } 131 132 @Override 133 protected void navigate() throws Exception { 134 waitAndClickByLinkText(AGENDA_LOOKUP_LINK_TEXT); 135 waitForPageToLoad(); 136 } 137 138 protected void testAgendaEditorAndOrToggleSync() throws Exception { 139 selectFrameIframePortlet(); 140 waitClearAndType("lookupCriteria[name]", "SimpleAgendaCompoundProp"); 141 waitAndClickByXpath("//button[contains(text(),'Search')]"); 142 waitAndClickByXpath("//a[contains(text(),'edit')]"); 143 selectFrameIframePortlet(); 144 waitAndClickByXpath("//a/div[contains(text(),'CmpdTestRule: For testing compound props')]"); 145 waitAndClickByXpath("//button[contains(text(),'Edit Rule')]"); 146 selectFrameIframePortlet(); 147 waitForTextPresent("( Campus Code = Muir AND Campus Code = Revelle AND Campus Code = Warren )"); 148 selectByName("document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].children[1].data.proposition.compoundOpCode","OR"); 149 selectByName("document.newMaintainableObject.dataObject.agendaItemLine.rule.propositionTree.rootElement.children[0].children[3].data.proposition.compoundOpCode","OR"); 150 waitForTextNotPresent("( Campus Code = Muir AND Campus Code = Revelle AND Campus Code = Warren )"); 151 waitForTextPresent("( Campus Code = Muir OR Campus Code = Revelle OR Campus Code = Warren )"); 152 } 153 154 protected void testAgendaEditorEditRuleAddActionsBlank() throws Exception { 155 //Save & Submit 156 testFillRequiredDetails("",null); 157 waitForTextPresent("INITIATED"); 158 waitAndClickButtonByExactText("Save"); 159 waitForTextPresent("SAVED"); 160 waitForTextPresent(" Document was successfully saved."); 161 waitAndClickButtonByExactText("Submit"); 162 waitAndClickConfirmSubmitOk(); 163 waitForTextPresent("ENROUTE"); 164 waitForTextPresent("Document was successfully submitted."); 165 166 //Blanket Approve 167 selectParentWindow(); 168 waitAndClickMainMenu(); 169 navigate(); 170 testFillRequiredDetails("",null); 171 waitForTextPresent("INITIATED"); 172 waitAndClickButtonByExactText("Blanket Approve"); 173 waitAndClickConfirmBlanketApproveOk(); 174 } 175 176 protected void testAgendaEditorEditRuleAddActionsKrmsActionResolverType() throws Exception { 177 //Save & Submit 178 selectParentWindow(); 179 waitAndClickMainMenu(); 180 navigate(); 181 testFillRequiredDetails("KrmsActionResolverType",null); 182 waitForTextPresent("INITIATED"); 183 waitAndClickButtonByExactText("Save"); 184 waitForTextPresent("SAVED"); 185 waitForTextPresent(" Document was successfully saved."); 186 waitAndClickButtonByExactText("Submit"); 187 waitAndClickConfirmSubmitOk(); 188 waitForTextPresent("ENROUTE"); 189 waitForTextPresent("Document was successfully submitted."); 190 191 //Blanket Approve 192 selectParentWindow(); 193 waitAndClickMainMenu(); 194 navigate(); 195 testFillRequiredDetails("KrmsActionResolverType",null); 196 waitForTextPresent("INITIATED"); 197 waitAndClickButtonByExactText("Blanket Approve"); 198 waitAndClickConfirmBlanketApproveOk(); 199 } 200 201 protected void testAgendaEditorEditRuleAddActionsNotifyPeopleFlow(String peopleFlowId) throws Exception { 202 //Save & Submit 203 selectParentWindow(); 204 waitAndClickMainMenu(); 205 navigate(); 206 testFillRequiredDetails("Notify PeopleFlow",peopleFlowId); 207 waitForTextPresent("INITIATED"); 208 waitAndClickButtonByExactText("Save"); 209 waitForTextPresent("SAVED"); 210 waitForTextPresent(" Document was successfully saved."); 211 waitAndClickButtonByExactText("Submit"); 212 waitAndClickConfirmSubmitOk(); 213 waitForTextPresent("ENROUTE"); 214 waitForTextPresent("Document was successfully submitted."); 215 216 //Blanket Approve 217 selectParentWindow(); 218 waitAndClickMainMenu(); 219 navigate(); 220 testFillRequiredDetails("Notify PeopleFlow",peopleFlowId); 221 waitForTextPresent("INITIATED"); 222 waitAndClickButtonByExactText("Blanket Approve"); 223 waitAndClickConfirmBlanketApproveOk(); 224 } 225 226 protected void testAgendaEditorEditRuleAddActionsRouteToPeopleFlow(String peopleFlowId) throws Exception { 227 //Save & Submit 228 selectParentWindow(); 229 waitAndClickMainMenu(); 230 navigate(); 231 testFillRequiredDetails("Route to PeopleFlow",peopleFlowId); 232 waitForTextPresent("INITIATED"); 233 waitAndClickButtonByExactText("Save"); 234 waitForTextPresent("SAVED"); 235 waitForTextPresent(" Document was successfully saved."); 236 waitAndClickButtonByExactText("Submit"); 237 waitAndClickConfirmSubmitOk(); 238 waitForTextPresent("ENROUTE"); 239 waitForTextPresent("Document was successfully submitted."); 240 241 //Blanket Approve 242 selectParentWindow(); 243 waitAndClickMainMenu(); 244 navigate(); 245 testFillRequiredDetails("Route to PeopleFlow",peopleFlowId); 246 waitForTextPresent("INITIATED"); 247 waitAndClickButtonByExactText("Blanket Approve"); 248 waitAndClickConfirmBlanketApproveOk(); 249 } 250 251 protected void testAgendaEditorEditRuleAddActionsValidationAction() throws Exception { 252 //Save & Submit 253 selectParentWindow(); 254 waitAndClickMainMenu(); 255 navigate(); 256 testFillRequiredDetails("Validation Action",null); 257 waitForTextPresent("INITIATED"); 258 waitAndClickButtonByExactText("Save"); 259 waitForTextPresent("SAVED"); 260 waitForTextPresent(" Document was successfully saved."); 261 waitAndClickButtonByExactText("Submit"); 262 waitAndClickConfirmSubmitOk(); 263 waitForTextPresent("ENROUTE"); 264 waitForTextPresent("Document was successfully submitted."); 265 266 //Blanket Approve 267 selectParentWindow(); 268 waitAndClickMainMenu(); 269 navigate(); 270 testFillRequiredDetails("Validation Action",null); 271 waitForTextPresent("INITIATED"); 272 waitAndClickButtonByExactText("Blanket Approve"); 273 waitAndClickConfirmBlanketApproveOk(); 274 } 275 276 private void testFillRequiredDetails(String selectValue,String peopleFlowId) throws Exception { 277 selectFrameIframePortlet(); 278 waitClearAndType("lookupCriteria[id]", ID_TEXT); 279 waitAndClickByXpath("//button[contains(text(),'Search')]"); 280 waitAndClickByXpath("//a[contains(text(),'edit')]"); 281 selectFrameIframePortlet(); 282 waitAndClickByXpath("//a[@class='agendaNode ruleNode']"); 283 waitAndClickByXpath("//button[contains(text(),'Edit Rule')]"); 284 selectFrameIframePortlet(); 285 selectByName("document.newMaintainableObject.dataObject.agendaItemLineRuleAction.typeId", selectValue); 286 287 if (selectValue.equals("KrmsActionResolverType") || selectValue.equalsIgnoreCase("Validation Action")){ 288 waitClearAndType("document.newMaintainableObject.dataObject.agendaItemLineRuleAction.name", "ActionName"); 289 } 290 291 waitForElementPresentByXpath("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[peopleFlowId]"); 292 293 if(selectValue.equalsIgnoreCase("Notify PeopleFlow") || selectValue.equalsIgnoreCase("Route to PeopleFlow")){ 294 waitClearAndType("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[peopleFlowId]", peopleFlowId); 295 waitClearAndType("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[peopleFlowName]", "Document Name1412916151718sz"); 296 waitClearAndType("document.newMaintainableObject.dataObject.agendaItemLineRuleAction.name", "test"); 297 }else if(selectValue.equalsIgnoreCase("Validation Action")) { 298 waitAndClickByName("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[actionTypeCode]"); 299 waitClearAndType("document.newMaintainableObject.dataObject.customRuleActionAttributesMap[actionMessage]","This is msg"); 300 } 301 waitAndClickButtonByExactText("Update Rule"); 302 acceptAlertIfPresent(); 303 } 304 305 protected void waitClearAndType(String name, String value) throws Exception { 306 clearTextByName(name); 307 waitAndTypeByName(name,value); 308 } 309 310 @Test 311 public void testAgendaEditorAndOrToggleSyncBookmark() throws Exception { 312 testAgendaEditorAndOrToggleSync(); 313 passed(); 314 } 315 316 @Test 317 public void testAgendaEditorAndOrToggleSyncNav() throws Exception { 318 testAgendaEditorAndOrToggleSync(); 319 passed(); 320 } 321 322 @Test 323 public void testAgendaEditorAddActionsBookmark() throws Exception { 324 String peopleFlowId = getPeopleFlowId(); 325 testAgendaEditorEditRuleAddActionsBlank(); 326 testAgendaEditorEditRuleAddActionsKrmsActionResolverType(); 327 testAgendaEditorEditRuleAddActionsNotifyPeopleFlow(peopleFlowId); 328 testAgendaEditorEditRuleAddActionsRouteToPeopleFlow(peopleFlowId); 329 testAgendaEditorEditRuleAddActionsValidationAction(); 330 passed(); 331 } 332 333 @Test 334 public void testAgendaEditorAddActionsNav() throws Exception { 335 String peopleFlowId = getPeopleFlowId(); 336 testAgendaEditorEditRuleAddActionsBlank(); 337 testAgendaEditorEditRuleAddActionsKrmsActionResolverType(); 338 testAgendaEditorEditRuleAddActionsNotifyPeopleFlow(peopleFlowId); 339 testAgendaEditorEditRuleAddActionsRouteToPeopleFlow(peopleFlowId); 340 testAgendaEditorEditRuleAddActionsValidationAction(); 341 passed(); 342 } 343} 344