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.configview;
018
019 import edu.samplu.common.UpgradedSeleniumITBase;
020 import org.junit.Assert;
021 import org.junit.Test;
022
023 /**
024 * Selenium test that tests collections
025 *
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 */
028 public class CollectionsIT extends UpgradedSeleniumITBase {
029
030 @Override
031 public String getTestUrl() {
032 return "/kr-krad/uicomponents?viewId=ConfigurationTestView-Collections&methodToCall=start";
033 }
034
035 /**
036 * Test adding a column of values to the Default Tests Table Layout
037 */
038 @Test
039 public void testDefaultTestsTableLayout() {
040 Assert.assertTrue(selenium.isTextPresent("Default Tests"));
041 Assert.assertTrue(selenium.isTextPresent("Table Layout"));
042 Assert.assertTrue(selenium.isTextPresent("* Field 1"));
043 Assert.assertTrue(selenium.isTextPresent("* Field 2"));
044 Assert.assertTrue(selenium.isTextPresent("* Field 3"));
045 Assert.assertTrue(selenium.isTextPresent("* Field 4"));
046 Assert.assertTrue(selenium.isTextPresent("Actions"));
047
048 selenium.type("name=newCollectionLines['list1'].field1", "asdf1");
049 selenium.type("name=newCollectionLines['list1'].field2", "asdf2");
050 selenium.type("name=newCollectionLines['list1'].field3", "asdf3");
051 selenium.type("name=newCollectionLines['list1'].field4", "asdf4");
052 selenium.click("//button[contains(.,'add')]"); // the first button is the one we want
053 selenium.waitForCondition("selenium.browserbot.getCurrentWindow().document.getElementsByName(\"newCollectionLines['list1'].field1\")[0].value == ''", "3000");
054
055 Assert.assertEquals("", selenium.getValue("name=newCollectionLines['list1'].field1"));
056 Assert.assertEquals("", selenium.getValue("name=newCollectionLines['list1'].field2"));
057 Assert.assertEquals("", selenium.getValue("name=newCollectionLines['list1'].field3"));
058 Assert.assertEquals("", selenium.getValue("name=newCollectionLines['list1'].field4"));
059 Assert.assertEquals("asdf1", selenium.getValue("name=list1[0].field1"));
060 Assert.assertEquals("asdf2", selenium.getValue("name=list1[0].field2"));
061 Assert.assertEquals("asdf3", selenium.getValue("name=list1[0].field3"));
062 Assert.assertEquals("asdf4", selenium.getValue("name=list1[0].field4"));
063
064 // how to figure out which delete button for the one we just added?
065 }
066
067 /**
068 * Test action column placement in table layout collections
069 */
070 @Test
071 public void testActionColumnPlacement() throws Exception {
072 // check if actions column RIGHT by default
073 Assert.assertTrue(selenium.isElementPresent("//div[@id='ConfigurationTestView-collection1']//tr[2]/td[6]//button[contains(.,\"delete\")]"));
074 // check if actions column is LEFT
075 Assert.assertTrue(selenium.isElementPresent("//div[@id='ConfigurationTestView-collection2']//tr[2]/td[1]//button[contains(.,\"delete\")]"));
076 // check if actions column is 3rd in a sub collection
077 Assert.assertTrue(selenium.isElementPresent("//div[@id='ConfigurationTestView-subCollection2_line0']//tr[2]/td[3]//button[contains(.,\"delete\")]"));
078 }
079 }