001 /**
002 * Copyright 2005-2011 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.configview;
017
018 import edu.samplu.common.UpgradedSeleniumITBase;
019 import org.junit.Test;
020
021 import static org.junit.Assert.*;
022
023 /**
024 * Test the help widget
025 *
026 * <p>
027 * Selenium RC does not allow us to test the external help popup windows due to an error on JavaScrips window.close
028 * method when selenium is running. To test the external help we use the {@link HelpIT2} test
029 * which utilizes WebDriver. Unfortunately due to a WebDriver bug/feature we can't test the tooltip help there.
030 * </p>
031 *
032 * @author Kuali Rice Team (rice.collab@kuali.org)
033 */
034 public class HelpIT extends UpgradedSeleniumITBase {
035
036 // Delay in milliseconds used to allow the help window reload the new help page.
037 // waitForPopUp will not work since the window already exists.
038 private long HELP_WINDOW_LOAD_DELAY = 3000;
039
040 @Override
041 public String getTestUrl() {
042 return "/kr-krad/configuration-test-view-uif-controller?viewId=ConfigurationTestView-Help&methodToCall=start";
043 }
044
045 /**
046 * Test the tooltip and external help on the view
047 */
048 @Test
049 public void testViewHelp() throws Exception {
050 // test tooltip help
051 mouseOver("css=h1 .uif-headerText-span");
052 assertEquals("Sample text for view help", getText("css=td.jquerybubblepopup-innerHtml"));
053
054 // test external help
055 waitAndClick("css=input[title=\"Help for Configuration Test View - Help\"]");
056 //selenium.waitForPopUp("Open Source Software | www.kuali.org", "30000");
057 //selenium.selectPopUp("HelpWindow");
058 Thread.sleep(5000);
059 selectWindow("Open Source Software | www.kuali.org");
060 Thread.sleep(5000);
061 assertEquals("http://www.kuali.org/?view", getLocation());
062 //selenium.deselectPopUp();
063 selectWindow("Kuali :: Configuration Test View - Help");
064 }
065
066 /**
067 * Test the tooltip and external help on the page
068 */
069 @Test
070 public void testPageHelp() throws Exception {
071 // test tooltip help
072 mouseOver("css=h2 .uif-headerText-span");
073 assertEquals("Sample text for page help", getText("css=td.jquerybubblepopup-innerHtml"));
074
075 // test external help
076 waitAndClick("css=input[title=\"Help for Help Page\"]");
077 //selenium.waitForPopUp("HelpWindow", "30000");
078 //selenium.selectPopUp("HelpWindow");
079 Thread.sleep(5000);
080 selectWindow("Open Source Software | www.kuali.org");
081 Thread.sleep(5000);
082 assertEquals("http://www.kuali.org/?page", getLocation());
083 //selenium.deselectPopUp();
084 selectWindow("Kuali :: Configuration Test View - Help");
085 }
086
087 /**
088 * Test the tooltip help on the section and fields
089 */
090 @Test
091 public void testTooltipHelp() throws Exception {
092 // verify that no tooltips are displayed initially
093 if (isElementPresent("css=td:contains(\"Sample text for section help - tooltip help\")")) {
094 assertFalse(isVisible("css=td:contains(\"Sample text for section help - tooltip help\")"));
095 }
096 if (isElementPresent("css=td:contains(\"Sample text for field help - label left\")")) {
097 assertFalse(isVisible("css=td:contains(\"Sample text for field help - label left\")"));
098 }
099 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 }