View Javadoc
1   /**
2    * Copyright 2005-2015 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.labs.kitchensink;
17  
18  import org.junit.Test;
19  
20  /**
21   * @author Kuali Rice Team (rice.collab@kuali.org)
22   */
23  
24  public class LabsProgressiveDisclosureAft extends LabsKitchenSinkBase {
25  
26      /**
27       * /kr-krad/uicomponents?viewId=UifCompView&pageId=UifCompView-Page5#UifCompView-Page5
28       */
29      public static final String BOOKMARK_URL = "/kr-krad/uicomponents?viewId=UifCompView&pageId=UifCompView-Page5#UifCompView-Page5";
30  
31      @Override
32      protected String getBookmarkUrl() {
33          return BOOKMARK_URL;
34      }
35  
36  	@Override
37  	protected void navigate() throws Exception {
38  		navigateToKitchenSink("Progressive Disclosure");
39  	}
40  	
41  	@Test
42      public void testProgressiveDisclosureBookmark() throws Exception {
43          testProgressiveDisclosure();
44          passed();
45      }
46  
47      @Test
48      public void testProgressiveDisclosureNav() throws Exception {
49          testProgressiveDisclosure();
50          passed();
51      }
52      
53      protected void testProgressiveDisclosure() throws InterruptedException {
54      	//Progressive Disclosure of Fields
55      	if(isElementPresentByName("field35") && isElementPresentByName("field36")) {
56      		fail("Elements already present.");
57      	}
58      	waitAndClickByXpath("//input[@name='field34' and @value='show1']");
59      	waitForElementPresentByName("field35");
60      	waitAndClickByXpath("//input[@name='field34' and @value='show2']");
61      	waitForElementPresentByName("field36");
62      	waitAndClickByXpath("//input[@name='field34' and @value='show3']");
63      	waitForElementPresentByName("field37");
64  //    	assertElementPresentByXpath("//input[@name='field48' and @disabled]");
65  //    	assertElementPresentByXpath("//input[@name='field49' and @disabled]");
66      	waitAndTypeByName("field47","A");
67      	assertTextPresent("Cancel");
68      	waitForElementPresentByName("field48");
69      	waitAndTypeByName("field47","B");
70      	assertTextPresent("Cancel");
71      	waitForElementPresentByName("field49");
72      	
73      	//Progressive Disclosure of Groups
74      	if(isElementPresentByXpath("//div[@id='prog2-group1' and @style='display: block;']")
75             || isElementPresentByXpath("//div[@id='prog2-group2' and @style='display: block;']")) {
76      		fail("Groups already present.");
77      	}
78      	waitAndClickByXpath("//input[@name='field38' and @value='show1']");
79      	assertElementPresentByXpath("//div[@data-parent='prog2-group1']");
80      	waitAndClickByXpath("//input[@name='field38' and @value='show2']");
81      	assertElementPresentByXpath("//div[@data-parent='prog2-group2']");
82      	
83      	//Conditional Refresh
84      	waitAndTypeByName("field46","deepmoteria");
85      	waitAndClickByXpath("//input[@name='field44' and @value='show2']");
86      	waitForTextPresent("deepmoteria");
87      	selectByName("field88","Fruits");
88      	selectByName("field89","Apples");
89      	selectByName("field88","Vegetables");
90      	Thread.sleep(2000);
91      	selectByName("field89","Beans");
92      	
93      	//Collection Group With Refresh
94      	waitAndTypeByXpath("//div[@data-label='SubField 1']/input","show2");
95      	assertTextPresent("add");
96      	Thread.sleep(2000);
97      	assertElementPresentByXpath("//label[contains(text(),'SubField 2:')]");
98      }
99  }