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