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