View Javadoc

1   /*
2    * Copyright 2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl1.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package edu.samplu.travel.krad.test;
17  
18  import static org.junit.Assert.*;
19  
20  import org.junit.Test;
21  import edu.samplu.common.WebDriverLegacyITBase;
22  
23  /**
24   * Test verifies updates in Totals at client side.
25   * 
26   * @author Kuali Rice Team (rice.collab@kuali.org)
27   */
28  public class CollectionTotallingLegacyIT extends WebDriverLegacyITBase {
29      
30      /**
31       * This overridden method ...
32       * 
33       * @see edu.samplu.common.UpgradedSeleniumITBase#getTestUrl()
34       */
35      @Override
36      public String getTestUrl() {
37          //Returns "Group Totalling" url
38          return "/kr-krad/uicomponents?viewId=Demo-CollectionTotaling&methodToCall=start";
39      }
40  
41      @Test
42      public void testCollectionTotalling() throws InterruptedException {
43          
44          //Scenario Asserts Changes in Total at client side        
45          assertEquals("Total: 419", getText("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']"));
46        
47          clearText("div#Demo-CollectionTotaling-Section1 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section1]  input[name='list1[0].field1']");
48          waitAndType("div#Demo-CollectionTotaling-Section1 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section1]  input[name='list1[0].field1']","10");
49          waitAndClick("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']");
50  
51          Thread.sleep(5000);
52          assertEquals("Total: 424", getText("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']"));
53    
54                  
55          //Scenario Asserts Changes in Total at client side on keyUp
56          assertEquals("Total: 419", getText("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']"));
57          clearText("div#Demo-CollectionTotaling-Section2 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section2] input[name='list1[0].field1']");        
58          waitAndType("div#Demo-CollectionTotaling-Section2 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section2] input[name='list1[0].field1']","9");
59          waitAndClick("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']");
60          
61          Thread.sleep(5000);
62          assertEquals("Total: 423", getText("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']"));
63          
64          
65          //Asserts absence of Total in 2nd column at the footer for Demonstrating totaling on only some columns 
66          assertEquals("", getTextByXpath("//div[3]/div[3]/table/tfoot/tr/th[2]"));
67          //Asserts Presence of Total in 2nd column at the footer for Demonstrating totaling on only some columns 
68          assertEquals("Total: 369", getTextByXpath("//div[3]/div[3]/table/tfoot/tr/th[3]/div/fieldset/div/div[2]/div[2]"));
69        
70          
71          //Asserts Presence of Total in left most column only being one with no totaling itself 
72          assertEquals("Total:", getTextByXpath("//*[@id='u100213_span']"));
73          assertEquals("419", getTextByXpath("//div[4]/div[3]/table/tfoot/tr/th[2]/div/fieldset/div/div[2]/div[2]"));
74  
75          //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) 
76          assertEquals("Total: 382", getTextByXpath("//div[2]/div/fieldset/div/div[2]/div[2]"));
77          clearText("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']");
78          waitAndType("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']","11");
79          waitAndClick("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']");
80          
81          Thread.sleep(5000);
82          assertEquals("Total: 385", getTextByXpath("//div[2]/div/fieldset/div/div[2]/div[2]"));
83         
84         // Assert changes in Decimal..
85          clearText("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']");
86          waitAndType("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']","15.25");
87          waitAndClick("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']");
88        
89          Thread.sleep(5000);
90          assertEquals("Page Average: 11.917", getTextByXpath("//div[2]/fieldset/div/div[2]/div"));
91         
92      }  
93  
94  }