001    /**
002     * Copyright 2005-2013 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    package edu.samplu.krad.library.collections;
017    
018    import org.kuali.rice.testtools.selenium.SmokeTestBase;
019    import org.junit.Test;
020    import org.openqa.selenium.By;
021    
022    /**
023     * @author Kuali Rice Team (rice.collab@kuali.org)
024     */
025    public class DemoLibraryCollectionFeaturesMultiValueLookupSmokeTest extends SmokeTestBase {
026    
027        /**
028         * /kr-krad/kradsampleapp?viewId=Demo-LightTable-View&methodToCall=start
029         */
030        public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-CollectionLookup-View&methodToCall=start";
031    
032        @Override
033        protected String getBookmarkUrl() {
034            return BOOKMARK_URL;
035        }
036    
037        @Override
038        protected void navigate() throws Exception {
039            waitAndClickById("Demo-LibraryLink", "");
040            waitAndClickByLinkText("Collection Features");
041            waitAndClickByLinkText("Multi-Value Lookup");
042        }
043    
044        protected void testMultiValueLookup() throws InterruptedException {
045            lightBoxLookupAddMultipleLines();
046    
047            waitAndClickButtonByText("Search");
048            assertButtonDisabledByText("return selected");
049    
050            waitAndClickByValue("IAT:Travel Account 1:a1");
051            assertButtonEnabledByText("return selected");
052    
053            waitAndClickByValue("IAT:Travel Account 1:a1");
054            assertButtonDisabledByText("return selected");
055    
056            waitAndClickButtonByText("return selected");
057            Thread.sleep(3000);
058            checkForIncidentReport();
059            assertTextPresent("a1"); // TODO better assertion once NullPointer is resolved
060        }
061    
062        private void lightBoxLookupAddMultipleLines() throws InterruptedException {
063            waitAndClickByLinkText("Lookup/Add Multiple Lines");
064    
065            driver.switchTo().frame(driver.findElement(By.cssSelector(".fancybox-iframe")));
066            selectTopFrame();
067            gotoIframeByXpath("//iframe[@class='fancybox-iframe']");
068        }
069    
070        @Test
071        public void testMultiValueLookupBookmark() throws InterruptedException {
072            testMultiValueLookup();
073            passed();
074        }
075    
076        @Test
077        public void testMultiValueLookupNav() throws InterruptedException {
078            testMultiValueLookup();
079            passed();
080        }
081    
082        @Test
083        public void testMultivalueLookUpSelectThisPageBookmark() throws Exception {
084            lightBoxLookupAddMultipleLines();
085            testMultiValueSelectAllThisPage();
086            passed();
087        }
088    
089        @Test
090        public void testMultivalueLookUpSelectThisPageNav() throws Exception {
091            lightBoxLookupAddMultipleLines();
092            testMultiValueSelectAllThisPage();
093            passed();
094        }
095    
096        @Test
097        public void testMultivalueLookUpSelectAllPagesBookmark() throws Exception {
098            lightBoxLookupAddMultipleLines();
099            testMultiValueSelectAllPages();
100            passed();
101        }
102    
103        @Test
104        public void testMultivalueLookUpSelectAllPagesNav() throws Exception {
105            lightBoxLookupAddMultipleLines();
106            testMultiValueSelectAllPages();
107            passed();
108        }
109    }