View Javadoc
1   /**
2    * Copyright 2005-2014 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.demo.uif.library.clientresponsiveness;
17  
18  import org.junit.Test;
19  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
20  
21  /**
22   * @author Kuali Rice Team (rice.collab@kuali.org)
23   */
24  public class DemoClientResponsivenessProgressiveDisclosureAft extends WebDriverLegacyITBase {
25  
26      /**
27       * /kr-krad/kradsampleapp?viewId=Demo-ProgressiveDisclosureView&methodToCall=start
28       */
29      public static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-ProgressiveDisclosureView&methodToCall=start";
30  
31      @Override
32      protected String getBookmarkUrl() {
33          return BOOKMARK_URL;
34      }
35      
36      /**
37       * //div[@data-parent='Demo-ProgressiveDisclosure-Example9']/div[@data-role='disclosureContent']
38       */
39      private static final String CWGR_GENERIC_XPATH= "//div[@data-parent='Demo-ProgressiveDisclosure-Example9']/div[@data-role='disclosureContent']";
40  
41      @Override
42      protected void navigate() throws Exception {
43          waitAndClickById("Demo-LibraryLink", "");
44          waitAndClickByLinkText("Client Responsiveness");
45          waitAndClickByLinkText("Progressive Disclosure");
46      }
47  
48      protected void testClientResponsivenessProgressiveDisclosure() throws Exception {
49           //Scenario-1
50          waitAndClickByLinkText("Default");
51          assertIsNotVisibleByXpath("//input[@name='inputField1']", "Is Visible");
52          waitAndClickByName("booleanField1");
53          waitIsVisibleByXpath("//input[@name='inputField1']","Not Visible");
54          waitAndClickByName("booleanField1");
55          assertIsNotVisibleByXpath("//input[@name='inputField1']", "Is Visible");
56          jiraAwareTypeByName("inputField2", "show");
57          waitForElementPresentByXpath("//input[@name='inputField3' and @disabled]");
58          waitAndClickByLinkText("Documentation");
59          waitForElementPresentByXpath("//input[@name='inputField3']");
60      }
61      
62      protected void testClientResponsivenessProgressiveDisclosureAjaxRetrieval() throws Exception {
63          waitAndClickByLinkText("Ajax Retrieval");
64          checkForIncidentReport("DemoClientResponsivenessProgressiveDisclosureAft Ajax Retrieval");
65          assertIsNotVisibleByXpath("//input[@name='inputField18']", "element");
66          waitAndClickByName("booleanField2");
67          waitIsVisibleByXpath("//input[@name='inputField18']", "element");
68      }
69      
70      protected void testClientResponsivenessProgressiveDisclosureRefreshWhenShown() throws Exception {
71          waitAndClickByLinkText("Refresh when Shown");
72          assertIsNotVisibleByXpath("//input[@name='inputField5']", "element");
73          waitAndClickByName("booleanField3");
74          waitIsVisibleByXpath("//input[@name='inputField5']", "element");
75      }
76      
77      protected void testClientResponsivenessProgressiveDisclosureShowFieldThroughMatching() throws Exception {
78      	waitAndClickByLinkText("Show Field Through Matching");
79  //    	assertElementPresentByXpath("//input[@name='inputField7' and @disabled]");
80  //    	assertElementPresentByXpath("//input[@name='inputField8' and @disabled]");
81      	waitAndTypeByName("inputField6","A");
82      	waitAndClickByLinkText("Documentation");
83      	waitForElementPresentByXpath("//input[@name='inputField7']");
84      	waitAndTypeByName("inputField6","B");
85      	waitAndClickByLinkText("Documentation");
86      	waitForElementPresentByXpath("//input[@name='inputField8']");
87      }
88      
89      protected void testClientResponsivenessProgressiveDisclosureOfGroup() throws Exception {
90      	waitAndClickByLinkText("Progressive Disclosure of Groups");
91      	waitForElementPresentByXpath("//input[@name='inputField10' and @disabled]");
92      	waitForElementPresentByXpath("//input[@name='inputField11' and @disabled]");
93      	waitForElementPresentByXpath("//input[@name='inputField12' and @disabled]");
94      	waitAndClickByXpath("//input[@name='inputField9' and @value='show1']");
95      	waitForElementPresentByXpath("//input[@name='inputField10']");
96      	waitForElementPresentByXpath("//input[@name='inputField11']");
97      	waitForElementPresentByXpath("//input[@name='inputField12']");
98      	waitAndClickByXpath("//input[@name='inputField9' and @value='show2']");
99      	waitForTextNotPresent("Loading...");
100     	waitForElementPresentByXpath("//input[@name='inputField13']");
101     	waitForElementPresentByXpath("//input[@name='inputField14']");
102     }
103     
104     protected void testClientResponsivenessProgressiveDisclosureConditionalRefresh() throws Exception {
105     	waitAndClickByXpath("//li[@data-tabfor='Demo-ProgressiveDisclosure-Example6']/a[contains(text(),'Conditional Refresh')]");
106     	waitAndClickByXpath("//input[@name='inputField15' and @value='show1']");
107     	waitForTextNotPresent("Loading...");
108     	waitAndTypeByName("inputField16","Hello World!");
109     	waitAndTypeByName("inputField17","Hello Deep!");
110     	waitAndClickByXpath("//input[@name='inputField15' and @value='show2']");
111         waitForTextNotPresent("Loading...");
112     	waitForTextPresent("Hello Deep!");
113     }
114     
115     protected void testClientResponsivenessProgressiveDisclosureConditionalOptions() throws Exception {
116     	waitAndClickByLinkText("Conditional Options");
117     	selectByName("inputField19","Apples");
118     	waitAndClickButtonByText("Refresh Group");
119         Thread.sleep(10000); // would be better to have a waitForTextNotPresent that takes seconds
120         waitForTextNotPresent("Loading...");
121     	selectByName("inputField4","Vegetables");
122     	// Test page gives exception after this step.
123         waitAndClickButtonByText("Refresh Field");
124         Thread.sleep(10000); // would be better to have a waitForTextNotPresent that takes seconds
125         waitForTextNotPresent("Loading...");
126         waitAndClickButtonByText("Refresh Field but with Server Errors");
127         waitForTextPresent("Field 1: Intended message with key: serverTestError not found.");
128         waitAndClickButtonByText("Refresh Page");
129         Thread.sleep(10000);
130         waitForTextNotPresent("Field 1: Intended message with key: serverTestError not found.");
131     }
132     
133     protected void testClientResponsivenessProgressiveDisclosureRefreshBasedOnTimer() throws Exception {
134     	waitAndClickByLinkText("Refresh Based on Timer");
135     	//There are no component to perform test on the page.
136         checkForIncidentReport();
137     }
138     
139     protected void testClientResponsivenessProgressiveDisclosureCollectionWithGroupRefresh() throws Exception {
140     	waitAndClickByLinkText("Collection Group With Refresh");
141         jiraAwareTypeByName("newCollectionLines['collection1'].field2", "ref");
142         fireEvent("focus", "collection1[0].field1");
143         waitForTextNotPresent("Loading...");
144     	//Test cannot be written ahead as there is a freemarker error in page
145         checkForIncidentReport();
146     }
147     
148     protected void testClientResponsivenessProgressiveDisclosureFieldWithCheckBoxFieldset() throws Exception {
149     	waitAndClickByLinkText("Field Within a Checkbox Field Set");
150     	waitForElementPresentByXpath("//input[@name='inputField21' and @disabled]");
151     	waitAndClickByXpath("//input[@name='checkboxesField1' and @value='1']");
152     	waitForElementPresentByXpath("//input[@name='inputField21']");
153         checkForIncidentReport();
154     }
155     
156     protected void testClientResponsivenessProgressiveDisclosureFieldWithRadioFieldset() throws Exception {
157     	waitAndClickByLinkText("Field Within a Radio Field Set");
158     	waitForElementPresentByXpath("//input[@name='inputField23' and @disabled]");
159     	waitAndClickByXpath("//input[@name='checkboxesField2' and @value='X']");
160     	waitForElementPresentByXpath("//input[@name='inputField23']");
161         checkForIncidentReport();
162     }
163     
164     @Test
165     public void testClientResponsivenessProgressiveDisclosureBookmark() throws Exception {
166     	testClientResponsivenessProgressiveDisclosureAll();
167         passed();
168     }
169 
170     @Test
171     public void testClientResponsivenessProgressiveDisclosureNav() throws Exception {
172     	testClientResponsivenessProgressiveDisclosureAll();
173         passed();
174     }
175 
176     @Test
177     public void testClientResponsivenessProgressiveDisclosureConditionalOptionsBookmark() throws Exception {
178         testClientResponsivenessProgressiveDisclosureConditionalOptions();
179         passed();
180     }
181 
182     @Test
183     public void testClientResponsivenessProgressiveDisclosureConditionalOptionsNav() throws Exception {
184         testClientResponsivenessProgressiveDisclosureConditionalOptions();
185         passed();
186     }
187 
188     @Test
189     public void testClientResponsivenessProgressiveDisclosureCollectionWithGroupRefreshBookmark() throws Exception {
190         testClientResponsivenessProgressiveDisclosureCollectionWithGroupRefresh();
191         passed();
192     }
193 
194     @Test
195     public void testClientResponsivenessProgressiveDisclosureCollectionWithGroupRefreshNav() throws Exception {
196         testClientResponsivenessProgressiveDisclosureCollectionWithGroupRefresh();
197         passed();
198     }
199 
200     @Test
201     public void testClientResponsivenessProgressiveDisclosureConditionalRefreshBookmark() throws Exception {
202         testClientResponsivenessProgressiveDisclosureConditionalRefresh();
203         passed();
204     }
205 
206     @Test
207     public void testClientResponsivenessProgressiveDisclosureConditionalRefreshNav() throws Exception {
208         testClientResponsivenessProgressiveDisclosureConditionalRefresh();
209         passed();
210     }
211 
212     private void testClientResponsivenessProgressiveDisclosureAll() throws Exception {
213         testClientResponsivenessProgressiveDisclosure();
214     	testClientResponsivenessProgressiveDisclosureAjaxRetrieval();
215         testClientResponsivenessProgressiveDisclosureRefreshWhenShown();
216         testClientResponsivenessProgressiveDisclosureOfGroup();
217         testClientResponsivenessProgressiveDisclosureRefreshBasedOnTimer();
218         testClientResponsivenessProgressiveDisclosureShowFieldThroughMatching();
219 //        testClientResponsivenessProgressiveDisclosureConditionalRefresh();
220 //        testClientResponsivenessProgressiveDisclosureCollectionWithGroupRefresh();
221 //        testClientResponsivenessProgressiveDisclosureConditionalOptions();
222         testClientResponsivenessProgressiveDisclosureFieldWithCheckBoxFieldset();
223         testClientResponsivenessProgressiveDisclosureFieldWithRadioFieldset();
224     }
225 }