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 */
016package edu.samplu.krad.library.clientresponsiveness;
017
018import org.junit.Test;
019
020import edu.samplu.common.Failable;
021import edu.samplu.common.ITUtil;
022import edu.samplu.common.SmokeTestBase;
023import edu.samplu.common.WebDriverLegacyITBase;
024
025/**
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 */
028public class LibraryClientResponsivenessDisableSmokeTest extends SmokeTestBase {
029
030    /**
031     * /kr-krad/kradsampleapp?viewId=Demo-Disable-View&methodToCall=start
032     */
033    public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-Disable-View&methodToCall=start";
034   
035    @Override
036    protected String getBookmarkUrl() {
037        return BOOKMARK_URL;
038    }
039
040    @Override
041    protected void navigate() throws Exception {
042        waitAndClickById("Demo-LibraryLink", "");
043        waitAndClickByLinkText("Client Responsiveness");
044        waitAndClickByLinkText("Disable");
045    }
046
047    protected void testClientResponsivenessDisable() throws Exception {
048       //Scenario-1 - enabled
049       waitAndClickByXpath("//input[@type='radio' and @value='enable']");
050       waitAndTypeByName("inputField2","a");
051       waitAndTypeByName("inputField3","b");
052       selectByName("inputField4", "Option 2");
053       selectByName("multiSelectField1","Option 3");
054       waitAndClickByXpath("//input[@type='radio' and @value='1']");
055       waitAndClickByName("checkboxesField1");
056       
057       //Scenario-2 - disabled
058       waitAndClickByXpath("//input[@type='radio' and @value='disable']");
059       if(isEnabledByName("inputField2") && isEnabledByName("inputField3") && isEnabledByName("inputField4") && isEnabledByName("inputField6") &&
060               isEnabledByName("inputField7") && isEnabledByName("multiSelectField1"))
061       {
062           fail("Field Not Disabled Properly.");
063       }
064    }
065    
066    protected void testClientResponsivenessDisableOnChange() throws Exception {
067        selectByName("exampleShown","On change");
068        
069        //Scenario-1
070        assertElementPresentByXpath("//button[@class='btn btn-primary uif-primaryActionButton uif-boxLayoutHorizontalItem disabled']");
071        waitAndTypeByName("inputField10","a");
072        waitAndTypeByName("inputField11","a");
073        if(isElementPresentByXpath("//button[@class='btn btn-primary uif-primaryActionButton uif-boxLayoutHorizontalItem disabled']"))
074        {
075            fail("Constraint not working properly.");
076        }
077        waitAndTypeByName("inputField10", "");
078        assertElementPresentByXpath("//button[@class='btn btn-primary uif-primaryActionButton uif-boxLayoutHorizontalItem disabled']");
079      }
080    
081    protected void testClientResponsivenessDisableOnKeyUp() throws Exception {
082        selectByName("exampleShown","On keyup");
083        waitAndTypeByName("inputField13","disable");
084        assertElementPresentByXpath("//button[contains(text(),'Action Button (keyUp)') and @class='btn btn-primary uif-primaryActionButton uif-boxLayoutHorizontalItem disabled']");
085        waitAndClickByLinkText("Usage");
086        assertElementPresentByXpath("//button[contains(text(),'Action Button (change)') and @class='btn btn-primary uif-primaryActionButton uif-boxLayoutHorizontalItem disabled']");
087     }
088    
089    protected void testClientResponsivenessDisableInCollections() throws Exception {
090        selectByName("exampleShown","In Collections");
091        assertElementPresentByXpath("//input[@name='newCollectionLines['collection1'].field2' and @class='uif-textControl valid ignoreValid']");
092        selectByName("newCollectionLines['collection1'].field1","Disable");
093        assertElementPresentByXpath("//input[@name='newCollectionLines['collection1'].field2' and @class='uif-textControl ignoreValid disabled']");
094     }
095    
096    protected void testClientResponsivenessDisableColl() throws Exception {
097        selectByName("exampleShown","Coll. SpringEL Functions");
098        waitAndClickByXpath("//input[@name='checkboxesField2' and value='1']");
099        assertElementPresentByXpath("//input[@name='inputField20' and @class='uif-textControl disabled']");
100        waitAndClickByXpath("//input[@name='checkboxesField2' and value='2']");
101        waitAndClickByXpath("//input[@name='checkboxesField2' and value='3']");
102        assertElementPresentByXpath("//input[@name='inputField21' and @class='uif-textControl disabled']");
103     }
104    
105    @Test
106    public void testClientResponsivenessDisableBookmark() throws Exception {
107        testClientResponsivenessDisable();
108        testClientResponsivenessDisableOnChange();
109        testClientResponsivenessDisableOnKeyUp();
110        testClientResponsivenessDisableInCollections();
111        testClientResponsivenessDisableColl();
112        passed();
113    }
114
115    @Test
116    public void testClientResponsivenessDisableNav() throws Exception {
117        testClientResponsivenessDisable();
118        testClientResponsivenessDisableOnChange();
119        testClientResponsivenessDisableOnKeyUp();
120        testClientResponsivenessDisableInCollections();
121        testClientResponsivenessDisableColl();
122        
123        passed();
124    }  
125}