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.demo.lookupviews.lookup.conditionalcriteria;
017
018 import org.kuali.rice.testtools.selenium.SmokeTestBase;
019 import org.junit.Test;
020
021 /**
022 * @author Kuali Rice Team (rice.collab@kuali.org)
023 */
024 public class DemoLookUpConditionalCriteriaSmokeTest extends SmokeTestBase {
025
026 /**
027 * /kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalCriteria&hideReturnLink=true
028 */
029 public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalCriteria&hideReturnLink=true";
030
031 /**
032 * lookupCriteria[number]
033 */
034 private static final String LOOKUP_CRITERIA_NUMBER_NAME="lookupCriteria[number]";
035
036 /**
037 * Search
038 */
039 private static final String SEARCH="Search";
040
041 /**
042 * lookupCriteria[rangeLowerBoundKeyPrefix_createDate]
043 */
044 private static final String LOOKUP_CRITERIA_DATE_NAME="lookupCriteria[rangeLowerBoundKeyPrefix_createDate]";
045
046 /**
047 * Not read only. Date input field present.
048 */
049 private static final String FAILURE_MESSAGE="Not read only. Date input field present.";
050
051 /**
052 * Date Created:
053 */
054 private static final String DATE_CREATED_MESSAGE="Date Created:";
055
056 /**
057 * Date Created is a required field.
058 */
059 private static final String DATE_REQUIRED_MESSAGE="Date Created is a required field.";
060
061 @Override
062 public String getBookmarkUrl() {
063 return BOOKMARK_URL;
064 }
065
066 @Override
067 protected void navigate() throws Exception {
068 waitAndClickById("Demo-DemoLink", "");
069 waitAndClickByLinkText("Lookup Conditional Criteria");
070 }
071
072 protected void testLookUpConditionalCriteria() throws InterruptedException {
073 //Case 1 - Date field required by number a1
074 //It requires "Search" to be clicked twice, for the date required message to show.
075 waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a1");
076 waitAndClickButtonByText(SEARCH);
077 Thread.sleep(10000); // If we don't wait long enough we'll get concurrency issues.
078 checkForIncidentReport(SEARCH, "DemoLookUpConditionalCriteriaSmokeTest testLookUpConditionalCriteria");
079 waitAndClickButtonByText(SEARCH);
080 Thread.sleep(3000);
081 checkForIncidentReport();
082 assertTextPresent(DATE_REQUIRED_MESSAGE);
083
084 //Case 2 - Date field read only by number a2
085 clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
086 waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a2");
087 waitAndClickButtonByText(SEARCH);
088 Thread.sleep(3000);
089 if(isElementPresentByName(LOOKUP_CRITERIA_DATE_NAME)) {
090 fail(FAILURE_MESSAGE);
091 }
092
093 //Case 3 - Date field hide by number a3
094 clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
095 waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME,"a3");
096 waitAndClickButtonByText(SEARCH);
097 Thread.sleep(3000);
098 assertTextNotPresent(DATE_CREATED_MESSAGE);
099 }
100
101 @Test
102 public void testLookUpConditionalCriteriaBookmark() throws Exception {
103 testLookUpConditionalCriteria();
104 passed();
105 }
106
107 @Test
108 public void testLookUpConditionalCriteriaNav() throws Exception {
109 testLookUpConditionalCriteria();
110 passed();
111 }
112 }