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.conditionalresults;
017
018 import org.junit.Assert;
019 import org.kuali.rice.testtools.selenium.SmokeTestBase;
020 import org.junit.Test;
021
022 import static org.junit.Assert.assertEquals;
023
024 /**
025 * @author Kuali Rice Team (rice.collab@kuali.org)
026 */
027 public class DemoLookUpConditionalResultsBasedOnCriteriaSmokeTest extends SmokeTestBase {
028
029 /**
030 * /kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalResultsBasedOnCriteria
031 */
032 public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalResultsBasedOnCriteria";
033
034 /**
035 * lookupCriteria[number]
036 */
037 private static final String LOOKUP_CRITERIA_TYPE_CODE="lookupCriteria[typeCode]";
038
039 /**
040 * Search
041 */
042 private static final String SEARCH="Search";
043
044 /**
045 * Principal Name column
046 */
047 private static final String PRINCIPAL_NAME_COLUMN_NAME = "Principal Name";
048
049 /**
050 * Group Name column
051 */
052 private static final String GROUP_NAME_COLUMN_NAME = "Group Name";
053
054 /**
055 * Role Name column
056 */
057 private static final String ROLE_NAME_COLUMN_NAME = "Role Name";
058
059 /**
060 * Description column
061 */
062 private static final String DESCRIPTION_COLUMN_NAME = "Description";
063
064 @Override
065 public String getBookmarkUrl() {
066 return BOOKMARK_URL;
067 }
068
069 @Override
070 protected void navigate() throws Exception {
071 waitAndClickById("Demo-DemoLink", "");
072 waitAndClickByLinkText("Lookup Conditional Results Based On Criteria");
073 }
074
075 protected void testLookUpConditionalResultsBasedOnCriteria() throws InterruptedException {
076 // Case 1 - Search by Principal
077 waitAndTypeByName(LOOKUP_CRITERIA_TYPE_CODE,"P");
078 waitAndClickButtonByText(SEARCH);
079 Thread.sleep(3000);
080 Assert.assertEquals(1, getCssCount("div#uLookupResults thead th"));
081 assertElementPresent("div#uLookupResults thead th:nth-child(1)");
082 assertTextPresent(PRINCIPAL_NAME_COLUMN_NAME, "div#uLookupResults thead th:nth-child(1) label",
083 "Principal Name column not present");
084
085 // Case 2 - Search by Group
086 waitAndTypeByName(LOOKUP_CRITERIA_TYPE_CODE, "G");
087 waitAndClickButtonByText(SEARCH);
088 Thread.sleep(3000);
089 Assert.assertEquals(2, getCssCount("div#uLookupResults thead th"));
090 assertElementPresent("div#uLookupResults thead th:nth-child(1)");
091 assertTextPresent(GROUP_NAME_COLUMN_NAME, "div#uLookupResults thead th:nth-child(1) label",
092 "Group Name column not present");
093 assertElementPresent("div#uLookupResults thead th:nth-child(2)");
094 assertTextPresent(DESCRIPTION_COLUMN_NAME, "div#uLookupResults thead th:nth-child(2) label",
095 "Description column not present");
096
097 // Case 3 - Search by Role
098 waitAndTypeByName(LOOKUP_CRITERIA_TYPE_CODE, "R");
099 waitAndClickButtonByText(SEARCH);
100 Thread.sleep(3000);
101 Assert.assertEquals(2, getCssCount("div#uLookupResults thead th"));
102 assertTextPresent(ROLE_NAME_COLUMN_NAME, "div#uLookupResults thead th:nth-child(1) label",
103 "Role Name column not present");
104 assertElementPresent("div#uLookupResults thead th:nth-child(2)");
105 assertTextPresent(DESCRIPTION_COLUMN_NAME, "div#uLookupResults thead th:nth-child(2) label",
106 "Description column not present");
107 }
108
109 @Test
110 public void testLookUpConditionalResultsBasedOnCriteriaBookmark() throws Exception {
111 testLookUpConditionalResultsBasedOnCriteria();
112 passed();
113 }
114
115 @Test
116 public void testLookUpConditionalResultsBasedOnCriteriaNav() throws Exception {
117 testLookUpConditionalResultsBasedOnCriteria();
118 passed();
119 }
120 }