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.lookup.conditionalcriteria;
17  
18  import org.kuali.rice.krad.demo.ViewDemoAftBase;
19  import org.junit.Test;
20  import org.openqa.selenium.By;
21  import org.openqa.selenium.Dimension;
22  
23  /**
24   * @author Kuali Rice Team (rice.collab@kuali.org)
25   */
26  public class DemoLookUpConditionalCriteriaAft extends ViewDemoAftBase {
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          waitAndClickDemoLink();
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, "blur");
63          waitAndClickSearch3();
64          waitForElementPresentByClassName("uif-requiredMessage");
65          assertTrue(isElementPresentByName(LOOKUP_CRITERIA_DATE_LOWER_BOUND_NAME));
66          assertTrue(isElementPresentByName(LOOKUP_CRITERIA_DATE_UPPER_BOUND_NAME));
67  
68          clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
69  
70          //Case 2 - Date field read only by number a2
71          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME, "a2");
72          fireEvent(LOOKUP_CRITERIA_NUMBER_NAME, "focus");
73          fireEvent(LOOKUP_CRITERIA_NUMBER_NAME, "blur");
74          waitAndClickSearch3();
75          waitForElementNotPresent(By.name(LOOKUP_CRITERIA_DATE_LOWER_BOUND_NAME));
76          assertFalse(isElementPresentByName(LOOKUP_CRITERIA_DATE_UPPER_BOUND_NAME));
77  
78          clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
79  
80          //Case 3 - Date field hide by number a3
81          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME, "a3");
82          fireEvent(LOOKUP_CRITERIA_NUMBER_NAME, "focus");
83          fireEvent(LOOKUP_CRITERIA_NUMBER_NAME, "blur");
84          waitAndClickSearch3();
85          waitForElementPresentByName(LOOKUP_CRITERIA_DATE_LOWER_BOUND_NAME);
86          assertTrue(isNotVisible(By.name(LOOKUP_CRITERIA_DATE_LOWER_BOUND_NAME)));
87          waitForElementPresentByName(LOOKUP_CRITERIA_DATE_UPPER_BOUND_NAME);
88          assertTrue(isNotVisible(By.name(LOOKUP_CRITERIA_DATE_UPPER_BOUND_NAME)));
89      }
90  
91      protected void testAutoTruncateColumns() throws InterruptedException {
92          waitForElementPresentByName(LOOKUP_CRITERIA_NUMBER_NAME);
93          jiraAwareClearAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME, "a3");
94          fireEvent(LOOKUP_CRITERIA_NUMBER_NAME, "blur");
95          waitAndClickSearch3();
96  
97          // verify auto truncate is enabled
98          jGrowl("Verifying auto truncate is enabled");
99          waitForElementPresent("#resultsName_line0.uif-truncate");
100 
101         // verify text not truncated
102         jGrowl("Verifying text is not truncated");
103         assertEquals("Travel Account 3", getText(By.cssSelector("#resultsName_line0_control")));
104 
105         // verify tooltip not present
106         jGrowl("Fire MouseOver event to show tooltip, and validate tooltip is not present");
107         fireMouseOverEventById("resultsName_line0_control");
108         waitForElementNotPresent(By.cssSelector(".popover.top.in"));
109 
110         jGrowl("Resizing the window width");
111         int width = 560;
112         int height = driver.manage().window().getSize().getHeight();
113         driver.manage().window().setSize(new Dimension(width, height));
114 
115         // cannot verify that the text is truncated since DOM always returns the original
116         // text and not what's displayed :{
117         jGrowl("Verifying text is still displayed");
118         assertEquals("Travel Account 3", getText(By.cssSelector("#resultsName_line0_control")));
119 
120         // verify tooltip present
121         jGrowl("Fire MouseOver event to show tooltip, and validate tooltip is present");
122         fireMouseOverEventById("resultsName_line0_control");
123         waitForToolTipTextPresent("Travel Account 3");
124     }
125 
126     @Test
127     public void testAutoTruncateColumnsBookmark() throws Exception {
128         testAutoTruncateColumns();
129         passed();
130     }
131 
132     @Test
133     public void testAutoTruncateColumnsNav() throws Exception {
134         testAutoTruncateColumns();
135         passed();
136     }
137 
138     @Test
139     public void testLookUpConditionalCriteriaBookmark() throws Exception {
140         testLookUpConditionalCriteria();
141         passed();
142     }
143 
144     @Test
145     public void testLookUpConditionalCriteriaNav() throws Exception {
146         testLookUpConditionalCriteria();
147         passed();
148     }
149 
150 }