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 */
016 package org.kuali.rice.krad.labs.lookups;
017
018 import org.junit.Test;
019 import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils;
020 import org.openqa.selenium.By;
021 import org.openqa.selenium.WebElement;
022
023 import java.util.List;
024
025 /**
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 */
028 public class LabsLookupDefaultCreateNewBlanketApproveAft extends LabsLookupBase {
029
030 /**
031 * /kr-krad/lookup?methodToCall=start&viewId=LabsLookup-DefaultView&hideReturnLink=true
032 */
033 public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LabsLookup-DefaultView&hideReturnLink=true";
034
035 @Override
036 protected String getBookmarkUrl() {
037 return BOOKMARK_URL;
038 }
039
040 @Override
041 public String getUserName() {
042 return "admin"; // must have blanket approve rights
043 }
044
045 @Override
046 protected void navigate() throws Exception {
047 navigateToLookup("Lookup Default");
048 }
049
050 @Test
051 public void testLabsLookupDefaultCreateNewBlanketApproveBookmark() throws Exception {
052 String account = uniqueAccount();
053 testLabsLookupDefaultCreateNewBlanketApprove(account);
054 passed();
055 }
056
057 private String uniqueAccount() {
058 return "z" + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomCharsNot9Digits();
059 }
060
061 @Test
062 public void testLabsLookupDefaultCreateNewBlanketApproveWithSubAccountBookmark() throws Exception {
063 testLabsLookupDefaultCreateNewBlanketApproveWithSubAccount(uniqueAccount());
064 passed();
065 }
066
067 @Test
068 public void testLabsLookupDefaultCreateNewBlanketApproveNav() throws Exception {
069 testLabsLookupDefaultCreateNewBlanketApprove(uniqueAccount());
070 passed();
071 }
072
073 @Test
074 public void testLabsLookupDefaultCreateNewBlanketApproveWithSubAccountNav() throws Exception {
075 testLabsLookupDefaultCreateNewBlanketApproveWithSubAccount(uniqueAccount());
076 passed();
077 }
078
079 protected void testLabsLookupDefaultCreateNewBlanketApprove(String account)throws Exception {
080 navigateToCreateNew();
081 waitAndTypeByName("document.documentHeader.documentDescription","Labs Default LookUp Created " + account);
082 waitAndTypeByName("document.newMaintainableObject.dataObject.number", account);
083 waitAndTypeByName("document.newMaintainableObject.dataObject.name",account);
084 waitAndTypeByName("document.newMaintainableObject.dataObject.foId","fran");
085 // waitAndTypeByName("document.newMaintainableObject.dataObject.createDate", "01/01/2012"); // no longer input field
086 waitAndClickByXpath("//input[@value='CAT']");
087
088 waitAndClickByLinkText("Notes and Attachments (0)");
089 waitAndTypeByXpath("//textarea[@maxlength='800']","My Note " + account);
090 waitAndClickByXpath("//button[@title='Add a Note']");
091 waitAndClickByLinkText("Ad Hoc Recipients");
092 waitAndTypeByXpath("//div[@data-parent='Uif-AdHocPersonCollection']/div/input","admin");
093 waitAndClickByXpath("//div[@data-parent='Uif-AdHocPersonCollection']/div/span");
094 waitAndClickByXpath("//button[@id='Uif-AdHocPersonCollection_add']");
095 waitAndClickButtonByText("blanket approve");
096 // waitForElementPresent("img[src*=\"info.png\"]"); // Loading to quick?
097
098 // Blanket submit has been updated to go to the hub page so error messages and doc state are no longer testable
099 // if (isElementPresentByXpath("//li[@class='uif-errorMessageItem']")) {
100 // failOnDocErrors();
101 // }
102 //
103 // assertTextPresent(new String[] {"Document was successfully approved.", "ENROUTE"});
104 }
105
106 protected void testLabsLookupDefaultCreateNewBlanketApproveWithSubAccount(String account)throws Exception {
107 navigateToCreateNew();
108 waitAndTypeByName("document.documentHeader.documentDescription","Labs Default LookUp Created " + account);
109 waitAndTypeByName("document.newMaintainableObject.dataObject.number", account);
110 waitAndTypeByName("document.newMaintainableObject.dataObject.name", account);
111 waitAndTypeByName("document.newMaintainableObject.dataObject.foId","fran");
112 // waitAndTypeByName("document.newMaintainableObject.dataObject.createDate", "01/01/2012"); // no longer an input field
113 waitAndClickByXpath("//input[@value='CAT']");
114
115 waitAndTypeByXpath("//div[@data-label='Travel Sub Account Number']/input","1");
116 waitAndTypeByXpath("//div[@data-label='Sub Account Name']/input","Sub Account");
117 waitAndClickButtonByText("add");
118
119 waitAndClickByLinkText("Notes and Attachments (0)");
120 waitAndTypeByXpath("//textarea[@maxlength='800']","My Note " + account);
121 waitAndClickByXpath("//button[@title='Add a Note']");
122 waitAndClickByLinkText("Ad Hoc Recipients");
123 waitAndTypeByXpath("//div[@data-parent='Uif-AdHocPersonCollection']/div/input","admin");
124 waitAndClickByXpath("//div[@data-parent='Uif-AdHocPersonCollection']/div/span");
125 waitAndClickByXpath("//button[@id='Uif-AdHocPersonCollection_add']");
126 waitAndClickButtonByText("blanket approve");
127 // waitForElementPresent("img[src*=\"info.png\"]"); // Loading to quick?
128 // Blanket approve now redirects to the hub so error messagea and doc status are no longer testable https://jira.kuali.org/browse/KULRICE-11463
129 // if (isElementPresentByXpath("//li[@class='uif-errorMessageItem']")) {
130 // failOnDocErrors();
131 // }
132 //
133 // assertTextPresent(new String[] {"Document was successfully approved.", "ENROUTE"});
134 }
135
136 private void failOnDocErrors() {
137 List<WebElement> errors = findElements(By.xpath("//li[@class='uif-errorMessageItem']"));
138 if (errors != null && errors.size() > 0) {
139 StringBuilder sb = new StringBuilder("");
140 for (WebElement error : errors) {
141 sb.append(error.getText()).append("\n");
142 }
143 jiraAwareFail(sb.toString());
144 }
145 }
146 }