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.validationmessagesview; 018 019 import edu.samplu.common.ITUtil; 020 import edu.samplu.common.UpgradedSeleniumITBase; 021 import org.junit.Test; 022 023 import static com.thoughtworks.selenium.SeleneseTestBase.assertTrue; 024 025 /** 026 * @author Kuali Rice Team (rice.collab@kuali.org) 027 */ 028 public class ServerWarningsIT extends UpgradedSeleniumITBase { 029 @Override 030 public String getTestUrl() { 031 return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start"; 032 } 033 034 @Test 035 public void testServerWarningsIT() throws Exception { 036 waitAndClick("//button[contains(.,'Get Warning Messages')]"); 037 waitForPageToLoad(); 038 assertTrue( "css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] not visible https://jira.kuali.org/browse/KULRICE-8140", 039 isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]")); 040 assertTrue("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-warningMessageItem not present", 041 isElementPresent("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-warningMessageItem")); 042 assertTrue("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] not visible", isVisible( 043 "css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]")); 044 assertTrue("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-warningMessageItem not present", 045 isElementPresent("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-warningMessageItem")); 046 assertTrue("css=div[data-role=\"InputField\"] img[alt=\"Warning\"] not present", isElementPresent( 047 "css=div[data-role=\"InputField\"] img[alt=\"Warning\"]")); 048 mouseOver("//a[contains(.,'Field 1')]"); 049 assertTrue("css=.uif-warningHighlight no present when //a[contains(.,'Field 1')] is moused over", 050 isElementPresent("css=.uif-warningHighlight")); 051 waitAndClick("//a[contains(.,'Field 1')]"); 052 waitForElementVisible("css=.jquerybubblepopup-innerHtml", " after click on //a[contains(.,'Field 1')]"); 053 054 assertTrue("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems not visible", isVisible( 055 "css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems")); 056 assertTrue("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible", 057 isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field")); 058 typeBlurFocus("name=field1", ""); 059 fireEvent("name=field1","hover"); 060 waitForElementVisible("css=.jquerybubblepopup-innerHtml", " not visible after typing nothing in name=field1 then firing blur and focus events"); 061 062 assertTrue("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible after typing nothing in name=field1 then firing blur and focus events", 063 isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field")); 064 065 waitForElementVisible("css=.jquerybubblepopup-innerHtml> .uif-clientMessageItems", " not visible after typing nothing in name=field1 then firing blur and focus events"); 066 067 assertTrue("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field not visible after typing nothing in name=field1 then firing blur and focus events", 068 isVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field")); 069 070 typeBlurFocus("name=field1", "b"); 071 fireEvent("name=field1","hover"); 072 waitForElementVisible("css=.jquerybubblepopup-innerHtml> .uif-serverMessageItems", " not visible after typing b in name=field1 then firing blur and focus events https://jira.kuali.org/browse/KULRICE-8140 Investigate Server Warnings"); 073 074 assertTrue("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field not visible after typing b in name=field1 then firing blur and focus events", 075 isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-warningMessageItem-field")); 076 assertTrue("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems", !isElementPresent( 077 "css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems")); 078 079 waitAndType("name=field1", ""); 080 fireEvent("name=field1", "focus"); 081 fireEvent("name=field1", "blur"); 082 fireEvent("name=field1","hover"); 083 assertTrue("css=.uif-hasError is not present after typing nothing in name=field1 and then firing focus and blur events", 084 isElementPresent("css=.uif-hasError")); 085 assertTrue( "css=img[src*=\"error.png\"] is not present after typing nothing in name=field1 and then firing focus and blur events", 086 isElementPresent("css=img[src*=\"error.png\"]")); 087 } 088 089 private void typeBlurFocus(String name, String text) throws InterruptedException{ 090 waitAndType(name, text); 091 fireEvent(name, "blur"); 092 fireEvent(name, "focus"); 093 } 094 }