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 org.junit.After;
019 import org.junit.Before;
020 import org.junit.Ignore;
021 import org.junit.Test;
022
023 import com.thoughtworks.selenium.DefaultSelenium;
024 import com.thoughtworks.selenium.Selenium;
025
026 import static org.junit.Assert.*;
027
028 /**
029 * Test the help widget
030 *
031 * <p>
032 * Selenium RC does not allow us to test the external help popup windows due to an error on JavaScrips window.close
033 * method when selenium is running. To test the external help we use the {@link HelpIT2} test
034 * which utilizes WebDriver. Unfortunately due to a WebDriver bug/feature we can't test the tooltip help there.
035 * </p>
036 *
037 * @author Kuali Rice Team (rice.collab@kuali.org)
038 */
039 public class HelpIT {
040 private Selenium selenium;
041
042 // Delay in milliseconds used to allow the help window reload the new help page.
043 // waitForPopUp will not work since the window already exists.
044 private long HELP_WINDOW_LOAD_DELAY = 3000;
045
046 @Before
047 public void setUp() throws Exception {
048 System.setProperty("remote.public.url", "http://localhost:8080/kr-dev/kr-krad/configuration-test-view-uif-controller?viewId=ConfigurationTestView-Help&methodToCall=start");
049 selenium = new DefaultSelenium("localhost", 4444, "*firefox", System.getProperty("remote.public.url"));
050 selenium.start();
051
052 // Login
053 selenium.open(System.getProperty("remote.public.url"));
054 assertEquals("Login", selenium.getTitle());
055 selenium.type("__login_user", "admin");
056 selenium.click("//input[@value='Login']");
057 selenium.waitForPageToLoad("30000");
058 }
059
060 /**
061 * Test the tooltip and external help on the view
062 */
063 @Test
064 public void testViewHelp() throws Exception {
065 // test tooltip help
066 selenium.mouseOver("css=h1 .uif-headerText-span");
067 assertEquals("Sample text for view help", selenium.getText("css=td.jquerybubblepopup-innerHtml"));
068
069 // test external help
070 selenium.click("css=input[title=\"Help for Configuration Test View - Help\"]");
071 selenium.waitForPopUp("HelpWindow", "30000");
072 selenium.selectPopUp("HelpWindow");
073 assertEquals("http://www.kuali.org/?view", selenium.getLocation());
074 selenium.deselectPopUp();
075 }
076
077 /**
078 * Test the tooltip and external help on the page
079 */
080 @Test
081 public void testPageHelp() throws Exception {
082 // test tooltip help
083 selenium.mouseOver("css=h2 .uif-headerText-span");
084 assertEquals("Sample text for page help", selenium.getText("css=td.jquerybubblepopup-innerHtml"));
085
086 // test external help
087 selenium.click("css=input[title=\"Help for Help Page\"]");
088 selenium.waitForPopUp("HelpWindow", "30000");
089 selenium.selectPopUp("HelpWindow");
090 assertEquals("http://www.kuali.org/?page", selenium.getLocation());
091 selenium.deselectPopUp();
092 }
093
094 /**
095 * Test the tooltip help on the section and fields
096 */
097 @Test
098 public void testTooltipHelp() throws Exception {
099 // verify that no tooltips are displayed initially
100 if (selenium.isElementPresent("css=td:contains(\"Sample text for section help - tooltip help\")")) {
101 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for section help - tooltip help\")"));
102 }
103 if (selenium.isElementPresent("css=td:contains(\"Sample text for field help - label left\")")) {
104 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for field help - label left\")"));
105 }
106 if (selenium.isElementPresent("css=td:contains(\"Sample text for field help - label right\")")) {
107 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for field help - label right\")"));
108 }
109 if (selenium.isElementPresent("css=td:contains(\"Sample text for field help - label top\")")) {
110 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for field help - label top\")"));
111 }
112 if (selenium.isElementPresent("css=td:contains(\"Sample text for standalone help widget tooltip which will never be rendered\")")) {
113 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for standalone help widget tooltip which will never be rendered\")"));
114 }
115 if (selenium.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\")")) {
116 assertFalse(selenium.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\")"));
117 }
118 if (selenium.isElementPresent("css=td:contains(\"Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip\")")) {
119 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip\")"));
120 }
121 if (selenium.isElementPresent("css=td:contains(\"Sample text for field help - there is also an on-focus tooltip\")")) {
122 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for field help - there is also an on-focus tooltip\")"));
123 }
124 if (selenium.isElementPresent("css=td:contains(\"Sample text for on-focus event tooltip\")")) {
125 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for on-focus event tooltip\")"));
126 }
127 if (selenium.isElementPresent("css=td:contains(\"Sample text for check box help\")")) {
128 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for check box help\")"));
129 }
130
131 // test tooltip help of section header
132 selenium.mouseOver("css=#ConfigurationTestView-Help-Section1 h3 .uif-headerText-span");
133 assertTrue(selenium.isVisible("css=td:contains(\"Sample text for section help - tooltip help\")"));
134 selenium.mouseOut("css=#ConfigurationTestView-Help-Section1 h3 .uif-headerText-span");
135 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for section help - tooltip help\")"));
136
137 // verify that no external help exist
138 assertFalse(selenium.isElementPresent("css=#ConfigurationTestView-Help-Section1 input.uif-helpImage"));
139
140 // test tooltip help of field with label to the left
141 selenium.mouseOver("id=field-label-left_label");
142 assertTrue(selenium.isVisible("css=td:contains(\"Sample text for field help - label left\")"));
143 selenium.mouseOut("id=field-label-left_label");
144 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for field help - label left\")"));
145
146 // test tooltip help of field with label to the right
147 selenium.mouseOver("id=field-label-right_label");
148 assertTrue(selenium.isVisible("css=td:contains(\"Sample text for field help - label righ\")"));
149 selenium.mouseOut("id=field-label-right_label");
150 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for field help - label right\")"));
151
152 // test tooltip help of field with label to the top
153 selenium.mouseOver("id=field-label-top_label");
154 assertTrue(selenium.isVisible("css=td:contains(\"Sample text for field help - label top\")"));
155 selenium.mouseOut("id=field-label-top_label");
156 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for field help - label top\")"));
157
158 // verify that standalone help with tooltip is not rendered
159 assertFalse(selenium.isElementPresent("id=standalone-help-not-rendered"));
160
161 // test tooltip help when it overrides a tooltip
162 selenium.mouseOver("id=override-tooltip_label");
163 assertTrue(selenium.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\")"));
164 if (selenium.isElementPresent("css=td:contains(\"Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip\")")) {
165 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip\")"));
166 }
167 selenium.mouseOut("id=override-tooltip_label");
168 assertFalse(selenium.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\")"));
169
170 // test tooltip help in conjunction with a focus event tooltip
171 selenium.mouseOver("id=on-focus-tooltip_control");
172 assertTrue(selenium.isVisible("css=td:contains(\"Sample text for on-focus event tooltip\")"));
173 selenium.mouseOver("id=on-focus-tooltip_label");
174 assertTrue(selenium.isVisible("css=td:contains(\"Sample text for field help - there is also an on-focus tooltip\")"));
175 selenium.mouseOut("id=on-focus-tooltip_control");
176 selenium.mouseOut("id=on-focus-tooltip_label");
177 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for field help - there is also an on-focus tooltip\")"));
178 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for on-focus event tooltip\")"));
179
180 // test tooltip help against a check box - help contains html
181 selenium.mouseOver("id=checkbox_label");
182 assertTrue(selenium.isVisible("css=td:contains(\"Sample text for check box help\")"));
183 selenium.mouseOut("id=checkbox_label");
184 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for check box help\")"));
185 }
186
187 /**
188 * Test the tooltip help on the sub-section and fields that are display only
189 */
190 @Test
191 public void testDisplayOnlyTooltipHelp() throws Exception {
192 // verify that no tooltips are displayed initially
193 if (selenium.isElementPresent("css=td:contains(\"Sample text for sub-section help\")")) {
194 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for sub-section help\")"));
195 }
196 if (selenium.isElementPresent("css=td:contains(\"Sample text for read only field help\")")) {
197 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for read only field help\")"));
198 }
199
200 // test tooltip help of sub-section header
201 selenium.mouseOver("css=h4 .uif-headerText-span");
202 assertTrue(selenium.isVisible("css=td:contains(\"Sample text for sub-section help\")"));
203 selenium.mouseOut("css=h4 .uif-headerText-span");
204 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for sub-section help\")"));
205
206 // test tooltip help of display only data field
207 selenium.mouseOver("css=#display-field label");
208 assertTrue(selenium.isVisible("css=td:contains(\"Sample text for read only field help\")"));
209 selenium.mouseOut("css=#display-field label");
210 assertFalse(selenium.isVisible("css=td:contains(\"Sample text for read only field help\")"));
211 }
212
213 /**
214 * Test the tooltip help on the section and fields with no content
215 */
216 @Test
217 public void testMissingTooltipHelp() throws Exception {
218 // verify that no tooltips are displayed initially
219 assertFalse(selenium.isElementPresent("css=.jquerybubblepopup"));
220
221 // verify that no external help exist
222 assertFalse(selenium.isElementPresent("css=#ConfigurationTestView-Help-Section2 input.uif-helpImage"));
223
224 // test tooltip help of section header
225 selenium.mouseOver("css=#ConfigurationTestView-Help-Section2 h3 .uif-headerText-span");
226 assertFalse(selenium.isElementPresent("css=.jquerybubblepopup"));
227 selenium.mouseOut("css=#ConfigurationTestView-Help-Section1 h3 .uif-headerText-span");
228 assertFalse(selenium.isElementPresent("css=.jquerybubblepopup"));
229
230 // test tooltip help of field
231 selenium.mouseOver("id=missing-tooltip-help_label");
232 assertFalse(selenium.isElementPresent("css=.jquerybubblepopup"));
233 selenium.mouseOut("id=missing-tooltip-help_label");
234 assertFalse(selenium.isElementPresent("css=.jquerybubblepopup"));
235 }
236
237 @After
238 public void tearDown() throws Exception {
239 selenium.stop();
240 }
241
242 }