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 org.kuali.rice.krad.labs.lookups; 017 018import org.junit.Before; 019import org.junit.Test; 020import org.kuali.rice.testtools.selenium.AutomatedFunctionalTestUtils; 021 022/** 023 * @author Kuali Rice Team (rice.collab@kuali.org) 024 */ 025public class LabsLookupDefaultCreateNewBlanketApproveAft extends LabsLookupBase { 026 027 /** 028 * /kr-krad/lookup?methodToCall=start&viewId=LabsLookup-DefaultView&hideReturnLink=true 029 */ 030 public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LabsLookup-DefaultView&hideReturnLink=true"; 031 032 protected String[][] inputVerifyDetails; 033 034 @Before 035 @Override 036 public void testSetUp() { 037 super.testSetUp(); 038 getDescriptionUnique(); // init uniqueString 039 inputVerifyDetails = new String[][]{ 040 {"Travel Account Name:", uniqueString}, 041 {"Travel Account Number:", "z" + uniqueString.substring(4, 13)}, 042 {"Fiscal Officer User ID:", "fran"}, 043 {"Fiscal Officer:", "fran"}, 044 {"Fiscal Officer Name:", "fran"}, 045 {"Code And Description:", "CAT - Clearing"} 046 }; 047 } 048 049 @Override 050 protected void blanketApproveSuccessfully() throws InterruptedException { 051 waitAndClickBlanketApprove(); 052 waitAndClickConfirmBlanketApproveOk(); 053 acceptAlertIfPresent(); // LabsLookupDefaultCreateNewBlanketApproveAft 054 waitForProgressLoading(); 055// Blanket submit has been updated to go to the hub page so error messages and doc state are no longer testable 056// checkForDocErrorKrad(); 057// waitForTextPresent("Document was successfully approved."); 058 } 059 060 061 @Override 062 protected String getBookmarkUrl() { 063 return BOOKMARK_URL; 064 } 065 066 @Override 067 public String getUserName() { 068 return "admin"; // must have blanket approve rights 069 } 070 071 @Override 072 protected String getDescriptionUnique() { 073 // "z" + to keep these at the bottom of the search results so as not to interfere with other AFTs. 074 if (uniqueString == null) { 075 uniqueString = "z" + AutomatedFunctionalTestUtils.createUniqueDtsPlusTwoRandomCharsNot9Digits(); 076 } 077 return getDescriptionBase() + " " + uniqueString; 078 } 079 080 @Override 081 protected void navigate() throws Exception { 082 navigateToLookup("Lookup Default"); 083 } 084 085 @Test 086 public void testLabsLookupDefaultCreateNewBlanketApproveBookmark() throws Exception { 087 testLabsLookupDefaultCreateNewBlanketApprove(); 088 passed(); 089 } 090 091 @Test 092 public void testLabsLookupDefaultCreateNewBlanketApproveWithSubAccountBookmark() throws Exception { 093 testLabsLookupDefaultCreateNewBlanketApproveWithSubAccount(); 094 passed(); 095 } 096 097 @Test 098 public void testLabsLookupDefaultCreateNewBlanketApproveNav() throws Exception { 099 testLabsLookupDefaultCreateNewBlanketApprove(); 100 passed(); 101 } 102 103 @Test 104 public void testLabsLookupDefaultCreateNewBlanketApproveWithSubAccountNav() throws Exception { 105 testLabsLookupDefaultCreateNewBlanketApproveWithSubAccount(); 106 passed(); 107 } 108 109 protected void testLabsLookupDefaultCreateNewBlanketApprove()throws Exception { 110 navigateToCreateNew(); 111 112 // TODO method that accepts full array 113 // TODO flag requires or determine via UI (*) what is required (could miss changes) 114 waitAndTypeLabeledInput("Description:", getDescriptionUnique()); 115 waitAndTypeLabeledInput(inputVerifyDetails[0][0], inputVerifyDetails[0][1]); 116 waitAndTypeLabeledInput("Travel Account Number:", inputVerifyDetails[1][1]); 117 waitAndTypeLabeledInput("Fiscal Officer User ID:", inputVerifyDetails[2][1]); 118 waitAndClickByXpath("//input[@value='CAT']"); 119 120 // TODO convenience method 121 waitAndClickByLinkText("Notes and Attachments (0)"); 122 waitAndTypeByXpath("//textarea[@maxlength='800']", "My Note " + uniqueString); 123 waitAndClickByXpath("//button[@title='Add a Note']"); 124 waitForProgressLoading(); 125 126 // TODO convenience method 127 waitAndClickByLinkText("Ad Hoc Recipients"); 128 waitAndTypeByXpath("//div[@data-parent='Uif-AdHocPersonCollection']/div/input", "admin"); 129 waitAndClickAdHocPersonAdd(); 130 waitForTextPresent("admin, admin"); 131 132 blanketApproveSuccessfully(); 133 134 // search based on name and verify 135 open(getBaseUrlString() + LabsLookupDefaultAft.BOOKMARK_URL); 136 waitAndTypeLabeledInput("Travel Account Name:", inputVerifyDetails[0][1]); 137 waitAndClickSearchByText(); 138 waitForProgressLoading(); 139 waitAndClickLinkContainingText(inputVerifyDetails[1][1]); // "Travel Account Number:" 140 waitForProgressLoading(); 141 gotoLightBox(); 142 assertLabeledTextPresent(inputVerifyDetails); 143 } 144 145 protected void testLabsLookupDefaultCreateNewBlanketApproveWithSubAccount()throws Exception { 146 navigateToCreateNew(); 147 148 waitAndTypeLabeledInput("Description:", getDescriptionUnique()); 149 waitAndTypeLabeledInput("Travel Account Name:", inputVerifyDetails[0][1]); 150 waitAndTypeLabeledInput("Travel Account Number:", inputVerifyDetails[1][1]); 151 waitAndTypeLabeledInput("Fiscal Officer User ID:", inputVerifyDetails[2][1]); 152 waitAndClickByXpath("//input[@value='CAT']"); 153 154 waitAndTypeLabeledInput("Travel Sub Account Number:", uniqueString.substring(0,7) + "sa"); 155 waitAndTypeLabeledInput("Sub Account Name:", "Sub Account " + uniqueString); 156 waitAndClickButtonByText("Add"); 157 waitForProgressAddingLine(); 158 159 waitAndClickByLinkText("Notes and Attachments (0)"); 160 waitAndTypeByXpath("//textarea[@maxlength='800']", "My Note " + uniqueString); 161 waitAndClickByXpath("//button[@title='Add a Note']"); 162 waitForProgressLoading(); 163 164 waitAndClickByLinkText("Ad Hoc Recipients"); 165 waitAndTypeByXpath("//div[@data-parent='Uif-AdHocPersonCollection']/div/input", "admin"); 166 waitAndClickAdHocPersonAdd(); 167 waitForTextPresent("admin, admin"); 168 169 blanketApproveSuccessfully(); 170 171 // search based on name and verify 172 open(getBaseUrlString() + LabsLookupDefaultAft.BOOKMARK_URL); 173 waitAndTypeLabeledInput("Travel Account Name:", inputVerifyDetails[0][1]); 174 waitAndClickSearchByText(); 175 waitForProgressLoading(); 176 waitAndClickLinkContainingText(inputVerifyDetails[1][1]); // "Travel Account Number:" 177 waitForProgressLoading(); 178 gotoLightBox(); 179 assertLabeledTextPresent(inputVerifyDetails); 180 // Travel Sub Account Number should be uppercased via UI 181 assertTextPresent(new String[]{(uniqueString.substring(0,7) + "sa").toUpperCase(), "Sub Account " + uniqueString}); 182 } 183}