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.compview;
018    
019    import edu.samplu.common.WebDriverLegacyITBase;
020    
021    import org.junit.Test;
022    
023    import static org.junit.Assert.assertEquals;
024    import static org.junit.Assert.assertTrue;
025    import static org.junit.Assert.fail;
026    
027    /**
028     * tests that the parent line variable is available in a sub collection
029     *
030     * <p>configuration done in /edu/sampleu/demo/kitchensink/UifComponentsViewP7.xml on bean id="subCollection1"</p>
031     *
032     * @author Kuali Rice Team (rice.collab@kuali.org)
033     */
034    public class ParentLineLegacyIT extends WebDriverLegacyITBase {
035        @Override
036        public String getTestUrl() {
037            return "/kr-krad/uicomponents?methodToCall=start&readOnlyFields=field91&viewId=UifCompView_KNS#UifCompView-Page7";
038        }
039    
040        @Test
041        /**
042         * tests that the size of a sub collection is correctly displayed using the parentLine el variable
043         */
044        public void testSubCollectionSize() throws Exception {
045            checkForIncidentReport("link=Collections");
046    //        // click on collections page link
047            waitAndClickByLinkText("Collections");
048    //        // wait for collections page to load by checking the presence of a sub collection line item
049            for (int second = 0;; second++) {
050                if (second >= 30)
051                    fail("timeout");
052                try { 
053                    if(getText("div.uif-group.uif-collectionGroup.uif-tableCollectionGroup.uif-tableSubCollection.uif-disclosure span.uif-headerText-span").equals("SubCollection - (3 lines)"))
054                    {
055                        break;
056                    }
057                              
058                }
059                catch (Exception e) {}
060                Thread.sleep(1000);
061            }
062            // verify that sub collection sizes are displayed as expected
063            assertEquals("SubCollection - (3 lines)", getText("div.uif-group.uif-collectionGroup.uif-tableCollectionGroup.uif-tableSubCollection.uif-disclosure span.uif-headerText-span"));
064            assertEquals("SubCollection - (2 lines)", getTextByXpath("//a[@id='subCollection1_line1_toggle']/span"));
065            
066            
067        }
068    }