1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.test.ui; |
21 |
|
|
22 |
|
import java.util.List; |
23 |
|
|
24 |
|
import org.junit.Assert; |
25 |
|
import org.junit.Before; |
26 |
|
import org.junit.Rule; |
27 |
|
import org.junit.Test; |
28 |
|
import org.openqa.selenium.By; |
29 |
|
import org.xwiki.test.ui.browser.IgnoreBrowser; |
30 |
|
import org.xwiki.test.ui.browser.IgnoreBrowsers; |
31 |
|
import org.xwiki.test.ui.po.FormElement; |
32 |
|
import org.xwiki.test.ui.po.ViewPage; |
33 |
|
import org.xwiki.test.ui.po.editor.ClassEditPage; |
34 |
|
import org.xwiki.test.ui.po.editor.ObjectEditPage; |
35 |
|
import org.xwiki.test.ui.po.editor.ObjectEditPane; |
36 |
|
import org.xwiki.test.ui.po.editor.StaticListClassEditElement; |
37 |
|
import org.xwiki.test.ui.po.editor.WikiEditPage; |
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@version |
43 |
|
@since |
44 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (155) |
Complexity: 9 |
Complexity Density: 0.06 |
|
45 |
|
public class EditObjectsTest extends AbstractTest |
46 |
|
{ |
47 |
|
@Rule |
48 |
|
public AdminAuthenticationRule adminAuthenticationRule = new AdminAuthenticationRule(getUtil()); |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
50 |
8 |
@Before... |
51 |
|
public void setUp() throws Exception |
52 |
|
{ |
53 |
8 |
getUtil().rest().deletePage("Test", "EditObjectsTestClass"); |
54 |
8 |
getUtil().rest().deletePage("Test", "EditObjectsTestObject"); |
55 |
|
} |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
60 |
1 |
@Test... |
61 |
|
public void testEmptyGroupObjects() |
62 |
|
{ |
63 |
|
|
64 |
1 |
WikiEditPage wep = WikiEditPage.gotoPage("Test", "EditObjectsTestObject"); |
65 |
1 |
wep.setContent("this is the content"); |
66 |
1 |
ViewPage vp = wep.clickSaveAndView(); |
67 |
|
|
68 |
|
|
69 |
1 |
ObjectEditPage oep = vp.editObjects(); |
70 |
1 |
oep.addObject("XWiki.XWikiGroups"); |
71 |
1 |
vp = oep.clickSaveAndView(); |
72 |
|
|
73 |
1 |
oep = vp.editObjects(); |
74 |
1 |
Assert.assertEquals(1, oep.getObjectsOfClass("XWiki.XWikiGroups").size()); |
75 |
|
} |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
80 |
1 |
@Test... |
81 |
|
@IgnoreBrowsers({ |
82 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
83 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
84 |
|
}) |
85 |
|
public void testChangeMultiselectProperty() |
86 |
|
{ |
87 |
|
|
88 |
1 |
ClassEditPage cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass"); |
89 |
1 |
cep.addProperty("prop", "DBList"); |
90 |
1 |
cep.getDatabaseListClassEditElement("prop").setHibernateQuery( |
91 |
|
"select doc.fullName from XWikiDocument doc where doc.space = 'Test'"); |
92 |
1 |
cep.clickSaveAndView(); |
93 |
|
|
94 |
|
|
95 |
1 |
WikiEditPage wep = WikiEditPage.gotoPage("Test", "EditObjectsTestObject"); |
96 |
1 |
wep.setContent("this is the content"); |
97 |
1 |
ViewPage vp = wep.clickSaveAndView(); |
98 |
|
|
99 |
|
|
100 |
1 |
ObjectEditPage oep = vp.editObjects(); |
101 |
1 |
FormElement objectForm = oep.addObject("Test.EditObjectsTestClass"); |
102 |
1 |
objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "Test.EditObjectsTestClass"); |
103 |
1 |
oep.clickSaveAndView(); |
104 |
|
|
105 |
|
|
106 |
1 |
cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass"); |
107 |
1 |
cep.getDatabaseListClassEditElement("prop").setMultiSelect(true); |
108 |
1 |
cep.clickSaveAndView(); |
109 |
|
|
110 |
|
|
111 |
1 |
oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject"); |
112 |
1 |
oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue( |
113 |
|
By.id("Test.EditObjectsTestClass_0_prop"), "Test.EditObjectsTestObject"); |
114 |
1 |
vp = oep.clickSaveAndView(); |
115 |
|
|
116 |
1 |
Assert.assertEquals("this is the content", vp.getContent()); |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (31) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
122 |
1 |
@Test... |
123 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146") |
124 |
|
public void testChangeNumberType() |
125 |
|
{ |
126 |
|
|
127 |
1 |
WikiEditPage wep = WikiEditPage.gotoPage("Test", "EditObjectsTestClass"); |
128 |
1 |
wep.setContent("this is the content"); |
129 |
1 |
ViewPage vp = wep.clickSaveAndView(); |
130 |
|
|
131 |
|
|
132 |
1 |
ClassEditPage cep = vp.editClass(); |
133 |
1 |
cep.addProperty("prop", "Number"); |
134 |
1 |
cep.getNumberClassEditElement("prop").setNumberType("integer"); |
135 |
1 |
vp = cep.clickSaveAndView(); |
136 |
1 |
Assert.assertEquals("this is the content", vp.getContent()); |
137 |
|
|
138 |
|
|
139 |
1 |
wep = WikiEditPage.gotoPage("Test", "EditObjectsTestObject"); |
140 |
1 |
wep.setContent("this is the content: {{velocity}}$doc.display('prop'){{/velocity}}"); |
141 |
1 |
vp = wep.clickSaveAndView(); |
142 |
|
|
143 |
|
|
144 |
1 |
ObjectEditPage oep = vp.editObjects(); |
145 |
1 |
FormElement objectForm = oep.addObject("Test.EditObjectsTestClass"); |
146 |
1 |
objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "3"); |
147 |
1 |
vp = oep.clickSaveAndView(); |
148 |
1 |
Assert.assertEquals("this is the content: 3", vp.getContent()); |
149 |
|
|
150 |
|
|
151 |
1 |
cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass"); |
152 |
1 |
cep.getNumberClassEditElement("prop").setNumberType("double"); |
153 |
1 |
vp = cep.clickSaveAndView(); |
154 |
1 |
Assert.assertEquals("this is the content", vp.getContent()); |
155 |
|
|
156 |
|
|
157 |
1 |
oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject"); |
158 |
1 |
oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue( |
159 |
|
By.id("Test.EditObjectsTestClass_0_prop"), "2.5"); |
160 |
1 |
vp = oep.clickSaveAndView(); |
161 |
1 |
Assert.assertEquals("this is the content: 2.5", vp.getContent()); |
162 |
|
|
163 |
|
|
164 |
1 |
cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass"); |
165 |
1 |
cep.getNumberClassEditElement("prop").setNumberType("long"); |
166 |
1 |
vp = cep.clickSaveAndView(); |
167 |
1 |
Assert.assertEquals("this is the content", vp.getContent()); |
168 |
|
|
169 |
|
|
170 |
1 |
oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject"); |
171 |
1 |
vp = oep.clickSaveAndView(); |
172 |
1 |
Assert.assertEquals("this is the content: 2", vp.getContent()); |
173 |
|
} |
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (27) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
179 |
1 |
@Test... |
180 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146") |
181 |
|
public void testChangeListMultipleSelect() |
182 |
|
{ |
183 |
|
|
184 |
1 |
WikiEditPage wep = WikiEditPage.gotoPage("Test", "EditObjectsTestClass"); |
185 |
1 |
wep.setContent("this is the content"); |
186 |
1 |
ViewPage vp = wep.clickSaveAndView(); |
187 |
|
|
188 |
|
|
189 |
1 |
ClassEditPage cep = vp.editClass(); |
190 |
1 |
cep.addProperty("prop", "StaticList"); |
191 |
1 |
StaticListClassEditElement slcee = cep.getStaticListClassEditElement("prop"); |
192 |
1 |
slcee.setMultiSelect(false); |
193 |
1 |
slcee.setValues("choice 1|choice 2|choice 3|choice 4|choice 5"); |
194 |
1 |
vp = cep.clickSaveAndView(); |
195 |
1 |
Assert.assertEquals("this is the content", vp.getContent()); |
196 |
|
|
197 |
|
|
198 |
1 |
wep = WikiEditPage.gotoPage("Test", "EditObjectsTestObject"); |
199 |
1 |
wep.setContent("this is the content: {{velocity}}$doc.display('prop'){{/velocity}}"); |
200 |
1 |
vp = wep.clickSaveAndView(); |
201 |
|
|
202 |
|
|
203 |
1 |
ObjectEditPage oep = vp.editObjects(); |
204 |
1 |
FormElement objectForm = oep.addObject("Test.EditObjectsTestClass"); |
205 |
1 |
objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "choice 3"); |
206 |
1 |
vp = oep.clickSaveAndView(); |
207 |
1 |
Assert.assertEquals("this is the content: choice 3", vp.getContent()); |
208 |
|
|
209 |
|
|
210 |
1 |
cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass"); |
211 |
1 |
cep.getStaticListClassEditElement("prop").setMultiSelect(true); |
212 |
1 |
vp = cep.clickSaveAndView(); |
213 |
1 |
Assert.assertEquals("this is the content", vp.getContent()); |
214 |
|
|
215 |
|
|
216 |
1 |
oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject"); |
217 |
1 |
oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue( |
218 |
|
By.id("Test.EditObjectsTestClass_0_prop"), "choice 3"); |
219 |
1 |
oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue( |
220 |
|
By.id("Test.EditObjectsTestClass_0_prop"), "choice 4"); |
221 |
1 |
vp = oep.clickSaveAndView(); |
222 |
1 |
Assert.assertEquals("this is the content: choice 3 choice 4", vp.getContent()); |
223 |
|
} |
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (34) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
229 |
1 |
@Test... |
230 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146") |
231 |
|
public void testChangeListTypeRelationalStorage() |
232 |
|
{ |
233 |
|
|
234 |
1 |
WikiEditPage wep = WikiEditPage.gotoPage("Test", "EditObjectsTestClass"); |
235 |
1 |
wep.setContent("this is the content"); |
236 |
1 |
ViewPage vp = wep.clickSaveAndView(); |
237 |
|
|
238 |
|
|
239 |
1 |
ClassEditPage cep = vp.editClass(); |
240 |
1 |
cep.addProperty("prop", "StaticList"); |
241 |
1 |
StaticListClassEditElement slcee = cep.getStaticListClassEditElement("prop"); |
242 |
1 |
slcee.setMultiSelect(true); |
243 |
1 |
slcee.setDisplayType(StaticListClassEditElement.DisplayType.INPUT); |
244 |
1 |
vp = cep.clickSaveAndView(); |
245 |
1 |
Assert.assertEquals("this is the content", vp.getContent()); |
246 |
|
|
247 |
|
|
248 |
1 |
wep = WikiEditPage.gotoPage("Test", "EditObjectsTestObject"); |
249 |
1 |
wep.setContent("this is the content: {{velocity}}$doc.display('prop'){{/velocity}}"); |
250 |
1 |
vp = wep.clickSaveAndView(); |
251 |
|
|
252 |
|
|
253 |
1 |
ObjectEditPage oep = vp.editObjects(); |
254 |
1 |
FormElement objectForm = oep.addObject("Test.EditObjectsTestClass"); |
255 |
1 |
objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "this|that|other"); |
256 |
1 |
vp = oep.clickSaveAndView(); |
257 |
1 |
Assert.assertEquals("this is the content: this that other", vp.getContent()); |
258 |
|
|
259 |
|
|
260 |
1 |
cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass"); |
261 |
1 |
cep.getStaticListClassEditElement("prop").setRelationalStorage(true); |
262 |
1 |
vp = cep.clickSaveAndView(); |
263 |
1 |
Assert.assertEquals("this is the content", vp.getContent()); |
264 |
|
|
265 |
|
|
266 |
1 |
oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject"); |
267 |
1 |
oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue( |
268 |
|
By.id("Test.EditObjectsTestClass_0_prop"), "this|other"); |
269 |
1 |
vp = oep.clickSaveAndView(); |
270 |
1 |
Assert.assertEquals("this is the content: this other", vp.getContent()); |
271 |
|
|
272 |
|
|
273 |
1 |
cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass"); |
274 |
1 |
cep.getStaticListClassEditElement("prop").setRelationalStorage(false); |
275 |
1 |
vp = cep.clickSaveAndView(); |
276 |
1 |
Assert.assertEquals("this is the content", vp.getContent()); |
277 |
|
|
278 |
|
|
279 |
1 |
oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject"); |
280 |
1 |
oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue( |
281 |
|
By.id("Test.EditObjectsTestClass_0_prop"), "that|other"); |
282 |
1 |
vp = oep.clickSaveAndView(); |
283 |
1 |
Assert.assertEquals("this is the content: that other", vp.getContent()); |
284 |
|
} |
285 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
286 |
1 |
@Test... |
287 |
|
@IgnoreBrowsers({ |
288 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
289 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
290 |
|
}) |
291 |
|
public void testObjectAddAndRemove() |
292 |
|
{ |
293 |
1 |
ObjectEditPage oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject"); |
294 |
1 |
FormElement object = oep.addObject("XWiki.XWikiUsers"); |
295 |
1 |
object.setFieldValue(By.id("XWiki.XWikiUsers_0_first_name"), "John"); |
296 |
|
|
297 |
|
|
298 |
1 |
FormElement object2 = oep.addObject("XWiki.XWikiUsers"); |
299 |
|
|
300 |
|
|
301 |
1 |
Assert.assertEquals("John", object.getFieldValue(By.id("XWiki.XWikiUsers_0_first_name"))); |
302 |
|
|
303 |
1 |
Assert.assertEquals("", object2.getFieldValue(By.id("XWiki.XWikiUsers_1_first_name"))); |
304 |
|
|
305 |
|
|
306 |
1 |
oep.deleteObject("XWiki.XWikiUsers", 1); |
307 |
|
|
308 |
|
|
309 |
1 |
oep = oep.clickSaveAndView().editObjects(); |
310 |
1 |
List<ObjectEditPane> xwikiUsersForms = oep.getObjectsOfClass("XWiki.XWikiUsers"); |
311 |
1 |
Assert.assertEquals(1, xwikiUsersForms.size()); |
312 |
1 |
Assert.assertEquals("John", xwikiUsersForms.get(0).getFieldValue(By.id("XWiki.XWikiUsers_0_first_name"))); |
313 |
|
} |
314 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
315 |
1 |
@Test... |
316 |
|
public void testInlineObjectAddButton() |
317 |
|
{ |
318 |
1 |
ObjectEditPage oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject"); |
319 |
1 |
oep.addObject("XWiki.XWikiUsers"); |
320 |
1 |
oep.addObjectFromInlineLink("XWiki.XWikiUsers"); |
321 |
|
} |
322 |
|
|
323 |
|
|
324 |
|
@see |
325 |
|
|
326 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
327 |
1 |
@Test... |
328 |
|
public void testPropertyDisplayersForNewObjects() throws Exception |
329 |
|
{ |
330 |
1 |
getUtil().rest().deletePage(getTestClassName(), getTestMethodName()); |
331 |
|
|
332 |
|
|
333 |
1 |
ClassEditPage classEditor = ClassEditPage.gotoPage(getTestClassName(), getTestMethodName()); |
334 |
1 |
classEditor.addProperty("date", "Date"); |
335 |
1 |
classEditor.addProperty("author", "Users"); |
336 |
|
|
337 |
|
|
338 |
1 |
String className = getTestClassName() + "." + getTestMethodName(); |
339 |
1 |
ObjectEditPage objectEditor = ObjectEditPage.gotoPage(getTestClassName(), getTestMethodName()); |
340 |
1 |
ObjectEditPane object = objectEditor.addObject(className); |
341 |
1 |
object.openDatePicker("date").setDay("15"); |
342 |
1 |
object.getUserPicker("author").sendKeys("ad").waitForSuggestions().select("Admin"); |
343 |
|
|
344 |
|
|
345 |
1 |
object = objectEditor.clickSaveAndView().editObjects().getObjectsOfClass(className).get(0); |
346 |
1 |
Assert.assertEquals("15", object.openDatePicker("date").getDay()); |
347 |
1 |
Assert.assertEquals("Administrator", object.getUserPicker("author").waitToLoad().getAcceptedSuggestions() |
348 |
|
.get(0).getName()); |
349 |
|
} |
350 |
|
} |