View Javadoc

1   /**
2    * Copyright 2005-2013 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 edu.samplu.krad.demo.lookupviews.lookup.conditionalresults;
17  
18  import org.junit.Assert;
19  import org.kuali.rice.testtools.selenium.SmokeTestBase;
20  import org.junit.Test;
21  
22  import static org.junit.Assert.assertEquals;
23  
24  /**
25   * @author Kuali Rice Team (rice.collab@kuali.org)
26   */
27  public class DemoLookUpConditionalResultsSmokeTest extends SmokeTestBase {
28  
29      /**
30       * /kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalResults&hideReturnLink=true
31       */
32      public static final String BOOKMARK_URL = "/kr-krad/lookup?methodToCall=start&viewId=LookupSampleViewConditionalResults";
33  
34      /**
35       *  lookupCriteria[number]
36       */
37      private static final String LOOKUP_CRITERIA_NUMBER_NAME = "lookupCriteria[number]";
38  
39      /**
40       *  Search
41       */
42      private static final String SEARCH = "Search";
43  
44      /**
45       *  Travel Account Number column
46       */
47      private static final String TRAVEL_ACCOUNT_NAME_COLUMN_NAME = "Travel Account Number";
48  
49      /**
50       *  Account Name column
51       */
52      private static final String ACCOUNT_NAME_COLUMN_NAME = "Account Name";
53  
54      /**
55       *  Date Created column
56       */
57      private static final String DATE_CREATED_COLUMN_NAME = "Date Created";
58  
59      @Override
60      public String getBookmarkUrl() {
61          return BOOKMARK_URL;
62      }
63  
64      @Override
65      protected void navigate() throws Exception {
66          waitAndClickById("Demo-DemoLink", "");
67          waitAndClickByLinkText("Lookup Conditional Results");
68      }
69  
70      protected void testLookUpConditionalResults() throws InterruptedException {
71          // Case 1 - Search of a1 only shows Travel Account Number column
72          waitAndTypeByName(LOOKUP_CRITERIA_NUMBER_NAME, "a1");
73          waitAndClickButtonByText(SEARCH);
74          Thread.sleep(3000);
75          Assert.assertEquals(1, getCssCount("div#uLookupResults thead th"));
76          assertElementPresent("div#uLookupResults thead th:nth-child(1)");
77          assertTextPresent(TRAVEL_ACCOUNT_NAME_COLUMN_NAME, "div#uLookupResults thead th:nth-child(1) label",
78                  "Travel Account Name column not present");
79  
80          // Case 2 - Empty research shows all columns
81          clearTextByName(LOOKUP_CRITERIA_NUMBER_NAME);
82          waitAndClickButtonByText(SEARCH);
83          Thread.sleep(3000);
84          Assert.assertEquals(3, getCssCount("div#uLookupResults thead th"));
85          assertElementPresent("div#uLookupResults thead th:nth-child(1)");
86          assertTextPresent(TRAVEL_ACCOUNT_NAME_COLUMN_NAME, "div#uLookupResults thead th:nth-child(1) label",
87                  "Travel Account Name column not present");
88          assertElementPresent("div#uLookupResults thead th:nth-child(2)");
89          assertTextPresent(ACCOUNT_NAME_COLUMN_NAME, "div#uLookupResults thead th:nth-child(2) label",
90                  "Account Name column not present");
91          assertElementPresent("div#uLookupResults thead th:nth-child(3)");
92          assertTextPresent(DATE_CREATED_COLUMN_NAME, "div#uLookupResults thead th:nth-child(3) label",
93                  "Date Created column not present");
94      }
95  
96      @Test
97      public void testLookUpConditionalResultsBookmark() throws Exception {
98          testLookUpConditionalResults();
99          passed();
100     }
101 
102     @Test
103     public void testLookUpConditionalResultsNav() throws Exception {
104         testLookUpConditionalResults();
105         passed();
106     }
107 }