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