001/**
002 * Copyright 2005-2016 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 org.kuali.rice.krad.demo.uif.library.elements;
017
018import org.junit.Test;
019
020import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
021
022/**
023 * @author Kuali Rice Team (rice.collab@kuali.org)
024 */
025public class LibraryElementsDropdownMenuAft extends WebDriverLegacyITBase {
026
027    /**
028     * /kr-krad/kradsampleapp?viewId=Demo-DropdownMenu-View
029     */
030    public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-DropdownMenu-View";
031 
032    @Override
033    protected String getBookmarkUrl() {
034        return BOOKMARK_URL;
035    }
036
037    @Override
038    protected void navigate() throws Exception {
039        waitAndClickLibraryLink();
040        waitAndClickByLinkText("Elements");
041        waitAndClickByLinkText("Dropdown Menu");
042    }
043
044    protected void testLibraryElementsDropdownBasic() throws Exception {
045        waitAndClickByLinkText("Basic Dropdown");
046        waitAndClickByLinkText("User thclark");
047        assertElementPresentByXpath("//a[contains(text(),'Preferences')]");
048        assertElementPresentByXpath("//a[contains(text(),'Logout')]");
049    }
050    
051    protected void testLibraryElementsDropdownWithDivider() throws Exception {
052        waitAndClickByLinkText("Dropdown with Divider");
053        waitAndClickByLinkText("Action List");
054        assertElementPresentByXpath("//a[contains(text(),'Proposal #1034')]");
055        assertElementPresentByXpath("//a[contains(text(),'Proposal #1035')]");
056        assertElementPresentByXpath("//a[contains(text(),'Proposal #1036')]");
057        assertElementPresentByXpath("//a[contains(text(),'Proposal #1037')]");
058        assertElementPresentByXpath("//a[contains(text(),'Full Action List')]");
059        assertElementPresentByXpath("//li[@class='divider']");
060    }
061    
062    protected void testLibraryElementsDropdownWithHeader() throws Exception {
063        waitAndClickByLinkText("Dropdown with Headers");
064        waitAndClickByLinkText("Favorites");
065        assertElementPresentByXpath("//a[contains(text(),'Proposal')]");
066        assertElementPresentByXpath("//a[contains(text(),'Budget')]");
067        assertElementPresentByXpath("//a[contains(text(),'Yearly Budget')]");
068        assertElementPresentByXpath("//li[@class='dropdown-header']");
069    }
070    
071    protected void testLibraryElementsDropdownWithDisabled() throws Exception {
072        waitAndClickByLinkText("Dropdown with Disabled");
073        waitAndClickByXpath("//a[contains(text(),'Select Action')]");
074        assertElementPresentByXpath("//a[contains(text(),'Approve') and @class='uif-actionLink']");
075        assertElementPresentByXpath("//a[contains(text(),'Disapprove') and @class='uif-actionLink disabled']");
076        assertElementPresentByXpath("//a[contains(text(),'Approve')]");
077    }
078    
079    protected void testLibraryElementsDropdownWithActionOptions() throws Exception {
080        waitAndClickByLinkText("Dropdown with Action Options");
081        waitAndClickByXpath("//a[contains(text(),'Select Action Options')]");
082        assertElementPresentByXpath("//a[contains(text(),'Refresh Section')]");
083        assertElementPresentByXpath("//a[contains(text(),'Action Script')]");
084        assertElementPresentByXpath("//a[contains(text(),'Pre-Submit Script')]");
085    }
086    
087    protected void testLibraryElementsDropdownWithToggleButton() throws Exception {
088        waitAndClickByLinkText("Dropdown with Toggle Button");
089        waitAndClickByXpath("//section[@id='Demo-DropdownMenu-Example6']/div/a/span[@class='caret']");
090        assertElementPresentByXpath("//a[contains(text(),'Preferences')]");
091        assertElementPresentByXpath("//a[contains(text(),'Logout')]");
092    }
093    
094    protected void testLibraryElementsDropdownWithTable() throws Exception {
095        waitAndClickByLinkText("Dropdown with Table");
096        waitAndClickByLinkText("more...");
097        assertTextPresent(new String[] {"Doc Nbr:","Initiator:","Status:","PI:","Created:","Updated:","Proposal Nbr:","Sponsor Name:"});
098        assertTextPresent(new String[] {"2743","thrclark","In Progress","Ken Graves","04:27pm 07/09/2013","12:22pm 07/12/2013","#23533","NIH"});
099    }
100
101    private void testAllDropdowns() throws Exception {
102        testLibraryElementsDropdownBasic();
103        testLibraryElementsDropdownWithDivider();
104        testLibraryElementsDropdownWithHeader();
105        testLibraryElementsDropdownWithDisabled();
106        testLibraryElementsDropdownWithActionOptions();
107        testLibraryElementsDropdownWithToggleButton();
108        testLibraryElementsDropdownWithTable();
109    }
110
111    @Test
112    public void testLibraryElementsDropdownBookmark() throws Exception {
113        testAllDropdowns();
114        passed();
115    }
116
117    @Test
118    public void testLibraryElementsDropdownNav() throws Exception {
119        testAllDropdowns();
120        passed();
121    }  
122}