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.lookup.conditionalcriteria;
17  
18  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
19  import org.junit.Test;
20  import org.openqa.selenium.By;
21  import org.openqa.selenium.WebElement;
22  
23  /**
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class DemoLookUpConditionalCriteriaAft extends WebDriverLegacyITBase {
27  
28      /**
29       * /kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalCriteria&hideReturnLink=true
30       */
31      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalCriteria&hideReturnLink=true";
32      
33      /**
34       *  lookupCriteria[number]
35       */
36      private static final String LOOKUP_CRITERIA_NUMBER_NAME="lookupCriteria[number]";
37      
38      /**
39       *  lookupCriteria[rangeLowerBoundKeyPrefix_createDate]
40       */
41      private static final String LOOKUP_CRITERIA_DATE_LOWER_BOUND_NAME="lookupCriteria[rangeLowerBoundKeyPrefix_createDate]";
42  
43      /**
44       *  lookupCriteria[createDate]
45       */
46      private static final String LOOKUP_CRITERIA_DATE_UPPER_BOUND_NAME="lookupCriteria[createDate]";
47      
48      @Override
49      public String getBookmarkUrl() {
50          return BOOKMARK_URL;
51      }
52  
53      @Override
54      protected void navigate() throws Exception {
55          waitAndClickById("Demo-DemoLink", "");
56          waitAndClickByLinkText("Lookup Conditional Criteria");
57      }
58  
59      protected void testLookUpConditionalCriteria() throws InterruptedException {
60          //Case 1 - Date field required by number a1
61          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME, "a1");
62          fireEvent(LOOKUP_CRITERIA_NUMBER_NAME, "focus");
63          fireEvent(LOOKUP_CRITERIA_NUMBER_NAME, "blur");
64          waitAndClickSearch3();
65          assertTrue(isElementPresent(By.className("uif-requiredMessage")));
66          assertTrue(isElementPresentByName(LOOKUP_CRITERIA_DATE_LOWER_BOUND_NAME));
67          assertTrue(isElementPresentByName(LOOKUP_CRITERIA_DATE_UPPER_BOUND_NAME));
68  
69          clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
70  
71          //Case 2 - Date field read only by number a2
72          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME, "a2");
73          fireEvent(LOOKUP_CRITERIA_NUMBER_NAME, "focus");
74          fireEvent(LOOKUP_CRITERIA_NUMBER_NAME, "blur");
75          waitAndClickSearch3();
76          assertFalse(isElementPresentByName(LOOKUP_CRITERIA_DATE_LOWER_BOUND_NAME));
77          assertFalse(isElementPresentByName(LOOKUP_CRITERIA_DATE_UPPER_BOUND_NAME));
78  
79          clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
80          
81          //Case 3 - Date field hide by number a3
82          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME, "a3");
83          fireEvent(LOOKUP_CRITERIA_NUMBER_NAME, "focus");
84          fireEvent(LOOKUP_CRITERIA_NUMBER_NAME, "blur");
85          waitAndClickSearch3();
86          waitForElementPresentByName(LOOKUP_CRITERIA_DATE_LOWER_BOUND_NAME);
87          assertTrue(isNotVisible(By.name(LOOKUP_CRITERIA_DATE_LOWER_BOUND_NAME)));
88          waitForElementPresentByName(LOOKUP_CRITERIA_DATE_UPPER_BOUND_NAME);
89          assertTrue(isNotVisible(By.name(LOOKUP_CRITERIA_DATE_UPPER_BOUND_NAME)));
90      }
91  
92      @Test
93      public void testLookUpConditionalCriteriaBookmark() throws Exception {
94          testLookUpConditionalCriteria();
95          passed();
96      }
97  
98      @Test
99      public void testLookUpConditionalCriteriaNav() throws Exception {
100         testLookUpConditionalCriteria();
101         passed();
102     }
103 }