001    /**
002     * Copyright 2005-2014 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.sampleu.krad.configview;
017    
018    import org.kuali.rice.testtools.common.JiraAwareFailable;
019    import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
020    import org.openqa.selenium.By;
021    
022    /**
023     * @author Kuali Rice Team (rice.collab@kuali.org)
024     */
025    public abstract class HelpAftBase extends WebDriverLegacyITBase {
026    
027        /**
028         * /kr-krad/configuration-test-view-uif-controller?viewId=ConfigurationTestView&methodToCall=start&pageId=ConfigurationTestView-Help-Page
029         */
030        public static final String BOOKMARK_URL = "/kr-krad/configuration-test-view-uif-controller?viewId=ConfigurationTestView&methodToCall=start&pageId=ConfigurationTestView-Help-Page";
031       
032        @Override
033        protected String getBookmarkUrl() {
034            return BOOKMARK_URL;
035        }
036    
037        protected void navigation() throws Exception {
038            waitAndClickKRAD();
039            waitAndClickByXpath(CONFIGURATION_VIEW_XPATH);
040            switchToWindow(CONFIGURATION_VIEW_WINDOW_TITLE);
041            waitAndClickByLinkText("Help");
042            Thread.sleep(5000);
043        }
044    
045        protected void testHelpNav(JiraAwareFailable failable) throws Exception {
046            navigation();
047            testViewHelp();
048            testPageHelp();
049            testTooltipHelp();
050            testDisplayOnlyTooltipHelp();
051            testMissingTooltipHelp();
052            passed();
053        }
054    
055        protected void testHelpBookmark(JiraAwareFailable failable) throws Exception {
056            testViewHelp();
057            testPageHelp();
058            testTooltipHelp();
059            testDisplayOnlyTooltipHelp();
060            testMissingTooltipHelp();
061            passed();
062        }
063    
064    
065        /**
066         * Test the tooltip and external help on the page
067         */
068        protected void testPageHelp() throws Exception {
069            // test tooltip help
070            fireMouseOverEventByXpath("//a/span[@class='uif-headerText-span']");
071            waitForTextPresent("Sample text for section help - tooltip help");
072    
073            // test external help
074            waitAndClickByXpath("//input[@alt='Help for Configuration Test View']");
075            Thread.sleep(5000);
076            switchToWindow("Kuali Foundation");
077            Thread.sleep(5000);
078            switchToWindow(CONFIGURATION_VIEW_WINDOW_TITLE);
079        }
080    
081        /**
082         * Test the tooltip help on the section and fields
083         */
084        protected void testTooltipHelp() throws Exception {
085            // verify that no tooltips are displayed initially
086            if (isElementPresentByXpath("//td[contains(text(),'Sample text for section help - tooltip help')]")) {
087                waitNotVisibleByXpath("//td[contains(text(),'Sample text for section help - tooltip help')]");
088            }
089    
090            if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - label left')]")) {
091                waitNotVisibleByXpath("//td[contains(text(),'Sample text for field help - label left')]");
092            }
093    
094            if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - label right')]")) {
095                waitNotVisibleByXpath("//td[contains(text(),'Sample text for field help - label right')]");
096            }
097    
098    // Comment out to see how CI handles the following tests
099    //        if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - label top')]")) {
100    //            waitNotVisibleByXpath("//td[contains(text(),'Sample text for field help - label top')]", "passes locally");
101    //        }
102    
103            if (isElementPresentByXpath("//td[contains(text(),'Sample text for standalone help widget tooltip which will never be rendered')]")) {
104                waitNotVisibleByXpath("//td[contains(text(),'Sample text for standalone help widget tooltip which will never be rendered')]");
105            }
106    
107            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')]")) {
108                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')]");
109            }
110    
111            if (isElementPresentByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]")) {
112                waitNotVisibleByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]");
113            }
114    
115            if (isElementPresentByXpath("//td[contains(text(),'Sample text for field help - there is also an on-focus tooltip')]")) {
116                waitNotVisibleByXpath("//td[contains(text(),'Sample text for field help - there is also an on-focus tooltip')]");
117            }
118    
119            if (isElementPresentByXpath("//td[contains(text(),'Sample text for on-focus event tooltip')]")) {
120                waitNotVisibleByXpath("//td[contains(text(),'Sample text for on-focus event tooltip')]");
121            }
122    
123            if (isElementPresentByXpath("//td[contains(text(),'Sample text for check box help')]")) {
124                waitNotVisibleByXpath("//td[contains(text(),'Sample text for check box help')]");
125            }
126    
127            // test tooltip help of section header
128            fireMouseOverEventByXpath("//section[@id='ConfigurationTestView-Help-Section1']/header/h3[@class='uif-headerText']");
129            waitIsVisible(By.xpath("//td[contains(text(),'Sample text for section help - tooltip help')]"));
130    
131            // verify that no external help exist
132            assertFalse(isElementPresent("#ConfigurationTestView-Help-Section1 input.uif-helpImage"));
133    
134            // test tooltip help of field with label to the left
135            fireMouseOverEventByXpath("//label[@id='field-label-left_label']");
136            waitIsVisible(By.xpath("//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            waitIsVisible(By.xpath("//td[contains(text(),'Sample text for field help - label right')]"));
141    
142            // test tooltip help of field with label to the top
143            fireMouseOverEventByXpath("//label[@id='field-label-top_label']");
144            waitIsVisible(By.xpath("//td[contains(text(),'Sample text for field help - label top')]"));
145    
146            // verify that standalone help with tooltip is not rendered
147            assertFalse(isElementPresentByXpath("//*[@id='standalone-help-not-rendered']"));
148    
149            // test tooltip help when it overrides a tooltip
150            fireMouseOverEventByXpath("//label[@id='override-tooltip_label']");
151            waitIsVisible(By.xpath("//td[contains(text(),'Sample text for field help - there is also a tooltip on the label but it is overridden by the help tooltip')]"));
152            if (isElementPresentByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]")) {
153                waitNotVisibleByXpath("//td[contains(text(),'Sample text for label tooltip - this will not be rendered as it is overridden by the help tooltip')]");
154            }
155    
156            // test tooltip help in conjunction with a focus event tooltip
157            fireMouseOverEventByXpath("//input[@id='on-focus-tooltip_control']");
158            waitIsVisible(By.xpath("//td[contains(text(),'Sample text for on-focus event tooltip')]"));
159            fireMouseOverEventByXpath("//label[@id='on-focus-tooltip_label']");
160            waitIsVisible(By.xpath("//td[contains(text(),'Sample text for field help - there is also an on-focus tooltip')]"));
161    
162            // test tooltip help against a check box - help contains html
163            fireMouseOverEventByXpath("//label[@id='checkbox_label']");
164            waitIsVisible(By.xpath("//td[contains(text(),'Sample text for check box help')]"));
165        }
166    
167        /**
168         * Test the tooltip help on the sub-section and fields that are display only
169         */
170        protected void testDisplayOnlyTooltipHelp() throws Exception {
171    
172            // test tooltip help of sub-section header
173            fireMouseOverEventByXpath("//section[@data-parent='ConfigurationTestView-Help-Section1']/header/h4");
174            waitForElementPresentByXpath("//td[contains(text(),'Sample text for sub-section help')]");
175    
176            // test tooltip help of display only data field
177            fireMouseOverEventByXpath("//label[@for='display-field_control']");
178            waitForElementPresentByXpath("//td[contains(text(),'Sample text for read only field help')]");
179        }
180    
181        /**
182         * Test the tooltip help on the section and fields with no content
183         */
184        protected void testMissingTooltipHelp() throws Exception {
185    
186            // test tooltip help of section header
187            fireMouseOverEventByXpath("//section[@id='ConfigurationTestView-Help-Section2']/div");
188            assertFalse(isElementPresentByXpath("//div[@class='jquerybubblepopup jquerybubblepopup-black' and @style='opacity: 0; top: 627px; left: 2px; position: absolute; display: block;']"));
189    
190            // test tooltip help of field
191            fireMouseOverEventByXpath("//label[@id='missing-tooltip-help_label']");
192            assertFalse(isElementPresentByXpath("//div[@class='jquerybubblepopup jquerybubblepopup-black' and @style='opacity: 0; top: 627px; left: 2px; position: absolute; display: block;']"));
193        }
194    
195        /**
196         * Test the tooltip and external help on the view
197         */
198        protected void testViewHelp() throws Exception {
199            // test tooltip help
200            fireEvent("field102", "blur");
201            fireMouseOverEventByXpath("//label[@id='field-label-left_label']");
202            waitForTextPresent("Sample text for field help - label left");
203    
204            // test external help
205            waitAndClickByXpath("//input[@alt='Help for Configuration Test View']");
206            Thread.sleep(5000);
207            switchToWindow("Kuali Foundation");
208            Thread.sleep(5000);
209            switchToWindow(CONFIGURATION_VIEW_WINDOW_TITLE);
210        }
211    }