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 DemoLookUpConditionalResultsSmokeTest extends SmokeTestBase {
028
029 /**
030 * /kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalResults&hideReturnLink=true
031 */
032 public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalResults";
033
034 /**
035 * lookupCriteria[number]
036 */
037 private static final String LOOKUP_CRITERIA_NUMBER_NAME = "lookupCriteria[number]";
038
039 /**
040 * Search
041 */
042 private static final String SEARCH = "Search";
043
044 /**
045 * Travel Account Number column
046 */
047 private static final String TRAVEL_ACCOUNT_NAME_COLUMN_NAME = "Travel Account Number";
048
049 /**
050 * Account Name column
051 */
052 private static final String ACCOUNT_NAME_COLUMN_NAME = "Account Name";
053
054 /**
055 * Date Created column
056 */
057 private static final String DATE_CREATED_COLUMN_NAME = "Date Created";
058
059 @Override
060 public String getBookmarkUrl() {
061 return BOOKMARK_URL;
062 }
063
064 @Override
065 protected void navigate() throws Exception {
066 waitAndClickById("Demo-DemoLink", "");
067 waitAndClickByLinkText("Lookup Conditional Results");
068 }
069
070 protected void testLookUpConditionalResults() throws InterruptedException {
071 // Case 1 - Search of a1 only shows Travel Account Number column
072 waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME, "a1");
073 waitAndClickButtonByText(SEARCH);
074 Thread.sleep(3000);
075 Assert.assertEquals(1, getCssCount("div#uLookupResults thead th"));
076 assertElementPresent("div#uLookupResults thead th:nth-child(1)");
077 assertTextPresent(TRAVEL_ACCOUNT_NAME_COLUMN_NAME, "div#uLookupResults thead th:nth-child(1) label",
078 "Travel Account Name column not present");
079
080 // Case 2 - Empty research shows all columns
081 clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
082 waitAndClickButtonByText(SEARCH);
083 Thread.sleep(3000);
084 Assert.assertEquals(3, getCssCount("div#uLookupResults thead th"));
085 assertElementPresent("div#uLookupResults thead th:nth-child(1)");
086 assertTextPresent(TRAVEL_ACCOUNT_NAME_COLUMN_NAME, "div#uLookupResults thead th:nth-child(1) label",
087 "Travel Account Name column not present");
088 assertElementPresent("div#uLookupResults thead th:nth-child(2)");
089 assertTextPresent(ACCOUNT_NAME_COLUMN_NAME, "div#uLookupResults thead th:nth-child(2) label",
090 "Account Name column not present");
091 assertElementPresent("div#uLookupResults thead th:nth-child(3)");
092 assertTextPresent(DATE_CREATED_COLUMN_NAME, "div#uLookupResults thead th:nth-child(3) label",
093 "Date Created column not present");
094 }
095
096 @Test
097 public void testLookUpConditionalResultsBookmark() throws Exception {
098 testLookUpConditionalResults();
099 passed();
100 }
101
102 @Test
103 public void testLookUpConditionalResultsNav() throws Exception {
104 testLookUpConditionalResults();
105 passed();
106 }
107 }