001 /**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package edu.samplu.krad.labs.lookups;
017
018 import org.junit.Test;
019
020 /**
021 * @author Kuali Rice Team (rice.collab@kuali.org)
022 */
023 public class DemoLabsLookUpConditionalCriteriaSmokeTest extends DemoLabsLookupBase {
024
025 /**
026 * /kr-krad/lookup?methodToCall=start&viewId=LabsLookup-ConditionalCriteriaView&hideReturnLink=true
027 */
028 public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LabsLookup-ConditionalCriteriaView&hideReturnLink=true";
029
030 /**
031 * lookupCriteria[number]
032 */
033 private static final String LOOKUP_CRITERIA_NUMBER_NAME="lookupCriteria[number]";
034
035 /**
036 * Search
037 */
038 private static final String SEARCH="Search";
039
040 /**
041 * lookupCriteria[rangeLowerBoundKeyPrefix_createDate]
042 */
043 private static final String LOOKUP_CRITERIA_DATE_NAME="lookupCriteria[rangeLowerBoundKeyPrefix_createDate]";
044
045 /**
046 * Not read only. Date input field present.
047 */
048 private static final String FAILURE_MESSAGE="Not read only. Date input field present.";
049
050 /**
051 * Date Created:
052 */
053 private static final String DATE_CREATED_LABEL="Date Created:";
054
055 /**
056 * Date Created is a required field.
057 */
058 private static final String DATE_REQUIRED_MESSAGE="Date Created is a required field.";
059
060 /**
061 * LookUp Criteria Name
062 */
063 private static final String LOOKUP_CRITERIA_NAME_NAME="lookupCriteria[name]";
064
065 @Override
066 protected String getBookmarkUrl() {
067 return BOOKMARK_URL;
068 }
069
070 @Override
071 protected void navigate() throws Exception {
072 navigateToLookup("Lookup Conditional Criteria");
073 }
074
075 protected void testLookUpConditionalCriteria() throws InterruptedException {
076 //Case 1 - Date field required by number a1
077 //It requires "Search" to be clicked twice, for the date required message to show.
078 waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a1");
079 waitAndClickButtonByText(SEARCH);
080 Thread.sleep(10000); // If we don't wait long enough we'll get concurrency issues.
081 checkForIncidentReport(SEARCH, "DemoLookUpConditionalCriteriaSmokeTest testLookUpConditionalCriteria");
082 waitAndClickButtonByText(SEARCH);
083 Thread.sleep(3000);
084 checkForIncidentReport();
085 assertTextPresent(DATE_REQUIRED_MESSAGE);
086
087 //Case 2 - Date field read only by number a2
088 clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
089 waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a2");
090 waitAndTypeByName(LOOKUP_CRITERIA_NAME_NAME,"");
091 Thread.sleep(2000);
092 if(isElementPresentByName(LOOKUP_CRITERIA_DATE_NAME)) {
093 fail(FAILURE_MESSAGE);
094 }
095
096 //Case 3 - Date field hide by number a3
097 clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
098 waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a3");
099 waitAndClickButtonByText(SEARCH);
100 Thread.sleep(3000);
101 assertTextNotPresent(DATE_CREATED_LABEL);
102 }
103
104 @Test
105 public void testLookUpConditionalCriteriaBookmark() throws Exception {
106 testLookUpConditionalCriteria();
107 passed();
108 }
109
110 @Test
111 public void testLookUpConditionalCriteriaNav() throws Exception {
112 testLookUpConditionalCriteria();
113 passed();
114 }
115 }