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.account;
17  
18  import org.junit.Test;
19  import org.kuali.rice.krad.demo.ViewDemoAftBase;
20  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
21  import org.openqa.selenium.By;
22  
23  /**
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class DemoTravelAccountMultivalueLookUpAft extends ViewDemoAftBase {
27  
28      /**
29       * /kr-krad/lookup?methodToCall=start&dataObjectClassName=org.kuali.rice.krad.demo.travel.dataobject.TravelAccount&hideReturnLink=true&multipleValuesSelect=true&lookupCollectionName=travelAccounts&suppressActions=true&conversionFields=number:foo,name:foo
30       */
31      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&dataObjectClassName=org.kuali.rice.krad.demo.travel.dataobject.TravelAccount&hideReturnLink=true&multipleValuesSelect=true&lookupCollectionName=travelAccounts&suppressActions=true&conversionFields=number:foo,name:foo";
32     
33      /**
34       * selectedCollectionLines['lookupResults']
35       */
36      public static final String LOOKUP_RESULTS = "selectedCollectionLines['lookupResults']";
37  
38      @Override
39      public String getBookmarkUrl() {
40          return BOOKMARK_URL;
41      }
42  
43      @Override
44      protected void navigate() throws Exception {
45          waitAndClickDemoLink();
46          waitAndClickByLinkText("Account Multi-Value Lookup");
47      }
48  
49      private void testSearchSelect() throws Exception {
50          waitAndClickByValue("CAT");
51          waitAndClickByXpath("//div[@data-label='Travel Account Type Code']/div/div/button[@class='btn btn-default uif-action icon-search']");
52      	waitSearchAndReturnFromLightbox();
53          waitAndClickButtonByText(WebDriverLegacyITBase.SEARCH);
54  
55          By[] bysPresent = new By[] {By.xpath("//a[contains(text(), 'a6')]"), By.xpath("//a[contains(text(), 'a9')]"), By.xpath("//a[contains(text(), 'a14')]")};
56          assertElementsPresentInResultPages(bysPresent);
57  
58          waitAndClickByName(LOOKUP_RESULTS);
59          assertButtonEnabledByText(WebDriverLegacyITBase.RETURN_SELECTED_BUTTON_TEXT);
60          waitAndClickByName(LOOKUP_RESULTS);
61          assertButtonDisabledByText(WebDriverLegacyITBase.RETURN_SELECTED_BUTTON_TEXT);
62  
63          assertMultiValueSelectAllThisPage();
64          assertMultiValueDeselectAllThisPage();
65  
66          waitAndClickByName(LOOKUP_RESULTS);
67          waitAndClickButtonByText(WebDriverLegacyITBase.SEARCH);
68          checkForIncidentReport();
69      }
70  
71      @Test
72      public void testTravelAccountMultivalueLookUpSearchSelectBookmark() throws Exception {
73          testSearchSelect();
74          passed();
75      }
76  
77      @Test
78      public void testTravelAccountMultivalueLookUpSearchSelectNav() throws Exception {
79          testSearchSelect();
80          passed();
81      }
82  
83      @Test
84      public void testTravelAccountMultivalueLookUpSelectThisPageBookmark() throws Exception {
85          testMultiValueSelectAllThisPage();
86          passed();
87      }
88  
89      @Test
90      public void testTravelAccountMultivalueLookUpSelectThisPageNav() throws Exception {
91          testMultiValueSelectAllThisPage();
92          passed();
93      }
94  
95      @Test
96      public void testTravelAccountMultivalueLookUpSelectAllPagesBookmark() throws Exception {
97          testMultiValueSelectAllPages();
98          passed();
99      }
100 
101     @Test
102     public void testTravelAccountMultivalueLookUpSelectAllPagesNav() throws Exception {
103         testMultiValueSelectAllPages();
104         passed();
105     }
106     
107     private void waitSearchAndReturnFromLightbox() throws Exception {
108     	gotoLightBox();
109     	waitAndClickButtonByText("Search");
110     	waitAndClickByLinkText("return value");
111     }
112 }