001/**
002 * Copyright 2005-2015 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 */
016package edu.sampleu.krad.screenelement;
017
018import org.junit.Test;
019import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
020
021/**
022 * Tests the Component section in Rice.
023 *
024 * @author Kuali Rice Team (rice.collab@kuali.org)
025 */
026public class CollectionTotallingAft extends WebDriverLegacyITBase {
027
028    /**
029     * "/kr-krad/uicomponents?viewId=UifCompView&methodToCall=start&readOnlyFields=field91";
030     */
031    public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=Demo-CollectionTotaling&methodToCall=start";
032
033    @Override
034    protected String getBookmarkUrl() {
035        return BOOKMARK_URL;
036    }
037
038    protected void navigate() throws InterruptedException {
039        waitAndClickKRAD();
040        waitAndClickByXpath(KUALI_COLLECTION_TOTALLING_XPATH);
041        switchToWindow(KUALI_COLLECTION_TOTALLING_WINDOW_XPATH);               
042    }
043
044    //Code for KRAD Test Package.
045    protected void testCollectionTotalling() throws Exception {
046        //Scenario Asserts Changes in Total at client side
047        Integer preValue=Integer.parseInt(getTextByXpath("//section[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/p"));
048        clearTextByXpath("//section[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tbody/tr[2]/td[2]/div/input[@name='list1[0].field1']");
049        waitAndTypeByXpath("//section[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tbody/tr[2]/td[2]/div/input[@name='list1[0].field1']","0");
050        waitAndClickByXpath("//section[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/p");
051        Integer postValue=Integer.parseInt(getTextByXpath("//section[@id='Demo-CollectionTotaling-Section1']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/p"));
052        Thread.sleep(2000);
053        if(postValue>preValue) {
054            jiraAwareFail("Totalling not working !");
055        }        
056        
057        //Scenario Asserts Changes in Total at client side on keyUp
058        Integer preValueClient=Integer.parseInt(getTextByXpath("//section[@id='Demo-CollectionTotaling-Section2']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/p"));
059        clearTextByXpath("//section[@id='Demo-CollectionTotaling-Section2']/div[@role='grid']/table/tbody/tr[2]/td[2]/div/input[@name='list1[0].field1']");
060        waitAndTypeByXpath("//section[@id='Demo-CollectionTotaling-Section2']/div[@role='grid']/table/tbody/tr[2]/td[2]/div/input[@name='list1[0].field1']","0");
061        Integer postValueClient=Integer.parseInt(getTextByXpath("//section[@id='Demo-CollectionTotaling-Section2']/div[@role='grid']/table/tfoot/tr/th[2]/div/fieldset/div/div/p"));
062        Thread.sleep(2000);        
063        if(postValueClient>preValueClient) {
064            jiraAwareFail("Totalling not working !");
065        }  
066        
067        //Totalling Flexibility
068        assertElementPresentByXpath("//section[@id='Demo-CollectionTotaling-Section3']/div[@role='grid']/table/tfoot/tr/th[3]/div/fieldset/div/div/p");
069
070        //Left Total Labels
071        assertElementPresentByXpath("//section[@id='Demo-CollectionTotaling-Section4']/div[@role='grid']/table/tfoot/tr/th/div/label");
072        
073        //Multiple Calculations
074        assertEquals("Page Total:",getTextByXpath("//section[@id='Demo-CollectionTotaling-Section6']/div[@role='grid']/table/tfoot/tr/th[5]/div/div/fieldset/div/div/label"));
075        assertEquals("Page Average:",getTextByXpath("//section[@id='Demo-CollectionTotaling-Section6']/div[@role='grid']/table/tfoot/tr/th[5]/div/div[2]/fieldset/div/div/label"));
076        assertEquals("Page Min:",getTextByXpath("//section[@id='Demo-CollectionTotaling-Section6']/div[@role='grid']/table/tfoot/tr/th[5]/div/div[3]/fieldset/div/div/label"));
077        assertEquals("Page Max:",getTextByXpath("//section[@id='Demo-CollectionTotaling-Section6']/div[@role='grid']/table/tfoot/tr/th[5]/div/div[4]/fieldset/div/div/label"));
078        
079        //Group Totaling
080        assertEquals("Group Total:",getTextByXpath("//section[@id='Demo-CollectionTotaling-Section7']/div[@role='grid']/table/tbody/tr[7]/td/div/label"));
081    }
082
083    @Test
084    public void testCollectionTotallingBookmark() throws Exception {
085        testCollectionTotalling();
086        passed();
087    }
088
089    @Test
090    public void testCollectionTotallingNav() throws Exception {
091        testCollectionTotalling();
092        passed();
093    }
094}