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