001 /* 002 * Copyright 2006-2012 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 017 package edu.samplu.krad.configview; 018 019 import edu.samplu.common.WebDriverITBase; 020 import org.junit.Test; 021 import org.openqa.selenium.By; 022 import org.openqa.selenium.interactions.Actions; 023 024 import static org.junit.Assert.assertEquals; 025 import static org.junit.Assert.assertFalse; 026 import static org.junit.Assert.assertTrue; 027 028 /** 029 * Test the help widget 030 * 031 * @author Kuali Rice Team (rice.collab@kuali.org) 032 */ 033 public class HelpIT2 extends WebDriverITBase { 034 035 /** 036 * URL for the Configuration Test View - Help 037 * 038 * <p> 039 * Due to a WebDriver bug (feature?) the tooltips can not be tested with WebDriver. {@link HelpIT} is being used 040 * to test help tooltips. 041 * </p> 042 * 043 * @see edu.samplu.common.WebDriverITBase#getTestUrl() 044 */ 045 @Override 046 public String getTestUrl() { 047 return "/kr-krad/configuration-test-view-uif-controller?viewId=ConfigurationTestView-Help&methodToCall=start"; 048 } 049 050 /** 051 * Test the tooltip and external help on the view 052 */ 053 @Test 054 public void testViewHelp() throws Exception { 055 // test tooltip help 056 if (isElementPresentQuick(By.cssSelector("td.jquerybubblepopup-innerHtml"))) { 057 assertFalse(driver.findElement(By.cssSelector("td.jquerybubblepopup-innerHtml")).isDisplayed()); 058 } 059 Actions action = new Actions(driver); 060 action.moveToElement(driver.findElement(By.cssSelector("h1 .uif-headerText-span"))).perform(); 061 assertEquals(driver.findElement(By.cssSelector("td.jquerybubblepopup-innerHtml")).getText(), "Sample text for view help"); 062 assertTrue(driver.findElement(By.cssSelector("td.jquerybubblepopup-innerHtml")).isDisplayed()); 063 action.moveToElement(driver.findElement(By.id("mouse-out"))).perform(); 064 // TODO: moveToElement does not remove mouse focus on previous element. (WebDriver bug?) Therefore we 065 // can not check for the proper behavior of the mouse out events. 066 // Also since multiple tooltips would be displayed we can not test multiple tooltips in one test. Thus 067 // Tooltips are being tested in the Selenium RC test HelpIT.java 068 // This code has been left in place to show a sample of how tooltip help testing would be performed, in 069 // the hopes that eventually all the testing can be converted to WebDriver. 070 // if (isElementPresentQuick(By.cssSelector("td.jquerybubblepopup-innerHtml"))) { 071 // assertFalse(driver.findElement(By.cssSelector("td.jquerybubblepopup-innerHtml")).isDisplayed()); 072 // } 073 074 // test external help 075 assertPopUpWindowUrl(By.cssSelector("input[title=\"Help for Configuration Test View - Help\"]"), "HelpWindow", "http://www.kuali.org/?view"); 076 } 077 078 /** 079 * Test the external help on the section and fields 080 */ 081 @Test 082 public void testExternalHelp() throws Exception { 083 // test external help of section 084 assertPopUpWindowUrl(By.cssSelector("input[title=\"Help for External Help\"]"), "HelpWindow", "http://www.kuali.org/?section"); 085 086 // test external help of field with label left 087 assertPopUpWindowUrl(By.cssSelector("#field-label-left-external-help .uif-helpImage"), "HelpWindow", 088 "http://www.kuali.org/?label_left"); 089 090 // test external help of field with label right 091 assertPopUpWindowUrl(By.cssSelector("#field-label-right-external-help .uif-helpImage"), "HelpWindow", 092 "http://www.kuali.org/?label_right"); 093 094 // test external help of field with label top and help URL from system parameters 095 assertPopUpWindowUrl(By.cssSelector("#field-label-top-external-help .uif-helpImage"), "HelpWindow", 096 "http://www.kuali.org/?system_parm"); 097 098 // test external help of standalone help widget 099 assertPopUpWindowUrl(By.id("standalone-external-help"), "HelpWindow", "http://www.kuali.org/?widget_only"); 100 } 101 102 /** 103 * Test the external help on the sub-section and display only fields 104 */ 105 @Test 106 public void testDisplayOnlyExternalHelp() throws Exception { 107 // test external help of sub-section 108 assertPopUpWindowUrl(By.cssSelector("input[title=\"Help for Display only fields\"]"), "HelpWindow", "http://www.kuali.org/?sub_section"); 109 110 // test external help of display only data field 111 assertPopUpWindowUrl(By.cssSelector("#display-field-external-help .uif-helpImage"), "HelpWindow", 112 "http://www.kuali.org/?display_field"); 113 } 114 115 /** 116 * Test the external help on the section and fields with missing help URL 117 */ 118 @Test 119 public void testMissingExternalHelp() throws Exception { 120 // test external help of section is not rendered 121 isElementPresent(By.cssSelector("input[title=\"Help for Missing External Help\"]")); 122 123 // test external help of field with blank externalHelpURL is not rendered 124 isElementPresentQuick(By.cssSelector("#external-help-externalHelpUrl-empty .uif-helpImage")); 125 126 // test external help of field with empty helpDefinition is not rendered 127 isElementPresentQuick(By.cssSelector("#external-help-helpdefinition-empty .uif-helpImage")); 128 129 // test external help of field with missing system parameter is not rendered 130 isElementPresentQuick(By.cssSelector("#external-help-system-parm-missing .uif-helpImage")); 131 132 // test external help of standalone help widget is not rendered 133 isElementPresentQuick(By.id("standalone-external-help-missing")); 134 } 135 }