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