View Javadoc

1   /**
2    * Copyright 2005-2011 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.configview;
17  
18  import edu.samplu.common.UpgradedSeleniumITBase;
19  import org.junit.Test;
20  
21  import static org.junit.Assert.*;
22  
23  /**
24   * Test the help widget
25   *
26   * <p>
27   * Selenium RC does not allow us to test the external help popup windows due to an error on JavaScrips window.close
28   * method when selenium is running.  To test the external help we use the {@link HelpIT2} test
29   * which utilizes WebDriver.  Unfortunately due to a WebDriver bug/feature we can't test the tooltip help there.
30   * </p>
31   *
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class HelpIT extends UpgradedSeleniumITBase {
35  
36      // Delay in milliseconds used to allow the help window reload the new help page.
37      // waitForPopUp will not work since the window already exists.
38      private long HELP_WINDOW_LOAD_DELAY = 3000;
39  
40      @Override
41      public String getTestUrl() {
42          return "/kr-krad/configuration-test-view-uif-controller?viewId=ConfigurationTestView-Help&methodToCall=start";
43      }
44  
45      /**
46       * Test the tooltip and external help on the view
47       */
48      @Test
49      public void testViewHelp() throws Exception {
50          // test tooltip help
51          mouseOver("css=h1 .uif-headerText-span");
52          assertEquals("Sample text for view help", getText("css=td.jquerybubblepopup-innerHtml"));
53  
54          // test external help
55          waitAndClick("css=input[title=\"Help for Configuration Test View - Help\"]");
56          //selenium.waitForPopUp("Open Source Software | www.kuali.org", "30000");
57          //selenium.selectPopUp("HelpWindow");
58          Thread.sleep(5000);
59          selectWindow("Open Source Software | www.kuali.org");
60          Thread.sleep(5000);
61          assertEquals("http://www.kuali.org/?view", getLocation());
62          //selenium.deselectPopUp();
63          selectWindow("Kuali :: Configuration Test View - Help");
64      }
65  
66      /**
67       * Test the tooltip and external help on the page
68       */
69      @Test
70      public void testPageHelp() throws Exception {
71          // test tooltip help
72          mouseOver("css=h2 .uif-headerText-span");
73          assertEquals("Sample text for page help", getText("css=td.jquerybubblepopup-innerHtml"));
74  
75          // test external help
76          waitAndClick("css=input[title=\"Help for Help Page\"]");
77          //selenium.waitForPopUp("HelpWindow", "30000");
78          //selenium.selectPopUp("HelpWindow");
79          Thread.sleep(5000);
80          selectWindow("Open Source Software | www.kuali.org");
81          Thread.sleep(5000);      
82          assertEquals("http://www.kuali.org/?page", getLocation());
83          //selenium.deselectPopUp();
84          selectWindow("Kuali :: Configuration Test View - Help");
85      }
86  
87      /**
88       * Test the tooltip help on the section and fields
89       */
90      @Test
91      public void testTooltipHelp() throws Exception {
92          // verify that no tooltips are displayed initially
93          if (isElementPresent("css=td:contains(\"Sample text for section help - tooltip help\")")) {
94              assertFalse(isVisible("css=td:contains(\"Sample text for section help - tooltip help\")"));
95          }
96          if (isElementPresent("css=td:contains(\"Sample text for field help - label left\")")) {
97              assertFalse(isVisible("css=td:contains(\"Sample text for field help - label left\")"));
98          }
99          if (isElementPresent("css=td:contains(\"Sample text for field help - label right\")")) {
100             assertFalse(isVisible("css=td:contains(\"Sample text for field help - label right\")"));
101         }
102         if (isElementPresent("css=td:contains(\"Sample text for field help - label top\")")) {
103             assertFalse(isVisible("css=td:contains(\"Sample text for field help - label top\")"));
104         }
105         if (isElementPresent("css=td:contains(\"Sample text for standalone help widget tooltip which will never be rendered\")")) {
106             assertFalse(isVisible("css=td:contains(\"Sample text for standalone help widget tooltip which will never be rendered\")"));
107         }
108         if (isElementPresent("css=td:contains(\"Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip\")")) {
109             assertFalse(isVisible("css=td:contains(\"Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip\")"));
110         }
111         if (isElementPresent("css=td:contains(\"Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip\")")) {
112             assertFalse(isVisible("css=td:contains(\"Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip\")"));
113         }
114         if (isElementPresent("css=td:contains(\"Sample text for field help - there is also an on-focus tooltip\")")) {
115             assertFalse(isVisible("css=td:contains(\"Sample text for field help - there is also an on-focus tooltip\")"));
116         }
117         if (isElementPresent("css=td:contains(\"Sample text for on-focus event tooltip\")")) {
118             assertFalse(isVisible("css=td:contains(\"Sample text for on-focus event tooltip\")"));
119         }
120         if (isElementPresent("css=td:contains(\"Sample text for check box help\")")) {
121             assertFalse(isVisible("css=td:contains(\"Sample text for check box help\")"));
122         }
123 
124         // test tooltip help of section header
125         mouseOver("css=#ConfigurationTestView-Help-Section1 h3 .uif-headerText-span");
126         assertTrue(isVisible("css=td:contains(\"Sample text for section help - tooltip help\")"));
127         mouseOut("css=#ConfigurationTestView-Help-Section1 h3 .uif-headerText-span");
128         assertFalse(isVisible("css=td:contains(\"Sample text for section help - tooltip help\")"));
129 
130         // verify that no external help exist
131         assertFalse(isElementPresent("css=#ConfigurationTestView-Help-Section1 input.uif-helpImage"));
132 
133         // test tooltip help of field with label to the left
134         mouseOver("id=field-label-left_label");
135         assertTrue(isVisible("css=td:contains(\"Sample text for field help - label left\")"));
136         mouseOut("id=field-label-left_label");
137         assertFalse(isVisible("css=td:contains(\"Sample text for field help - label left\")"));
138 
139         // test tooltip help of field with label to the right
140         mouseOver("id=field-label-right_label");
141         assertTrue(isVisible("css=td:contains(\"Sample text for field help - label righ\")"));
142         mouseOut("id=field-label-right_label");
143         assertFalse(isVisible("css=td:contains(\"Sample text for field help - label right\")"));
144 
145         // test tooltip help of field with label to the top
146         mouseOver("id=field-label-top_label");
147         assertTrue(isVisible("css=td:contains(\"Sample text for field help - label top\")"));
148         mouseOut("id=field-label-top_label");
149         assertFalse(isVisible("css=td:contains(\"Sample text for field help - label top\")"));
150 
151         // verify that standalone help with tooltip is not rendered
152         assertFalse(isElementPresent("id=standalone-help-not-rendered"));
153 
154         // test tooltip help when it overrides a tooltip
155         mouseOver("id=override-tooltip_label");
156         assertTrue(isVisible("css=td:contains(\"Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip\")"));
157         if (isElementPresent("css=td:contains(\"Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip\")")) {
158             assertFalse(isVisible("css=td:contains(\"Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip\")"));
159         }
160         mouseOut("id=override-tooltip_label");
161         assertFalse(isVisible("css=td:contains(\"Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip\")"));
162 
163         // test tooltip help in conjunction with a focus event tooltip
164         mouseOver("id=on-focus-tooltip_control");
165         assertTrue(isVisible("css=td:contains(\"Sample text for on-focus event tooltip\")"));
166         mouseOver("id=on-focus-tooltip_label");
167         assertTrue(isVisible("css=td:contains(\"Sample text for field help - there is also an on-focus tooltip\")"));
168         mouseOut("id=on-focus-tooltip_control");
169         mouseOut("id=on-focus-tooltip_label");
170         assertFalse(isVisible("css=td:contains(\"Sample text for field help - there is also an on-focus tooltip\")"));
171         assertFalse(isVisible("css=td:contains(\"Sample text for on-focus event tooltip\")"));
172 
173         // test tooltip help against a check box - help contains html
174         mouseOver("id=checkbox_label");
175         assertTrue(isVisible("css=td:contains(\"Sample text for check box help\")"));
176         mouseOut("id=checkbox_label");
177         assertFalse(isVisible("css=td:contains(\"Sample text for check box help\")"));
178     }
179 
180     /**
181      * Test the tooltip help on the sub-section and fields that are display only
182      */
183     @Test
184     public void testDisplayOnlyTooltipHelp() throws Exception {
185         // verify that no tooltips are displayed initially
186         if (isElementPresent("css=td:contains(\"Sample text for sub-section help\")")) {
187             assertFalse(isVisible("css=td:contains(\"Sample text for sub-section help\")"));
188         }
189         if (isElementPresent("css=td:contains(\"Sample text for read only field help\")")) {
190             assertFalse(isVisible("css=td:contains(\"Sample text for read only field help\")"));
191         }
192 
193         // test tooltip help of sub-section header
194         mouseOver("css=h4 .uif-headerText-span");
195         assertTrue(isVisible("css=td:contains(\"Sample text for sub-section help\")"));
196         mouseOut("css=h4 .uif-headerText-span");
197         assertFalse(isVisible("css=td:contains(\"Sample text for sub-section help\")"));
198 
199         // test tooltip help of display only data field
200         mouseOver("css=#display-field label");
201         assertTrue(isVisible("css=td:contains(\"Sample text for read only field help\")"));
202         mouseOut("css=#display-field label");
203         assertFalse(isVisible("css=td:contains(\"Sample text for read only field help\")"));
204     }
205 
206     /**
207      * Test the tooltip help on the section and fields with no content
208      */
209     @Test
210     public void testMissingTooltipHelp() throws Exception {
211         // verify that no tooltips are displayed initially
212         assertFalse(isElementPresent("css=.jquerybubblepopup"));
213 
214         // verify that no external help exist
215         assertFalse(isElementPresent("css=#ConfigurationTestView-Help-Section2 input.uif-helpImage"));
216 
217         // test tooltip help of section header
218         mouseOver("css=#ConfigurationTestView-Help-Section2 h3 .uif-headerText-span");
219         assertFalse(isElementPresent("css=.jquerybubblepopup"));
220         mouseOut("css=#ConfigurationTestView-Help-Section1 h3 .uif-headerText-span");
221         assertFalse(isElementPresent("css=.jquerybubblepopup"));
222 
223         // test tooltip help of field
224         mouseOver("id=missing-tooltip-help_label");
225         assertFalse(isElementPresent("css=.jquerybubblepopup"));
226         mouseOut("id=missing-tooltip-help_label");
227         assertFalse(isElementPresent("css=.jquerybubblepopup"));
228     }
229 }