View Javadoc
1   /**
2    * Copyright 2005-2014 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  package edu.sampleu.krad.configview;
17  
18  import org.kuali.rice.testtools.common.JiraAwareFailable;
19  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
20  
21  /**
22   * @author Kuali Rice Team (rice.collab@kuali.org)
23   */
24  public abstract class HelpAftBase extends WebDriverLegacyITBase {
25  
26      /**
27       * /kr-krad/configuration-test-view-uif-controller?viewId=ConfigurationTestView&methodToCall=start&pageId=ConfigurationTestView-Help-Page
28       */
29      public static final String BOOKMARK_URL = "/kr-krad/configuration-test-view-uif-controller?viewId=ConfigurationTestView&methodToCall=start&pageId=ConfigurationTestView-Help-Page";
30     
31      @Override
32      protected String getBookmarkUrl() {
33          return BOOKMARK_URL;
34      }
35  
36      protected void navigation() throws Exception {
37          waitAndClickKRAD();
38          waitAndClickByXpath(CONFIGURATION_VIEW_XPATH);
39          switchToWindow(CONFIGURATION_VIEW_WINDOW_TITLE);
40          waitAndClickByLinkText("Help");
41          Thread.sleep(5000);
42      }
43  
44      protected void testHelpNav(JiraAwareFailable failable) throws Exception {
45          navigation();
46          testViewHelp();
47          testPageHelp();
48          testTooltipHelp();
49          testDisplayOnlyTooltipHelp();
50          testMissingTooltipHelp();
51          passed();
52      }
53  
54      protected void testHelpBookmark(JiraAwareFailable failable) throws Exception {
55          testViewHelp();
56          testPageHelp();
57          testTooltipHelp();
58          testDisplayOnlyTooltipHelp();
59          testMissingTooltipHelp();
60          passed();
61      }
62  
63  
64      /**
65       * Test the tooltip and external help on the page
66       */
67      protected void testPageHelp() throws Exception {
68          // test tooltip help
69          fireMouseOverEventByXpath("//a/span[@class='uif-headerText-span']");
70          waitForTextPresent("Sample text for section help - tooltip help");
71  
72          // test external help
73          waitAndClickByXpath("//input[@alt='Help for Configuration Test View']");
74          Thread.sleep(5000);
75          switchToWindow("Kuali Foundation");
76          Thread.sleep(5000);
77          switchToWindow(CONFIGURATION_VIEW_WINDOW_TITLE);
78      }
79  
80      /**
81       * Test the tooltip help on the section and fields
82       */
83      protected void testTooltipHelp() throws Exception {
84          // verify that no tooltips are displayed initially
85          if (isElementPresentByXpath("//td[contains(text(),'Sample text for section help - tooltip help')]")) {
86              assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for section help - tooltip help')]"));
87          }
88  
89          if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - label left')]")) {
90              assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label left')]"));
91          }
92  
93          if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - label right')]")) {
94              assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label right')]"));
95          }
96  
97          if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - label top')]")) {
98              assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label top')]"));
99          }
100 
101         if (isElementPresentByXpath("//td[contains(text(),'Sample text for standalone help widget tooltip which will never be rendered')]")) {
102             assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for standalone help widget tooltip which will never be rendered')]"));
103         }
104 
105         if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip')]")) {
106             assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip')]"));
107         }
108 
109         if (isElementPresentByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]")) {
110             assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]"));
111         }
112 
113         if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - there is also an on-focus tooltip')]")) {
114             assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also an on-focus tooltip')]"));
115         }
116 
117         if (isElementPresentByXpath("//td[contains(text(),'Sample text for on-focus event tooltip')]")) {
118             assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for on-focus event tooltip')]"));
119         }
120 
121         if (isElementPresentByXpath("//td[contains(text(),'Sample text for check box help')]")) {
122             assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for check box help')]"));
123         }
124 
125         // test tooltip help of section header
126         fireMouseOverEventByXpath("//section[@id='ConfigurationTestView-Help-Section1']/header/h3[@class='uif-headerText']");
127         Thread.sleep(500);
128         assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for section help - tooltip help')]"));
129 
130         // verify that no external help exist
131         assertFalse(isElementPresent("#ConfigurationTestView-Help-Section1 input.uif-helpImage"));
132 
133         // test tooltip help of field with label to the left
134         fireMouseOverEventByXpath("//label[@id='field-label-left_label']");
135         Thread.sleep(3000);
136         assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label left')]"));
137 
138         // test tooltip help of field with label to the right
139         fireMouseOverEventByXpath("//label[@id='field-label-right_label']");
140         Thread.sleep(3000);
141         assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label right')]"));
142 
143         // test tooltip help of field with label to the top
144         fireMouseOverEventByXpath("//label[@id='field-label-top_label']");
145         Thread.sleep(3000);
146         assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - label top')]"));
147 
148         // verify that standalone help with tooltip is not rendered
149         assertFalse(isElementPresentByXpath("//*[@id='standalone-help-not-rendered']"));
150 
151         // test tooltip help when it overrides a tooltip
152         fireMouseOverEventByXpath("//label[@id='override-tooltip_label']");
153         Thread.sleep(3000);
154         assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip')]"));
155         if (isElementPresentByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]")) {
156             assertFalse(isVisibleByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]"));
157         }
158 
159         // test tooltip help in conjunction with a focus event tooltip
160         fireMouseOverEventByXpath("//input[@id='on-focus-tooltip_control']");
161         assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for on-focus event tooltip')]"));
162         fireMouseOverEventByXpath("//label[@id='on-focus-tooltip_label']");
163         assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also an on-focus tooltip')]"));
164 
165         // test tooltip help against a check box - help contains html
166         fireMouseOverEventByXpath("//label[@id='checkbox_label']");
167         assertTrue(isVisibleByXpath("//td[contains(text(),'Sample text for check box help')]"));
168     }
169 
170     /**
171      * Test the tooltip help on the sub-section and fields that are display only
172      */
173     protected void testDisplayOnlyTooltipHelp() throws Exception {
174 
175         // test tooltip help of sub-section header
176         fireMouseOverEventByXpath("//section[@data-parent='ConfigurationTestView-Help-Section1']/header/h4");
177         waitForElementPresentByXpath("//td[contains(text(),'Sample text for sub-section help')]");
178 
179         // test tooltip help of display only data field
180         fireMouseOverEventByXpath("//label[@for='display-field_control']");
181         waitForElementPresentByXpath("//td[contains(text(),'Sample text for read only field help')]");
182     }
183 
184     /**
185      * Test the tooltip help on the section and fields with no content
186      */
187     protected void testMissingTooltipHelp() throws Exception {
188 
189         // test tooltip help of section header
190         fireMouseOverEventByXpath("//section[@id='ConfigurationTestView-Help-Section2']/div");
191         assertFalse(isElementPresentByXpath("//div[@class='jquerybubblepopup jquerybubblepopup-black' and @style='opacity: 0; top: 627px; left: 2px; position: absolute; display: block;']"));
192 
193         // test tooltip help of field
194         fireMouseOverEventByXpath("//label[@id='missing-tooltip-help_label']");
195         assertFalse(isElementPresentByXpath("//div[@class='jquerybubblepopup jquerybubblepopup-black' and @style='opacity: 0; top: 627px; left: 2px; position: absolute; display: block;']"));
196     }
197 
198     /**
199      * Test the tooltip and external help on the view
200      */
201     protected void testViewHelp() throws Exception {
202         // test tooltip help
203         fireEvent("field102", "blur");
204         fireMouseOverEventByXpath("//label[@id='field-label-left_label']");
205         waitForTextPresent("Sample text for field help - label left");
206 
207         // test external help
208         waitAndClickByXpath("//input[@alt='Help for Configuration Test View']");
209         Thread.sleep(5000);
210         switchToWindow("Kuali Foundation");
211         Thread.sleep(5000);
212         switchToWindow(CONFIGURATION_VIEW_WINDOW_TITLE);
213     }
214 }