View Javadoc
1   /**
2    * Copyright 2005-2016 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.junit.Ignore;
19  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
20  import org.junit.Test;
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          waitAndClickDemoLink();
80          waitAndClickByLinkText("Travel Authorization Document");
81      }
82  
83      protected void testTravelAccountAuthorizationSubmit() throws Exception {
84      	testTravelAccountAuthorization();
85          waitAndClickSubmitByText();
86          waitAndClickConfirmSubmitOk();
87  // No isn't visible but Yes is?!
88  //        waitForElementVisibleBy(By.xpath("//label[contains(text(), 'No')]"), "").click();
89  //        waitAndClick(By.xpath("//label[contains(text(), 'No')]"));
90  //        waitAndClickButtonByText("submit");
91  //        waitAndClick(By.xpath("//button[contains(text(), 'Yes')]"));
92      	waitForTextPresent("Document was successfully");
93      }
94  
95      protected void testTravelAccountAuthorizationBlanketApprove() throws Exception {
96      	testTravelAccountAuthorization();
97          waitAndClickBlanketApprove();
98          checkForIncidentReport();
99  // blanket approve redirects to hub so can no longer test for message
100 //    	waitForTextPresent("Document was successfully approved.");
101     }
102 
103     protected void testTravelAccountAuthorization() throws Exception {
104     	waitAndTypeByName(DESCRIPTION_NAME,"Travel Authorization Description");
105     	waitAndTypeByName("document.documentHeader.organizationDocumentNumber","1");
106     	waitAndTypeByName("document.documentHeader.explanation","This is an explanation for Travel Authorization !'");
107     	waitAndClickById("travelerQuickfinder_quickfinder_act");
108     	waitAndGetReturnValue();
109     	waitAndTypeByName(CONTACT_NUMBER_NAME,"918000884215");
110         jGrowl("Click Primary Destination Id Quick Finder");
111     	waitAndClickByXpath("//div[@data-label='Primary Destination Id']/div/div/button");
112     	waitAndGetReturnValue();
113     	selectByName("document.travelTypeCode","In State");
114     	waitAndTypeByName("document.tripBegin","02/01/2014");
115     	waitAndTypeByName("document.tripEnd","02/04/2014");
116         jGrowl("Traveler Lookup Quickfinder");
117         waitAndClickById("travelerQuickfinder_quickfinder_act");
118     	waitAndGetReturnValue();
119 
120         // KNS/KRAD Equiv M38
121         jGrowl("Click Primary Destination Id Quickfinder");
122         waitAndClickByXpath("//div[@data-label='Primary Destination Id']/div/div/button");
123     	waitAndGetReturnValue();
124         String primaryDestinationId = waitAndGetAttributeByName("document.tripDestinationId", "value");
125     	waitAndTypeByName("document.expenseLimit","1000");
126 
127     	//Actual Expense
128         waitAndTypeByName("newCollectionLines['document.actualExpenseItems'].travelCompanyName", "Kuali");
129         selectOptionByName("newCollectionLines['document.actualExpenseItems'].travelExpenseTypeCd", "A"); // Airfare
130         waitAndTypeByName("newCollectionLines['document.actualExpenseItems'].expenseDesc", "Expense Description");
131         waitAndTypeByName("newCollectionLines['document.actualExpenseItems'].expenseAmount", "123.12");
132         jGrowl("Click Actual Expense Items Add Button");
133     	waitAndClickByXpath("//button[contains(@data-submit_data, 'document.actualExpenseItems')]");
134     	
135     	//Daily Cost Estimate
136     	waitAndTypeByName("newCollectionLines['document.dailyExpenseEstimates'].perDiemDate","12/12/13");
137         selectOptionByName("newCollectionLines['document.dailyExpenseEstimates'].travelDestinationId", primaryDestinationId);
138         waitAndTypeByName("newCollectionLines['document.dailyExpenseEstimates'].breakfastValue","16");
139         waitAndTypeByName("newCollectionLines['document.dailyExpenseEstimates'].lunchValue","18");
140         waitAndTypeByName("newCollectionLines['document.dailyExpenseEstimates'].dinnerValue","20");
141         waitAndTypeByName("newCollectionLines['document.dailyExpenseEstimates'].incidentalsValue","7");
142         selectOptionByName("newCollectionLines['document.dailyExpenseEstimates'].mileageRateId", "10000"); // DO
143         waitAndTypeByName("newCollectionLines['document.dailyExpenseEstimates'].estimatedMileage","13");
144         jGrowl("Click Daily Expense Estimates Add Button");
145         waitAndClickByXpath("//button[contains(@data-submit_data, 'document.dailyExpenseEstimates')]");
146     }
147     
148     protected void waitAndGetReturnValue() throws Exception {
149     	gotoLightBox();
150     	waitAndClickButtonByText(SEARCH);
151     	waitAndClickByLinkText(RETURN_VALUE);
152     }
153     
154     @Ignore("https://jira.kuali.org/browse/KULRICE-13357 AFT Failures Dialogs on CI")
155     @Test
156     public void testTravelAccountAuthorizationSubmitNav() throws Exception {
157         testTravelAccountAuthorizationSubmit();
158         passed();
159     }
160     
161     @Test
162     public void testTravelAccountAuthorizationBlanketApproveNav() throws Exception {
163         testTravelAccountAuthorizationBlanketApprove();
164         passed();
165     }
166 
167     @Ignore("https://jira.kuali.org/browse/KULRICE-13357 AFT Failures Dialogs on CI")
168     @Test
169     public void testTravelAccountAuthorizationSubmitBookmark() throws Exception {
170     	testTravelAccountAuthorizationSubmit();
171         passed();
172     }
173     
174     @Test
175     public void testTravelAccountAuthorizationBlanketApproveBookmark() throws Exception {
176         testTravelAccountAuthorizationBlanketApprove();
177         passed();
178     }
179 }