View Javadoc

1   /*
2    * Copyright 2006-2012 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  
17  package edu.samplu.krad.configview;
18  
19  import edu.samplu.common.WebDriverITBase;
20  import org.junit.Test;
21  import org.openqa.selenium.By;
22  import org.openqa.selenium.interactions.Actions;
23  
24  import static org.junit.Assert.assertEquals;
25  import static org.junit.Assert.assertFalse;
26  import static org.junit.Assert.assertTrue;
27  
28  /**
29   * Test the help widget
30   *
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  public class HelpIT2 extends WebDriverITBase {
34  
35      /**
36       * URL for the Configuration Test View - Help
37       *
38       * <p>
39       * Due to a WebDriver bug (feature?) the tooltips can not be tested with WebDriver.  {@link HelpIT} is being used
40       * to test help tooltips.
41       * </p>
42       *
43       * @see edu.samplu.common.WebDriverITBase#getTestUrl()
44       */
45      @Override
46      public String getTestUrl() {
47          return "http://localhost:8080/kr-dev/kr-krad/configuration-test-view-uif-controller?viewId=ConfigurationTestView-Help&methodToCall=start";
48      }
49  
50      /**
51       * Test the tooltip and external help on the view
52       */
53      @Test
54      public void testViewHelp() throws Exception {
55          // test tooltip help
56          if (isElementPresentQuick(By.cssSelector("td.jquerybubblepopup-innerHtml"))) {
57              assertFalse(driver.findElement(By.cssSelector("td.jquerybubblepopup-innerHtml")).isDisplayed());
58          }
59          Actions action = new Actions(driver);
60          action.moveToElement(driver.findElement(By.cssSelector("h1 .uif-headerText-span"))).perform();
61          assertEquals(driver.findElement(By.cssSelector("td.jquerybubblepopup-innerHtml")).getText(), "Sample text for view help");
62          assertTrue(driver.findElement(By.cssSelector("td.jquerybubblepopup-innerHtml")).isDisplayed());
63          action.moveToElement(driver.findElement(By.id("mouse-out"))).perform();
64          // TODO: moveToElement does not remove mouse focus on previous element. (WebDriver bug?) Therefore we
65          //       can not check for the proper behavior of the mouse out events.
66          //       Also since multiple tooltips would be displayed we can not test multiple tooltips in one test.  Thus
67          //       Tooltips are being tested in the Selenium RC test HelpIT.java
68          //       This code has been left in place to show a sample of how tooltip help testing would be performed, in
69          //       the hopes that eventually all the testing can be converted to WebDriver.
70  //        if (isElementPresentQuick(By.cssSelector("td.jquerybubblepopup-innerHtml"))) {
71  //            assertFalse(driver.findElement(By.cssSelector("td.jquerybubblepopup-innerHtml")).isDisplayed());
72  //        }
73  
74          // test external help
75          assertPopUpWindowUrl(By.cssSelector("input[title=\"Help for Configuration Test View - Help\"]"), "HelpWindow", "http://www.kuali.org/?view");
76      }
77  
78      /**
79       * Test the external help on the section and fields
80       */
81      @Test
82      public void testExternalHelp() throws Exception {
83          // test external help of section
84          assertPopUpWindowUrl(By.cssSelector("input[title=\"Help for External Help\"]"), "HelpWindow", "http://www.kuali.org/?section");
85  
86          // test external help of field with label left
87          assertPopUpWindowUrl(By.cssSelector("#field-label-left-external-help .uif-helpImage"), "HelpWindow",
88                  "http://www.kuali.org/?label_left");
89  
90          // test external help of field with label right
91          assertPopUpWindowUrl(By.cssSelector("#field-label-right-external-help .uif-helpImage"), "HelpWindow",
92                  "http://www.kuali.org/?label_right");
93  
94          // test external help of field with label top and help URL from system parameters
95          assertPopUpWindowUrl(By.cssSelector("#field-label-top-external-help .uif-helpImage"), "HelpWindow",
96                  "http://www.kuali.org/?system_parm");
97  
98          // test external help of standalone help widget
99          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 }