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[rangeLowerBoundKeyPrefix_createDate]
33       */
34      private static final String LOOKUP_CRITERIA_DATE_NAME="lookupCriteria[rangeLowerBoundKeyPrefix_createDate]";
35      
36      /**
37       *  Not read only. Date input field present.
38       */
39      private static final String FAILURE_MESSAGE="Not read only. Date input field present.";
40      
41      @Override
42      protected String getBookmarkUrl() {
43          return BOOKMARK_URL;
44      }
45  
46      @Override
47      protected void navigate() throws Exception {
48          navigateToLookup("Lookup Conditional Criteria");
49      }
50  
51      // copied from DemoLookUpConditionalCriteriaAft
52      protected void testLookUpConditionalCriteria() throws InterruptedException {
53          //Case 1 - Date field required by number a1
54          //It requires "Search" to be clicked twice, for the date required message to show.
55          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME, "a1");
56          waitAndClickByName("lookupCriteria[name]");
57          waitForElementPresent(By.className("uif-requiredMessage"));
58          checkForIncidentReport();
59  
60          //Case 2 - Date field read only by number a2
61          clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
62          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME, "a2");
63          waitAndClickByName("lookupCriteria[name]");
64          Thread.sleep(3000);
65          checkForIncidentReport();
66          if(isElementPresentByName(LOOKUP_CRITERIA_DATE_NAME)) {
67              fail(FAILURE_MESSAGE);
68          }
69  
70          //Case 3 - Date field hide by number a3
71          clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
72          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME, "a3");
73          waitAndClickByName("lookupCriteria[name]");
74          Thread.sleep(3000);
75          checkForIncidentReport();
76          assertTrue(isNotVisible(By.name(LOOKUP_CRITERIA_DATE_NAME)));
77          assertTrue(isNotVisible(By.name("lookupCriteria[createDate]")));
78      }
79  
80  
81      @Test
82      public void testLookUpConditionalCriteriaBookmark() throws Exception {
83          testLookUpConditionalCriteria();
84          passed();
85      }
86  
87      @Test
88      public void testLookUpConditionalCriteriaNav() throws Exception {
89          testLookUpConditionalCriteria();
90          passed();
91      }
92  }