001 /* 002 * Copyright 2011 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/ecl1.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 package edu.samplu.travel.krad.test; 017 018 import static org.junit.Assert.*; 019 020 import org.junit.Test; 021 import edu.samplu.common.WebDriverLegacyITBase; 022 023 /** 024 * Test verifies updates in Totals at client side. 025 * 026 * @author Kuali Rice Team (rice.collab@kuali.org) 027 */ 028 public class CollectionTotallingLegacyIT extends WebDriverLegacyITBase { 029 030 /** 031 * This overridden method ... 032 * 033 * @see edu.samplu.common.UpgradedSeleniumITBase#getTestUrl() 034 */ 035 @Override 036 public String getTestUrl() { 037 //Returns "Group Totalling" url 038 return "/kr-krad/uicomponents?viewId=Demo-CollectionTotaling&methodToCall=start"; 039 } 040 041 @Test 042 public void testCollectionTotalling() throws InterruptedException { 043 044 //Scenario Asserts Changes in Total at client side 045 assertEquals("Total: 419", getText("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']")); 046 047 clearText("div#Demo-CollectionTotaling-Section1 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section1] input[name='list1[0].field1']"); 048 waitAndType("div#Demo-CollectionTotaling-Section1 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section1] input[name='list1[0].field1']","10"); 049 waitAndClick("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']"); 050 051 Thread.sleep(5000); 052 assertEquals("Total: 424", getText("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']")); 053 054 055 //Scenario Asserts Changes in Total at client side on keyUp 056 assertEquals("Total: 419", getText("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']")); 057 clearText("div#Demo-CollectionTotaling-Section2 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section2] input[name='list1[0].field1']"); 058 waitAndType("div#Demo-CollectionTotaling-Section2 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section2] input[name='list1[0].field1']","9"); 059 waitAndClick("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']"); 060 061 Thread.sleep(5000); 062 assertEquals("Total: 423", getText("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']")); 063 064 065 //Asserts absence of Total in 2nd column at the footer for Demonstrating totaling on only some columns 066 assertEquals("", getTextByXpath("//div[3]/div[3]/table/tfoot/tr/th[2]")); 067 //Asserts Presence of Total in 2nd column at the footer for Demonstrating totaling on only some columns 068 assertEquals("Total: 369", getTextByXpath("//div[3]/div[3]/table/tfoot/tr/th[3]/div/fieldset/div/div[2]/div[2]")); 069 070 071 //Asserts Presence of Total in left most column only being one with no totaling itself 072 assertEquals("Total:", getTextByXpath("//*[@id='u100213_span']")); 073 assertEquals("419", getTextByXpath("//div[4]/div[3]/table/tfoot/tr/th[2]/div/fieldset/div/div[2]/div[2]")); 074 075 //Asserts changes in value in Total and Decimal for Demonstrating multiple types of calculations for a single column (also setting average to 3 decimal places to demonstrate passing data to calculation function) 076 assertEquals("Total: 382", getTextByXpath("//div[2]/div/fieldset/div/div[2]/div[2]")); 077 clearText("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']"); 078 waitAndType("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']","11"); 079 waitAndClick("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']"); 080 081 Thread.sleep(5000); 082 assertEquals("Total: 385", getTextByXpath("//div[2]/div/fieldset/div/div[2]/div[2]")); 083 084 // Assert changes in Decimal.. 085 clearText("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']"); 086 waitAndType("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']","15.25"); 087 waitAndClick("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']"); 088 089 Thread.sleep(5000); 090 assertEquals("Page Average: 11.917", getTextByXpath("//div[2]/fieldset/div/div[2]/div")); 091 092 } 093 094 }