View Javadoc

1   /**
2    * Copyright 2005-2013 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/ecl2.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 com.thoughtworks.selenium.SeleneseTestBase;
19  import org.kuali.rice.testtools.selenium.SmokeTestBase;
20  import org.junit.Test;
21  
22  /**
23   * Tests the Component section in Rice.
24   *
25   * @author Kuali Rice Team (rice.collab@kuali.org)
26   */
27  public class CollectionTotallingSmokeTest extends SmokeTestBase {
28  
29      /**
30       * "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&readOnlyFields=field91";
31       */
32      public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=Demo-CollectionTotaling&methodToCall=start";
33  
34      @Override
35      protected String getBookmarkUrl() {
36          return BOOKMARK_URL;
37      }
38  
39      protected void navigate() throws InterruptedException {
40          waitAndClickKRAD();
41          waitAndClickByXpath(KUALI_COLLECTION_TOTALLING_XPATH);
42          switchToWindow(KUALI_COLLECTION_TOTALLING_WINDOW_XPATH);               
43      }
44  
45      //Code for KRAD Test Package.
46      protected void testCollectionTotalling() throws Exception {
47          //Scenario Asserts Changes in Total at client side
48          waitForElementPresent("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']");
49          SeleneseTestBase.assertEquals("Total: 419", getText(
50                  "div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']"));
51          clearText("div#Demo-CollectionTotaling-Section1 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section1]  input[name='list1[0].field1']");
52          waitAndType("div#Demo-CollectionTotaling-Section1 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section1]  input[name='list1[0].field1']","10");
53          waitAndClick("div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']");
54          Thread.sleep(5000);
55          SeleneseTestBase.assertEquals("Total: 424", getText(
56                  "div#Demo-CollectionTotaling-Section1 div[role='grid'] div[data-label='Total']"));
57  
58          //Scenario Asserts Changes in Total at client side on keyUp
59          SeleneseTestBase.assertEquals("Total: 419", getText(
60                  "div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']"));
61          clearText("div#Demo-CollectionTotaling-Section2 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section2] input[name='list1[0].field1']");
62          waitAndType("div#Demo-CollectionTotaling-Section2 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section2] input[name='list1[0].field1']","9");
63          waitAndClick("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']");
64          Thread.sleep(5000);
65          SeleneseTestBase.assertEquals("Total: 423", getText(
66                  "div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']"));
67  
68          //Asserts absence of Total in 2nd column at the footer for Demonstrating totaling on only some columns
69          SeleneseTestBase.assertEquals("", getTextByXpath("//div[3]/div[3]/table/tfoot/tr/th[2]"));
70  
71          //Asserts Presence of Total in 2nd column at the footer for Demonstrating totaling on only some columns
72          SeleneseTestBase.assertEquals("Total: 369", getTextByXpath(
73                  "//div[3]/div[3]/table/tfoot/tr/th[3]/div/fieldset/div/div[2]/div[2]"));
74  
75          //Asserts Presence of Total in left most column only being one with no totaling itself
76          SeleneseTestBase.assertEquals("Total:", getTextByXpath("//*[@id='u100213_span']"));
77          SeleneseTestBase.assertEquals("419", getTextByXpath(
78                  "//div[4]/div[3]/table/tfoot/tr/th[2]/div/fieldset/div/div[2]/div[2]"));
79  
80          //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)
81          SeleneseTestBase.assertEquals("Total: 382", getTextByXpath("//div[2]/div/fieldset/div/div[2]/div[2]"));
82          clearText("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']");
83          waitAndType("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']","11");
84          waitAndClick("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']");
85          Thread.sleep(5000);
86          SeleneseTestBase.assertEquals("Total: 385", getTextByXpath("//div[2]/div/fieldset/div/div[2]/div[2]"));
87  
88          // Assert changes in Decimal..
89          clearText("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']");
90          waitAndType("div#Demo-CollectionTotaling-Section6 > div[role='grid'] > table > tbody div[data-parent=Demo-CollectionTotaling-Section6] input[name='list1[0].field4']","15.25");
91          waitAndClick("div#Demo-CollectionTotaling-Section2 div[role='grid'] div[data-label='Total']");
92          Thread.sleep(5000);
93          SeleneseTestBase.assertEquals("Page Average: 11.917", getTextByXpath("//div[2]/fieldset/div/div[2]/div"));
94      }
95  
96      @Test
97      public void testCollectionTotallingBookmark() throws Exception {
98          testCollectionTotalling();
99          passed();
100     }
101 
102     @Test
103     public void testCollectionTotallingNav() throws Exception {
104         testCollectionTotalling();
105         passed();
106     }
107 }