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 junit.framework.Assert; 022 import org.junit.Test; 023 024 /** 025 * @author Kuali Rice Team (rice.collab@kuali.org) 026 */ 027 public class ServerInfoIT extends UpgradedSeleniumITBase { 028 @Override 029 public String getTestUrl() { 030 return "/kr-krad/uicomponents?viewId=Demo-ValidationLayout&methodToCall=start"; 031 } 032 033 @Test 034 public void testServerInfoIT() throws Exception { 035 waitAndClick("//button[contains(.,'Get Info Messages')]"); 036 waitIsVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]"); 037 Assert.assertTrue(isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"]")); 038 Assert.assertTrue(isElementPresent("css=div[data-messagesfor=\"Demo-ValidationLayout-SectionsPage\"] .uif-infoMessageItem")); 039 Assert.assertTrue(isVisible("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"]")); 040 Assert.assertTrue(isElementPresent("css=div[data-messagesfor=\"Demo-ValidationLayout-Section1\"] .uif-infoMessageItem")); 041 Assert.assertTrue(isElementPresent("css=div[data-role=\"InputField\"] img[alt=\"Information\"]")); 042 mouseOver("//a[contains(.,'Field 1')]"); 043 Assert.assertTrue(isElementPresent("css=.uif-infoHighlight")); 044 waitAndClick("//a[contains(.,'Field 1')]"); 045 for (int second = 0;; second++) { 046 if (second >= 60) Assert.fail("timeout"); 047 try { if (isVisible("css=.jquerybubblepopup-innerHtml")) break; } catch (Exception e) {} 048 Thread.sleep(1000); 049 } 050 051 Assert.assertTrue(isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems")); 052 Assert.assertTrue(isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field")); 053 waitAndType("name=field1", ""); 054 fireEvent("name=field1", "blur"); 055 fireEvent("name=field1", "focus"); 056 for (int second = 0;; second++) { 057 if (second >= 60) Assert.fail("timeout"); 058 try { if (isVisible("css=.jquerybubblepopup-innerHtml")) break; } catch (Exception e) {} 059 Thread.sleep(1000); 060 } 061 062 Assert.assertTrue(isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field")); 063 for (int second = 0;; second++) { 064 if (second >= 60) Assert.fail("timeout"); 065 try { if (isVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems")) break; } catch (Exception e) {} 066 Thread.sleep(1000); 067 } 068 069 Assert.assertTrue(isVisible("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems .uif-errorMessageItem-field")); 070 waitAndType("name=field1", "b"); 071 fireEvent("name=field1", "blur"); 072 fireEvent("name=field1", "focus"); 073 for (int second = 0;; second++) { 074 if (second >= 60) Assert.fail("timeout"); 075 try { if (!isElementPresent("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems")) break; } catch (Exception e) {} 076 Thread.sleep(1000); 077 } 078 fireEvent("name=field1", "blur"); 079 080 Assert.assertTrue(!isVisible("css=.jquerybubblepopup-innerHtml > .uif-serverMessageItems .uif-infoMessageItem-field")); 081 Assert.assertFalse(isElementPresent("css=.jquerybubblepopup-innerHtml > .uif-clientMessageItems")); 082 waitAndType("name=field1", ""); 083 fireEvent("name=field1", "focus"); 084 fireEvent("name=field1", "blur"); 085 Assert.assertTrue(isElementPresent("css=.uif-hasError")); 086 Assert.assertTrue(isElementPresent("css=img[src*=\"error.png\"]")); 087 } 088 }