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.demo.uif.library.clientresponsiveness;
17  
18  import org.junit.Test;
19  import org.kuali.rice.testtools.selenium.WebDriverLegacyITBase;
20  import org.openqa.selenium.By;
21  
22  /**
23   * @author Kuali Rice Team (rice.collab@kuali.org)
24   *
25   * Functional Test ensures correct behavior of the client responsiveness component refresh actions.
26   */
27  public class LibraryClientResponsivenessInlineEditingAft extends WebDriverLegacyITBase {
28  
29      /* Bookmark url for client repsonsiveness component refresh view */
30      protected static final String BOOKMARK_URL = "/kr-krad/kradsampleapp?viewId=Demo-InlineEdit";
31      
32      /**
33       * Returns the client responsiveness component refresh view
34       * @return the url for the client responsiveness component refresh view
35       */
36      @Override
37      protected String getBookmarkUrl() { return BOOKMARK_URL; }
38  
39      /**
40       * Navigates to the base page, before the tests start
41       * @throws Exception if errors while navigating to base page
42       */
43      @Override
44      protected void navigate() throws Exception {
45          waitAndClickLibraryLink();
46          waitAndClickByLinkText("Client Responsiveness");
47          waitAndClickByLinkText("Inline Editing");
48      }
49  
50      /**
51       * Ensures proper behaviour of the method to call on refresh action
52       * @throws Exception if errors while testing the method to call on refresh action
53       */
54      protected void testClientResponsivenessInlineEditing() throws Exception {
55      	testClientResponsivenessInlineEditTextField();   //   Need to fix this from developement side
56      	testClientResponsivenessInlineEditTextFieldWithComplexMarkUp();   //Need to fix this from developement side
57      	testClientResponsivenessInlineEditTextFieldViaAjax();
58      	testClientResponsivenessInlineEditTextArea();
59      	testClientResponsivenessInlineEditTableCollection();
60      	testClientResponsivenessInlineEditLabelColumnCollectionGrid();
61      }
62  
63      /**
64       * Ensures proper behavior of the reset data on refresh action
65       * @throws Exception if errors while testing rest data on refresh
66       */
67      protected void testClientResponsivenessInlineEditTextField() throws Exception {
68      	waitForElementPresent("//section[@id='Demo-InlineEdit-Example1']/div/button[contains(text(),'My InLine Book Title')]");
69      	waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example1']/div/button");
70          waitAndTypeByXpath("//div[@data-parent='Demo-InlineEdit-Example1']/div/input[@name='dataField3']", "1");
71          waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example1']/div/div/div/button[@title='Save']");
72          waitForElementPresent("//section[@id='Demo-InlineEdit-Example1']/div/button[contains(text(),'My Inline Book Title1')]");
73          waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example1']/div/button");
74          waitAndTypeByXpath("//div[@data-parent='Demo-InlineEdit-Example1']/div/input[@name='dataField3']", "a");
75          waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example1']/div/div/div/button[@title='Cancel']");
76          waitForElementPresent("//section[@id='Demo-InlineEdit-Example1']/div/button[contains(text(),'My Inline Book Title1')]");
77      }
78      
79      /**
80       * Ensures proper behavior of the reset data on refresh action
81       * @throws Exception if errors while testing rest data on refresh
82       */
83      protected void testClientResponsivenessInlineEditTextFieldWithComplexMarkUp() throws Exception {
84      	selectByName("exampleShown","Inline Edit Text Field w Complex Markup");
85      	waitForElementPresent("//section[@id='Demo-InlineEdit-Example2']/div/button[contains(text(),'My Book Title')]");
86      	waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example2']/div/button");
87          waitAndTypeByXpath("//div[@data-parent='Demo-InlineEdit-Example2']/div/input[@name='dataField6']", "a");
88          waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example2']/div/div/div/button[@title='Save']");
89          waitForElementPresent("//section[@id='Demo-InlineEdit-Example2']/div/button[contains(text(),'My Book Titlea')]");
90          waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example2']/div/button");
91          waitAndTypeByXpath("//div[@data-parent='Demo-InlineEdit-Example2']/div/input[@name='dataField6']", "b");
92          waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example2']/div/div/div/button[@title='Cancel']");
93          waitForElementPresent("//section[@id='Demo-InlineEdit-Example2']/div/button[contains(text(),'My Book Titlea')]");
94      }
95      
96      /**
97       * Ensures proper behavior of the reset data on refresh action
98       * @throws Exception if errors while testing rest data on refresh
99       */
100     protected void testClientResponsivenessInlineEditTextFieldViaAjax() throws Exception {
101     	selectByName("exampleShown","Inline Edit Text Field via Ajax");
102     	waitForElementPresent("//section[@id='Demo-InlineEdit-Example3']/div/button[contains(text(),'10011')]");
103     	waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example3']/div/button");
104         waitAndTypeByName("dataField1","a");
105         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example3']/div/div/div/button[@title='Save']");
106         waitForElementPresent("//section[@id='Demo-InlineEdit-Example3']/div/button[contains(text(),'10011a')]");
107         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example3']/div/button");
108         waitAndTypeByName("dataField1","b");
109         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example3']/div/div/div/button[@title='Cancel']");
110         waitForElementPresent("//section[@id='Demo-InlineEdit-Example3']/div/button[contains(text(),'10011a')]");
111     }
112     
113     /**
114      * Ensures proper behavior of the reset data on refresh action
115      * @throws Exception if errors while testing rest data on refresh
116      */
117     protected void testClientResponsivenessInlineEditTextArea() throws Exception {
118     	selectByName("exampleShown","Inline Edit Textarea");
119     	waitForElementPresent("//section[@id='Demo-InlineEdit-Example4']/div/button/pre[contains(text(),'Book')]");
120     	waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example4']/div/button");
121         waitAndTypeByName("dataField5","asdf");
122         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example4']/div/div/div/button[@title='Save']");
123         waitForElementPresent("//section[@id='Demo-InlineEdit-Example4']/div/button/pre[contains(text(),'asdf')]");
124         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example4']/div/button");
125         waitAndTypeByName("dataField5","b");
126         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example4']/div/div/div/button[@title='Cancel']");
127         waitForElementPresent("//section[@id='Demo-InlineEdit-Example4']/div/button/pre[contains(text(),'asdf')]");
128     }
129     
130     /**
131      * Ensures proper behavior of the reset data on refresh action
132      * @throws Exception if errors while testing rest data on refresh
133      */
134     protected void testClientResponsivenessInlineEditSelect() throws Exception {
135     	selectByName("exampleShown","Inline Edit Select");
136     	waitForElementPresent("//section[@id='Demo-InlineEdit-Example5']/div/button[contains(text(),'Option 3')]");
137         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example5']/div/button");
138         selectByName("dataField7","Option 1");
139         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example5']/div/div/div/button[@title='Save']");
140         waitForElementPresent("//section[@id='Demo-InlineEdit-Example5']/div/button[contains(text(),'1')]");
141         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example5']/div/button");
142         selectByName("dataField7","Option 2");
143         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example5']/div/div/div/button[@title='Cancel']");
144         waitForElementPresent("//section[@id='Demo-InlineEdit-Example5']/div/button[contains(text(),'1')]");
145     }
146 
147     /**
148      * Ensures proper behavior of the reset data on refresh action
149      * @throws Exception if errors while testing rest data on refresh
150      */
151     protected void testClientResponsivenessInlineEditPopoverWidget() throws Exception {
152     	selectByName("exampleShown","Inline Edit in Popover widget");
153         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example6']/button");
154         waitForElementPresentByXpath("//div[@id='Demo-PopoverContent-Group']/div/button[contains(text(),'My Second Book Title')]");
155         waitAndClickByXpath("//div[@id='Demo-PopoverContent-Group']/div/button");
156         waitAndTypeByName("dataField8","a");
157         waitAndClickByXpath("//div[@id='Demo-PopoverContent-Group']/div/div/div/button[@title='Save']");
158         waitForElementPresentByXpath("//div[@id='Demo-PopoverContent-Group']/div/button[contains(text(),'My Second Book Titlea')]");
159         waitAndClickByXpath("//div[@id='Demo-PopoverContent-Group']/div/button");
160         waitAndTypeByName("dataField8","b");
161         waitAndClickByXpath("//div[@id='Demo-PopoverContent-Group']/div/div/div/button[@title='Cancel']");
162         waitForElementPresentByXpath("//div[@id='Demo-PopoverContent-Group']/div/button[contains(text(),'My Second Book Titlea')]");
163         waitForElementPresentByXpath("//div[@id='Demo-PopoverContent-Group']/div[2]/button");
164         waitForElementPresentByXpath("//div[@id='Demo-PopoverContent-Group']/div[3]/input");
165         waitAndClickByXpath("//div[@id='Demo-PopoverContent-Group']/button");
166         acceptAlertIfPresent();
167     }
168     
169     /**
170      * Ensures proper behavior of the reset data on refresh action
171      * @throws Exception if errors while testing rest data on refresh
172      */
173     protected void testClientResponsivenessInlineEditDisclosureWidget() throws Exception {
174     	selectByName("exampleShown","Inline Edit in Disclosure widget");
175     	waitForElementPresentByXpath("//div[@style='display: none; overflow: hidden;']");
176         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example7']/section/header/h3/a");
177         waitForElementPresentByXpath("//div[@style='display: block; overflow: hidden;']");
178         waitForElementPresent("//section[@id='Demo-InlineEdit-Example7']/section/div/div/button[contains(text(),'My Third Book Title')]");
179     	waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example7']/section/div/div/button");
180         waitAndTypeByName("dataField11","a");
181         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example7']/section/div/div/div/div/button[@title='Save']");
182         waitForElementPresent("//section[@id='Demo-InlineEdit-Example7']/section/div/div/button[contains(text(),'My Third Book Titlea')]");
183         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example7']/section/div/div/button");
184         waitAndTypeByName("dataField11","b");
185         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example7']/section/div/div/div/div/button[@title='Cancel']");
186         waitForElementPresent("//section[@id='Demo-InlineEdit-Example7']/section/div/div/button[contains(text(),'My Third Book Titlea')]");
187     }
188     
189     /**
190      * Ensures proper behavior of the reset data on refresh action
191      * @throws Exception if errors while testing rest data on refresh
192      */
193     protected void testClientResponsivenessInlineEditTableCollection() throws Exception {
194     	selectByName("exampleShown","Inline Edit in Table Collection");
195     	waitForElementPresent("//table/tbody/tr/td/div/button[contains(text(),'1')]");
196     	waitAndClickByXpath("//table/tbody/tr/td/div/button");
197         waitAndTypeByName("collection1[0].field1","a");
198         waitAndClickByXpath("//table/tbody/tr/td/div/div/div/button[@title='Save']");
199         waitForElementPresent("//table/tbody/tr/td/div/button[contains(text(),'1a')]");
200         waitAndClickByXpath("//table/tbody/tr/td/div/button");
201         waitAndTypeByName("collection1[0].field1","b");
202         waitAndClickByXpath("//table/tbody/tr/td/div/div/div/button[@title='Cancel']");
203         waitForElementPresent("//table/tbody/tr/td/div/button[contains(text(),'1a')]");
204     }
205     
206     /**
207      * Ensures proper behavior of the reset data on refresh action
208      * @throws Exception if errors while testing rest data on refresh
209      */
210     protected void testClientResponsivenessInlineEditLabelColumnCollectionGrid() throws Exception {
211     	selectByName("exampleShown","Inline Edit in a 1 Label Column CSS Grid");
212     	waitForElementPresent("//section[@id='Demo-InlineEdit-Example9']/div/div/button");
213     	waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example9']/div/div/button");
214         waitAndTypeByName("inputField10","1");
215         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example9']/div/div/div/div/button[@title='Save']");
216         waitForElementPresent("//section[@id='Demo-InlineEdit-Example9']/div/div/button[contains(text(),'1')]");
217         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example9']/div/div/button");
218         waitAndTypeByName("inputField10","a");
219         waitAndClickByXpath("//section[@id='Demo-InlineEdit-Example9']/div/div/div/div/button[@title='Cancel']");
220         waitForElementPresent("//section[@id='Demo-InlineEdit-Example9']/div/div/button[contains(text(),'1')]");
221     }
222     
223     /**
224      * Test by bookmark
225      * @throws Exception if errors while testing bookmark
226      */
227     @Test
228     public void testClientResponsivenessComponentRefreshBookmark() throws Exception {
229         testClientResponsivenessInlineEditing();
230         passed();
231     }
232 
233     /**
234      * Test by navigation
235      * @throws Exception if errors while testing navigation
236      */
237     @Test
238     public void testClientResponsivenessComponentRefreshNav() throws Exception {
239         testClientResponsivenessInlineEditing();
240         passed();
241     }
242 
243     @Test
244     public void testClientResponsivenessInlineEditDisclosureWidgetBookmark() throws Exception {
245         testClientResponsivenessInlineEditDisclosureWidget();
246         passed();
247     }
248 
249     @Test
250     public void testClientResponsivenessInlineEditDisclosureWidgetNav() throws Exception {
251         testClientResponsivenessInlineEditDisclosureWidget();
252         passed();
253     }
254 
255     @Test
256     public void testClientResponsivenessInlineEditSelectBookmark() throws Exception {
257         testClientResponsivenessInlineEditSelect();
258         passed();
259     }
260 
261     @Test
262     public void testClientResponsivenessInlineEditSelectNav() throws Exception {
263         testClientResponsivenessInlineEditSelect();
264         passed();
265     }
266 
267     @Test
268     public void testClientResponsivenessInlineEditPopoverWidgetBookmark() throws Exception {
269         testClientResponsivenessInlineEditPopoverWidget();
270         passed();
271     }
272 
273     @Test
274     public void testClientResponsivenessInlineEditPopoverWidgetNav() throws Exception {
275         testClientResponsivenessInlineEditPopoverWidget();
276         passed();
277     }
278 }