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.account;
17  
18  import org.kuali.rice.krad.demo.ViewDemoAftBase;
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 DemoTravelAccountLookUpAutoSearchAft extends ViewDemoAftBase {
26  
27      /**
28       * /kr-krad/lookup?methodToCall=search&dataObjectClassName=org.kuali.rice.krad.demo.travel.dataobject.TravelAccount&lookupCriteria['number']=a*&readOnlyFields=number&hideReturnLink=true&showMaintenanceLinks=true
29       */
30      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=search&dataObjectClassName=org.kuali.rice.krad.demo.travel.dataobject.TravelAccount&lookupCriteria['number']=a*&readOnlyFields=number&hideReturnLink=true&showMaintenanceLinks=true";
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      public void navigate() throws Exception {
48          waitAndClickDemoLink();
49          waitAndClickByLinkText("Account Lookup Auto Search Pre-Filtered");
50      }
51  
52      protected void testDemoTravelAccountLookUpAutoSearch() throws Exception {
53          waitForTextPresent("Showing 1 to 10");
54  
55          By[] results = {By.linkText("a1"), By.linkText("a2"), By.linkText("a3"), By.linkText("a4"), By.linkText("a5"),
56                  By.linkText("a6"), By.linkText("a7"), By.linkText("a8"), By.linkText("a9"), By.linkText("a10"),
57                  By.linkText("a11"), By.linkText("a12"), By.linkText("a13"), By.linkText("a14")};
58  
59          assertElementsPresentInResultPages(results);
60          waitAndClickByXpath("//div[@data-label='Travel Account Type Code']/div/div/button[@class='btn btn-default uif-action icon-search']");
61      	waitSearchAndReturnFromLightbox();
62  
63  // TODO should the foid work?
64  //        waitAndTypeByName("lookupCriteria[foId]","1");
65  //        waitAndClickButtonByText(SEARCH);
66  //        Thread.sleep(3000);
67  //        assertElementPresentByXpath("//a[contains(text(), 'a1')]");
68  //        if(isElementPresentByLinkText("a2") || isElementPresentByLinkText("a3")) {
69  //            fail("Search Functionality not working properly.");
70  //        }
71      }
72  
73      protected void testDemoTravelAccountLookUpAdditionalSearch() throws Exception {
74          waitForTextPresent("Showing 1 to 10");
75  
76          By[] results = {By.linkText("a1"), By.linkText("a2"), By.linkText("a3"), By.linkText("a4"), By.linkText("a5"),
77                  By.linkText("a6"), By.linkText("a7"), By.linkText("a8"), By.linkText("a9"), By.linkText("a10"),
78                  By.linkText("a11"), By.linkText("a12"), By.linkText("a13"), By.linkText("a14")};
79  
80          assertElementsPresentInResultPages(results);
81          waitAndClickButtonByText(SEARCH);
82          checkForIncidentReport();
83       }
84  
85      @Test
86      public void testDemoTravelAccountLookUpAutoSearchNav() throws Exception {
87          testDemoTravelAccountLookUpAutoSearch();
88          passed();
89      }
90  
91      @Test
92      public void testDemoTravelAccountLookUpAutoSearchBookmark() throws Exception {
93          testDemoTravelAccountLookUpAutoSearch();
94          passed();
95      }
96  
97      @Test
98      public void testDemoTravelAccountLookUpAdditionalBookmark() throws Exception {
99          testDemoTravelAccountLookUpAdditionalSearch();
100         passed();
101     }
102 
103 
104     private void waitSearchAndReturnFromLightbox() throws Exception {
105     	gotoLightBox();
106     	waitAndClickButtonByText("Search");
107     	waitAndClickByLinkText("return value");
108     }
109 }