View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.demo.travel.application;
17  
18  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
19  import org.junit.Test;
20  import org.openqa.selenium.By;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   */
25  public class DemoTravelAccountAuthorizationAft extends WebDriverLegacyITBase {
26  
27      /**
28       * /kr-krad/approval?methodToCall=docHandler&command=initiate&docTypeName=TravelAuthorization
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/approval?methodToCall=docHandler&command=initiate&docTypeName=TravelAuthorization";
31  
32      /**
33       * submit
34       */
35      public static final String SUBMIT = "submit";
36      
37      /**
38       * Search
39       */
40      public static final String SEARCH = "Search";
41      
42      /**
43       * return value
44       */
45      public static final String RETURN_VALUE = "return value";
46      
47      /**
48       * blanket approve
49       */
50      public static final String BLANKET_APPROVE = "blanket approve";
51  
52      /**
53       * document.documentHeader.documentDescription
54       */
55      public static final String DESCRIPTION_NAME = "document.documentHeader.documentDescription";
56  
57      /**
58       * document.cellPhoneNumber
59       */
60      public static final String CONTACT_NUMBER_NAME = "document.cellPhoneNumber";
61      
62      /**
63       * //div[@id='Uif-PageContentWrapper']/div/div[4]/div[2]/div/table/tbody/tr/
64       */
65      public static final String ACTUAL_EXPENSE_GENERIC_XPATH = "//div[@id='Uif-PageContentWrapper']/div/div[4]/div[2]/div/table/tbody/tr/";
66      
67      /**
68       * //div[@id='Uif-PageContentWrapper']/div/div[5]/div[2]/div/table/tbody/tr/
69       */
70      public static final String DAILY_COST_ESTIMATE_GENERIC_XPATH = "//div[@id='Uif-PageContentWrapper']/div/div[5]/div[2]/div/table/tbody/tr/";
71      
72      @Override
73      public String getBookmarkUrl() {
74          return BOOKMARK_URL;
75      }
76  
77      @Override
78      protected void navigate() throws Exception {
79          waitAndClickById("Demo-DemoLink", "");
80          waitAndClickByLinkText("Travel Authorization Document");
81      }
82  
83      protected void testTravelAccountAuthorizationSubmit() throws Exception {
84      	testTravelAccountAuthorization();
85      	waitAndClickButtonByText("submit");
86  // No isn't visible but Yes is?!
87  //        waitForElementVisibleBy(By.xpath("//label[contains(text(), 'No')]"), "").click();
88  //        waitAndClick(By.xpath("//label[contains(text(), 'No')]"));
89  //        waitAndClickButtonByText("submit");
90          waitAndClick(By.xpath("//label[contains(text(), 'Yes')]"));
91      	waitForTextPresent("Document was successfully");
92      }
93  
94      protected void testTravelAccountAuthorizationBlanketApprove() throws Exception {
95      	testTravelAccountAuthorization();
96      	waitAndClickButtonByText("blanket approve");
97          checkForIncidentReport();
98  // blanket approve redirects to hub so can no longer test for message
99  //    	waitForTextPresent("Document was successfully approved.");
100     }
101 
102     protected void testTravelAccountAuthorization() throws Exception {
103     	waitAndTypeByName(DESCRIPTION_NAME,"Travel Authorization Description");
104     	waitAndTypeByName("document.documentHeader.organizationDocumentNumber","1");
105     	waitAndTypeByName("document.documentHeader.explanation","This is an explanation for Travel Authorization !'");
106     	waitAndClickByXpath("//a[@id='travelerQuickfinder_quickfinder_act']");
107     	waitAndGetReturnValue();
108     	waitAndTypeByName(CONTACT_NUMBER_NAME,"918000884215");
109     	waitAndClickByXpath("//div[@data-label='Primary Destination Id']/div/span/a");
110     	waitAndGetReturnValue();
111     	selectByName("document.travelTypeCode","In State");
112     	waitAndTypeByName("document.tripBegin","02/01/2014");
113     	waitAndTypeByName("document.tripEnd","02/04/2014");
114         jGrowl("Traveler Lookup Quickfinder");
115     	waitAndClickByXpath("//a[@id='travelerQuickfinder_quickfinder_act']");
116     	waitAndGetReturnValue();
117 
118         // KNS/KRAD Equiv M38
119         jGrowl("Click Primary Destination Id Quickfinder");
120     	waitAndClickByXpath("//div[@data-label='Primary Destination Id']/div/span/a");
121     	waitAndGetReturnValue();
122         String primaryDestinationId = waitAndGetAttributeByName("document.tripDestinationId", "value");
123     	waitAndTypeByName("document.expenseLimit","1000");
124 
125     	//Actual Expense
126         waitAndTypeByName("newCollectionLines['document.actualExpenseItems'].travelCompanyName", "Kuali");
127         selectOptionByName("newCollectionLines['document.actualExpenseItems'].travelExpenseTypeCd", "A"); // Airfare
128         waitAndTypeByName("newCollectionLines['document.actualExpenseItems'].expenseDesc", "Expense Description");
129         waitAndTypeByName("newCollectionLines['document.actualExpenseItems'].expenseAmount", "123.12");
130         jGrowl("Click Actual Expense Items Add Button");
131     	waitAndClickByXpath("//button[contains(@data-submit_data, 'document.actualExpenseItems')]");
132     	
133     	//Daily Cost Estimate
134     	waitAndTypeByName("newCollectionLines['document.dailyExpenseEstimates'].perDiemDate","12/12/13");
135         selectOptionByName("newCollectionLines['document.dailyExpenseEstimates'].travelDestinationId", primaryDestinationId);
136         waitAndTypeByName("newCollectionLines['document.dailyExpenseEstimates'].breakfastValue","16");
137         waitAndTypeByName("newCollectionLines['document.dailyExpenseEstimates'].lunchValue","18");
138         waitAndTypeByName("newCollectionLines['document.dailyExpenseEstimates'].dinnerValue","20");
139         waitAndTypeByName("newCollectionLines['document.dailyExpenseEstimates'].incidentalsValue","7");
140         selectOptionByName("newCollectionLines['document.dailyExpenseEstimates'].mileageRateId", "10000"); // DO
141         waitAndTypeByName("newCollectionLines['document.dailyExpenseEstimates'].estimatedMileage","13");
142         jGrowl("Click Daily Expense Estimates Add Button");
143         waitAndClickByXpath("//button[contains(@data-submit_data, 'document.dailyExpenseEstimates')]");
144     }
145     
146     protected void waitAndGetReturnValue() throws Exception {
147     	gotoLightBox();
148     	waitAndClickButtonByText(SEARCH);
149     	waitAndClickByLinkText(RETURN_VALUE);
150     }
151     
152     @Test
153     public void testTravelAccountAuthorizationSubmitNav() throws Exception {
154         testTravelAccountAuthorizationSubmit();
155         passed();
156     }
157     
158     @Test
159     public void testTravelAccountAuthorizationBlanketApproveNav() throws Exception {
160         testTravelAccountAuthorizationBlanketApprove();
161         passed();
162     }
163 
164     @Test
165     public void testTravelAccountAuthorizationSubmitBookmark() throws Exception {
166     	testTravelAccountAuthorizationSubmit();
167         passed();
168     }
169     
170     @Test
171     public void testTravelAccountAuthorizationBlanketApproveBookmark() throws Exception {
172         testTravelAccountAuthorizationBlanketApprove();
173         passed();
174     }
175 }