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.kuali.rice.krad.demo.ViewDemoAftBase;
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 DemoTravelPerDiemLookUpAft extends ViewDemoAftBase {
26  
27      /**
28       * /kr-krad/lookup?methodToCall=start&dataObjectClassName=edu.sampleu.travel.dataobject.TravelPerDiemExpense
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&dataObjectClassName=edu.sampleu.travel.dataobject.TravelPerDiemExpense";
31  
32      /**
33       * Search
34       */
35      public static final String SEARCH = "Search";
36      
37      /**
38       * Clear Values
39       */
40      public static final String CLEAR_VALUES = "Clear Values";
41      
42      @Override
43      public String getBookmarkUrl() {
44          return BOOKMARK_URL;
45      }
46  
47      @Override
48      protected void navigate() throws Exception {
49          waitAndClickDemoLink();
50          waitAndClickByLinkText("Travel Per Diem Lookup");
51      }
52  
53      protected void testTravelPerDiemLookUp() throws Exception {
54      	waitAndTypeByName("lookupCriteria[travelPerDiemExpenseId]","1");
55      	waitAndTypeByName("lookupCriteria[travelAuthorizationDocumentId]","1");
56      	selectByName("lookupCriteria[travelDestinationId]","Colorado");
57      	waitAndClickByXpath("//div[@data-label='Primary Destination']/div/div/button[@class='btn btn-default uif-action icon-search']");
58      	waitSearchAndReturnFromLightbox();
59          assertEquals("lookupCriteria[travelAuthorizationDocumentId] value not 1 as set before Lightbox search", "1", waitAndGetAttributeByName("lookupCriteria[travelAuthorizationDocumentId]", "value"));
60      	waitAndClickByXpath("//div[@data-label='Mileage Rate']/div/div/button[@class='btn btn-default uif-action icon-search']");
61      	waitSearchAndReturnFromLightbox();
62      	waitAndClickButtonByText(SEARCH);
63      	waitForTextPresent("No values match this search.");
64      	waitForTextPresent("You have entered the primary key for this table (Id) in the search criteria. Since these fields can be used to uniquely identify a row in this table, the other search criteria entered will be ignored.");
65      	waitAndClickButtonByText(CLEAR_VALUES);
66      	waitAndTypeByName("lookupCriteria[travelPerDiemExpenseId]","10000");
67      	waitAndClickButtonByText(SEARCH);
68          // Last data first so data is fully loaded
69      	String activeResults [] ={"30","10000","10000","10000","10","10","15","20","DO"};
70      	assertTextPresent(activeResults);
71      }
72  
73      @Test
74      public void testTravelPerDiemLookUpBookmark() throws Exception {
75          testTravelPerDiemLookUp();
76          passed();
77      }
78  
79      @Test
80      public void testTravelPerDiemLookUpNav() throws Exception {
81          testTravelPerDiemLookUp();
82          passed();
83      }
84      
85      private void waitSearchAndReturnFromLightbox() throws Exception {
86      	gotoLightBox();
87      	waitAndClickButtonByText("Search");
88      	waitAndClickByLinkText("return value");
89      }
90  }