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.labs.lookups;
17  
18  import org.junit.Test;
19  import org.openqa.selenium.By;
20  
21  /**
22   * @author Kuali Rice Team (rice.collab@kuali.org)
23   */
24  public class LabsLookUpConditionalCriteriaAft extends LabsLookupBase {
25  
26      /**
27       * /kr-krad/lookup?methodToCall=start&viewId=LabsLookup-ConditionalCriteriaView&hideReturnLink=true
28       */
29      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LabsLookup-ConditionalCriteriaView&hideReturnLink=true";
30  
31      /**
32       *  lookupCriteria[number]
33       */
34      private static final String LOOKUP_CRITERIA_NUMBER_NAME="lookupCriteria[number]";
35      
36      /**
37       *  Search
38       */
39      private static final String SEARCH="Search";
40      
41      /**
42       *  lookupCriteria[rangeLowerBoundKeyPrefix_createDate]
43       */
44      private static final String LOOKUP_CRITERIA_DATE_NAME="lookupCriteria[rangeLowerBoundKeyPrefix_createDate]";
45      
46      /**
47       *  Not read only. Date input field present.
48       */
49      private static final String FAILURE_MESSAGE="Not read only. Date input field present.";
50      
51      /**
52       *  Date Created:
53       */
54      private static final String DATE_CREATED_LABEL="Date Created:";
55      
56      /**
57       *  Date Created is a required field.
58       */
59      private static final String DATE_REQUIRED_MESSAGE="Date Created is a required field.";
60      
61      /**
62       *  LookUp Criteria Name 
63       */
64      private static final String LOOKUP_CRITERIA_NAME_NAME="lookupCriteria[name]";
65      
66      @Override
67      protected String getBookmarkUrl() {
68          return BOOKMARK_URL;
69      }
70  
71      @Override
72      protected void navigate() throws Exception {
73          navigateToLookup("Lookup Conditional Criteria");
74      }
75  
76      // copied from DemoLookUpConditionalCriteriaAft
77      protected void testLookUpConditionalCriteria() throws InterruptedException {
78          //Case 1 - Date field required by number a1
79          //It requires "Search" to be clicked twice, for the date required message to show.
80          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME, "a1");
81          waitAndClickByName("lookupCriteria[name]");
82          waitForElementPresent(By.className("uif-requiredMessage"));
83          checkForIncidentReport();
84  
85          //Case 2 - Date field read only by number a2
86          clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
87          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME, "a2");
88          waitAndClickByName("lookupCriteria[name]");
89          Thread.sleep(3000);
90          checkForIncidentReport();
91          if(isElementPresentByName(LOOKUP_CRITERIA_DATE_NAME)) {
92              fail(FAILURE_MESSAGE);
93          }
94  
95          //Case 3 - Date field hide by number a3
96          clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
97          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME, "a3");
98          waitAndClickByName("lookupCriteria[name]");
99          Thread.sleep(3000);
100         checkForIncidentReport();
101         assertTrue(isNotVisible(By.name(LOOKUP_CRITERIA_DATE_NAME)));
102         assertTrue(isNotVisible(By.name("lookupCriteria[createDate]")));
103     }
104 
105 
106     @Test
107     public void testLookUpConditionalCriteriaBookmark() throws Exception {
108         testLookUpConditionalCriteria();
109         passed();
110     }
111 
112     @Test
113     public void testLookUpConditionalCriteriaNav() throws Exception {
114         testLookUpConditionalCriteria();
115         passed();
116     }
117 }