1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.test.selenium; |
21 |
|
|
22 |
|
import org.junit.Test; |
23 |
|
import org.openqa.selenium.By; |
24 |
|
import org.openqa.selenium.Keys; |
25 |
|
import org.openqa.selenium.WebElement; |
26 |
|
import org.xwiki.test.selenium.framework.AbstractXWikiTestCase; |
27 |
|
|
28 |
|
import static org.junit.Assert.*; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@version |
34 |
|
|
|
|
| 80.9% |
Uncovered Elements: 67 (351) |
Complexity: 25 |
Complexity Density: 0.08 |
|
35 |
|
public class AdministrationTest extends AbstractXWikiTestCase |
36 |
|
{ |
37 |
|
|
38 |
|
|
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
40 |
1 |
@Test... |
41 |
|
public void testApplicationSection() |
42 |
|
{ |
43 |
|
|
44 |
1 |
deletePage("XWiki", "SearchAdmin"); |
45 |
1 |
clickAdministerWiki(); |
46 |
1 |
assertElementNotPresent("//*[contains(@class, 'admin-menu')]//a[contains(@href, 'section=Search')]"); |
47 |
1 |
restorePage("XWiki", "SearchAdmin"); |
48 |
|
} |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
53 |
1 |
@Test... |
54 |
|
public void testSettingXWikiPreferences() |
55 |
|
{ |
56 |
1 |
clickAdministerWiki(); |
57 |
1 |
clickLinkWithXPath("//a[text()='Localization']", true); |
58 |
1 |
getSelenium().select("//select[@name='XWiki.XWikiPreferences_0_multilingual']", "label=Yes"); |
59 |
1 |
clickLinkWithXPath("//input[@value='Save']", true); |
60 |
1 |
assertElementPresent("//a[@id='tmLanguages']"); |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
@value |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
@value |
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (52) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
89 |
1 |
@Test... |
90 |
|
public void testPanelsAdmin() |
91 |
|
{ |
92 |
1 |
open("XWiki", "XWikiPreferences", "admin"); |
93 |
|
|
94 |
|
|
95 |
1 |
clickLinkWithLocator("//a[text()='Panel Wizard']"); |
96 |
1 |
waitForBodyContains("Page Layout"); |
97 |
1 |
clickLinkWithXPath("//a[@href='#PageLayoutSection']", false); |
98 |
1 |
waitForElement("//div[@id = 'rightcolumn']"); |
99 |
1 |
clickLinkWithXPath("//div[@id='rightcolumn']", false); |
100 |
1 |
waitForBodyContains("Panel List"); |
101 |
1 |
clickLinkWithXPath("//a[@href='#PanelListSection']", false); |
102 |
1 |
dragAndDrop(By.xpath("//div[@class='panel expanded CategoriesPanel']//h1"), By.id("rightPanels")); |
103 |
1 |
assertElementPresent("//div[@id = 'rightPanels']/div[contains(@class, 'CategoriesPanel')]"); |
104 |
1 |
clickLinkWithXPath("//button[text()='Save the new layout']", false); |
105 |
1 |
waitForNotificationSuccessMessage("The layout has been saved properly."); |
106 |
1 |
open("Main", "WebHome"); |
107 |
1 |
assertElementNotPresent("leftPanels"); |
108 |
1 |
assertElementPresent("rightPanels"); |
109 |
1 |
assertElementPresent("//div[@id = 'rightPanels']/div[contains(@class, 'CategoriesPanel')]"); |
110 |
|
|
111 |
|
|
112 |
1 |
open("XWiki", "XWikiPreferences", "admin"); |
113 |
1 |
clickLinkWithLocator("//a[text()='Panel Wizard']"); |
114 |
1 |
waitForBodyContains("Page Layout"); |
115 |
1 |
clickLinkWithXPath("//a[@href='#PageLayoutSection']", false); |
116 |
1 |
waitForCondition("selenium.isElementPresent(\"//div[@id='bothcolumns']\")!=false;"); |
117 |
1 |
clickLinkWithXPath("//div[@id='bothcolumns']", false); |
118 |
1 |
waitForBodyContains("Panel List"); |
119 |
1 |
clickLinkWithXPath("//a[@href='#PanelListSection']", false); |
120 |
1 |
dragAndDrop(By.xpath("//div[@id='rightPanels']//div[contains(@class, 'CategoriesPanel')]//h1"), |
121 |
|
By.xpath("//div[@id='allviewpanels']//div[@class='accordionTabContentBox']")); |
122 |
1 |
assertElementNotPresent("//div[@id = 'rightPanels']//div[contains(@class, 'CategoriesPanel')]"); |
123 |
1 |
clickLinkWithXPath("//button[text()='Save the new layout']", false); |
124 |
1 |
waitForNotificationSuccessMessage("The layout has been saved properly."); |
125 |
1 |
open("Main", "WebHome"); |
126 |
1 |
assertElementPresent("leftPanels"); |
127 |
1 |
assertElementPresent("rightPanels"); |
128 |
1 |
assertElementNotPresent("//div[@id = 'rightPanels']//div[contains(@class, 'CategoriesPanel')]"); |
129 |
|
|
130 |
|
|
131 |
1 |
open("TestPanelsAdmin", "WebHome", "edit", "editor=wiki"); |
132 |
1 |
setFieldValue("content", "aaa"); |
133 |
1 |
clickEditSaveAndView(); |
134 |
1 |
open("TestPanelsAdmin", "WebPreferences", "admin"); |
135 |
1 |
clickLinkWithLocator("//a[text()='Panel Wizard']"); |
136 |
1 |
waitForBodyContains("Page Layout"); |
137 |
1 |
clickLinkWithXPath("//a[@href='#PageLayoutSection']", false); |
138 |
1 |
waitForCondition("selenium.isElementPresent(\"//div[@id='leftcolumn']\")!=false;"); |
139 |
1 |
clickLinkWithXPath("//div[@id='leftcolumn']", false); |
140 |
1 |
waitForBodyContains("Panel List"); |
141 |
1 |
clickLinkWithXPath("//a[@href='#PanelListSection']", false); |
142 |
1 |
dragAndDrop(By.xpath("//div[@class='panel expanded CategoriesPanel']//h1"), By.id("leftPanels")); |
143 |
1 |
clickLinkWithXPath("//button[text()='Save the new layout']", false); |
144 |
1 |
waitForNotificationSuccessMessage("The layout has been saved properly."); |
145 |
1 |
open("TestPanelsAdmin", "WebHome"); |
146 |
1 |
assertElementPresent("leftPanels"); |
147 |
1 |
assertElementPresent("//div[@id = 'leftPanels']//div[contains(@class, 'CategoriesPanel')]"); |
148 |
1 |
open("XWiki", "WebHome"); |
149 |
1 |
assertElementPresent("rightPanels"); |
150 |
1 |
assertElementNotPresent("//div[@id = 'leftPanels']//div[contains(@class, 'CategoriesPanel')]"); |
151 |
|
} |
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
159 |
1 |
@Test... |
160 |
|
public void testAddConfigurableApplicationInExistingSection() |
161 |
|
{ |
162 |
|
|
163 |
1 |
createConfigurableApplication("Main", "TestConfigurable", "Presentation", true); |
164 |
|
|
165 |
1 |
open("XWiki", "XWikiPreferences", "admin", "editor=globaladmin§ion=Presentation"); |
166 |
1 |
assertConfigurationPresent("Main", "TestConfigurable"); |
167 |
|
|
168 |
1 |
open("Main", "WebPreferences", "admin", "editor=spaceadmin§ion=Presentation"); |
169 |
1 |
assertConfigurationNotPresent("Main", "TestConfigurable"); |
170 |
|
|
171 |
1 |
open("Main", "TestConfigurable", "edit", "editor=object"); |
172 |
1 |
expandObject("XWiki.ConfigurableClass", 0); |
173 |
1 |
getSelenium().uncheck("XWiki.ConfigurableClass_0_configureGlobally"); |
174 |
1 |
clickEditSaveAndView(); |
175 |
|
|
176 |
1 |
open("Main", "WebPreferences", "admin", "editor=spaceadmin§ion=Presentation"); |
177 |
1 |
assertConfigurationPresent("Main", "TestConfigurable"); |
178 |
|
|
179 |
1 |
open("XWiki", "WebPreferences", "admin", "editor=spaceadmin§ion=Presentation"); |
180 |
1 |
assertConfigurationNotPresent("Main", "TestConfigurable"); |
181 |
|
|
182 |
1 |
open("XWiki", "XWikiPreferences", "admin", "editor=globaladmin§ion=Presentation"); |
183 |
1 |
assertConfigurationNotPresent("Main", "TestConfigurable"); |
184 |
|
} |
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
192 |
1 |
@Test... |
193 |
|
public void testAddConfigurableApplicationInNonexistantSection() |
194 |
|
{ |
195 |
1 |
String section = "HopingThereIsNoSectionByThisName"; |
196 |
|
|
197 |
1 |
createConfigurableApplication("Main", "TestConfigurable", section, true); |
198 |
|
|
199 |
1 |
clickAdministerWiki(); |
200 |
1 |
waitForElement(getAdminMenuItemLocator(section)); |
201 |
1 |
clickLinkWithText(section); |
202 |
1 |
assertConfigurationPresent("Main", "TestConfigurable"); |
203 |
|
|
204 |
1 |
open("Main", "WebPreferences", "admin"); |
205 |
|
|
206 |
1 |
assertElementNotPresent(getAdminMenuItemLocator(section)); |
207 |
|
} |
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
|
212 |
|
|
213 |
|
|
214 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
215 |
1 |
@Test... |
216 |
|
public void testConfigurableCreatedByUnauthorizedWillNotExecute() |
217 |
|
{ |
218 |
|
|
219 |
|
|
220 |
1 |
deletePage("Main", "testConfigurableCreatedByUnauthorizedWillNotExecute"); |
221 |
|
|
222 |
1 |
loginAndRegisterUser("anotherJoker", "bentOnMalice", false); |
223 |
1 |
String nonExistingSection = "HopingThereIsNoSectionByThisName"; |
224 |
1 |
createConfigurableApplication("Main", |
225 |
|
"testConfigurableCreatedByUnauthorizedWillNotExecute", |
226 |
|
nonExistingSection, true); |
227 |
1 |
loginAsAdmin(); |
228 |
1 |
open("XWiki", "XWikiPreferences", "admin", "editor=globaladmin§ion=" + nonExistingSection); |
229 |
1 |
assertConfigurationNotEditable("Main", "testConfigurableCreatedByUnauthorizedWillNotExecute"); |
230 |
|
} |
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (36) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
239 |
1 |
@Test... |
240 |
|
public void testApplicationConfiguredInMultipleSections() |
241 |
|
{ |
242 |
1 |
String space = "Main"; |
243 |
1 |
String page = "TestConfigurable"; |
244 |
|
|
245 |
1 |
createConfigurableApplication(space, page, "TestSection1", true); |
246 |
1 |
open(space, page, "edit", "editor=object"); |
247 |
|
|
248 |
1 |
getSelenium().select("classname", "value=XWiki.ConfigurableClass"); |
249 |
1 |
clickButtonAndContinue("//input[@name='action_objectadd']"); |
250 |
1 |
setFieldValue("XWiki.ConfigurableClass_1_displayInSection", "TestSection2"); |
251 |
1 |
setFieldValue("XWiki.ConfigurableClass_1_heading", "Some Other Heading"); |
252 |
1 |
setFieldValue("XWiki.ConfigurableClass_1_configurationClass", space + "." + page); |
253 |
1 |
getSelenium().uncheck("XWiki.ConfigurableClass_1_configureGlobally"); |
254 |
|
|
255 |
1 |
setFieldValue("XWiki.ConfigurableClass_1_propertiesToShow", "TextArea, Select"); |
256 |
1 |
setFieldValue("XWiki.ConfigurableClass_0_propertiesToShow", "String, Boolean"); |
257 |
1 |
clickEditSaveAndView(); |
258 |
|
|
259 |
|
|
260 |
1 |
open("XWiki", "XWikiPreferences", "admin", "editor=globaladmin§ion=TestSection1"); |
261 |
1 |
assertElementPresent("//div[@id='admin-page-content']/h2[@id='HSomeHeading']/span"); |
262 |
|
|
263 |
1 |
String fullName = space + "." + page; |
264 |
1 |
String form = "//div[@id='admin-page-content']/form[@action='/xwiki/bin/save/" + space + "/" + page + "']"; |
265 |
1 |
assertElementPresent(form + "/fieldset//label['String']"); |
266 |
1 |
assertElementPresent(form + "/fieldset//input[@name='" + fullName + "_0_String']"); |
267 |
1 |
assertElementPresent(form + "/fieldset//label['Boolean']"); |
268 |
1 |
assertElementPresent(form + "/fieldset//select[@name='" + fullName + "_0_Boolean']"); |
269 |
1 |
assertElementPresent(form + "/fieldset/input[@id='" + fullName + "_redirect']"); |
270 |
|
|
271 |
1 |
assertElementPresent(form + "/fieldset/input[@value='" + getSelenium().getLocation() + "'][@name='xredirect']"); |
272 |
|
|
273 |
|
|
274 |
|
|
275 |
1 |
waitForElement("//div/div/p/span/input[@type='submit'][@value='Save']"); |
276 |
|
|
277 |
1 |
assertElementNotPresent(form + "/fieldset//textarea[@name='" + fullName + "_0_TextArea']"); |
278 |
1 |
assertElementNotPresent(form + "/fieldset//select[@name='" + fullName + "_0_Select']"); |
279 |
|
|
280 |
|
|
281 |
1 |
open("Main", "WebPreferences", "admin", "editor=spaceadmin§ion=TestSection2"); |
282 |
1 |
assertElementPresent("//h2[@id='HSomeOtherHeading']/span"); |
283 |
|
|
284 |
1 |
assertElementPresent(form + "/fieldset//label"); |
285 |
1 |
assertElementPresent(form + "/fieldset//textarea[@name='" + fullName + "_0_TextArea']"); |
286 |
1 |
assertElementPresent(form + "/fieldset//select[@name='" + fullName + "_0_Select']"); |
287 |
1 |
assertElementPresent(form + "/fieldset/input[@id='" + fullName + "_redirect']"); |
288 |
|
|
289 |
1 |
assertElementPresent(form + "/fieldset/input[@value='" + getSelenium().getLocation() + "'][@name='xredirect']"); |
290 |
|
|
291 |
|
|
292 |
|
|
293 |
1 |
waitForElement("//div/div/p/span/input[@type='submit'][@value='Save']"); |
294 |
|
|
295 |
1 |
assertElementNotPresent(form + "/fieldset//input[@name='" + fullName + "_0_String']"); |
296 |
1 |
assertElementNotPresent(form + "/fieldset//select[@name='" + fullName + "_0_Boolean']"); |
297 |
|
} |
298 |
|
|
299 |
|
|
300 |
|
|
301 |
|
@see |
302 |
|
|
303 |
|
|
304 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
305 |
1 |
@Test... |
306 |
|
public void testNotStrippingHtmlMacros() |
307 |
|
{ |
308 |
1 |
String space = "Main"; |
309 |
1 |
String page = "TestConfigurable"; |
310 |
1 |
String test = "{{html}} <pre> {{html clean=\"false\"}} </pre> {{/html}}"; |
311 |
|
|
312 |
1 |
String fullName = space + "." + page; |
313 |
1 |
String form = "//div[@id='admin-page-content']/form[@action='/xwiki/bin/save/" + space + "/" + page + "']"; |
314 |
|
|
315 |
1 |
createConfigurableApplication(space, page, "TestSection1", true); |
316 |
1 |
open(space, page, "edit", "editor=object"); |
317 |
1 |
expandObject(fullName, 0); |
318 |
1 |
setFieldValue(fullName + "_0_TextArea", test); |
319 |
1 |
setFieldValue(fullName + "_0_String", test); |
320 |
1 |
clickEditSaveAndView(); |
321 |
|
|
322 |
1 |
open("XWiki", "XWikiPreferences", "admin", "editor=globaladmin§ion=TestSection1"); |
323 |
1 |
waitForTextPresent(form + "/fieldset//textarea[@name='" + fullName + "_0_TextArea']", test); |
324 |
|
|
325 |
1 |
assertTrue(getSelenium().getValue(form + "/fieldset//input[@name='" + fullName + "_0_String']").equals(test)); |
326 |
|
} |
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
337 |
1 |
@Test... |
338 |
|
public void testLabelLinkGeneration() |
339 |
|
{ |
340 |
1 |
String space = "Main"; |
341 |
1 |
String page = "TestConfigurable"; |
342 |
1 |
createConfigurableApplication(space, page, "TestSection3", true); |
343 |
1 |
open(space, page, "edit", "editor=object"); |
344 |
1 |
setFieldValue("XWiki.ConfigurableClass_0_linkPrefix", "TheLinkPrefix"); |
345 |
1 |
clickEditSaveAndView(); |
346 |
|
|
347 |
1 |
open("XWiki", "XWikiPreferences", "admin", "editor=globaladmin§ion=TestSection3"); |
348 |
1 |
assertElementPresent("//form/fieldset//a[@href='TheLinkPrefixString']"); |
349 |
1 |
assertElementPresent("//form/fieldset//a[@href='TheLinkPrefixBoolean']"); |
350 |
1 |
assertElementPresent("//form/fieldset//a[@href='TheLinkPrefixTextArea']"); |
351 |
1 |
assertElementPresent("//form/fieldset//a[@href='TheLinkPrefixSelect']"); |
352 |
|
} |
353 |
|
|
354 |
|
|
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
|
359 |
|
|
|
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 1 |
Complexity Density: 0.04 |
3FAIL
|
|
360 |
0 |
@Test... |
361 |
|
public void testLockingAndUnlocking() |
362 |
|
{ |
363 |
0 |
String space = "Main"; |
364 |
0 |
String page1 = "TestConfigurable"; |
365 |
0 |
String page2 = "TestConfigurable2"; |
366 |
0 |
String isThisPageLocked = "{{velocity}}Is This Page Locked $doc.getLocked(){{/velocity}}"; |
367 |
0 |
createConfigurableApplication(space, page1, "TestSection4", true); |
368 |
0 |
createConfigurableApplication(space, page2, "TestSection5", true); |
369 |
0 |
open(space, page1, "edit", "editor=wiki"); |
370 |
0 |
setFieldValue("content", isThisPageLocked); |
371 |
0 |
clickEditSaveAndView(); |
372 |
0 |
open(space, page2, "edit", "editor=wiki"); |
373 |
0 |
setFieldValue("content", isThisPageLocked); |
374 |
0 |
clickEditSaveAndView(); |
375 |
|
|
376 |
|
|
377 |
0 |
open("XWiki", "XWikiPreferences", "admin", "editor=globaladmin§ion=TestSection4"); |
378 |
|
|
379 |
0 |
try { |
380 |
|
|
381 |
|
|
382 |
0 |
getSelenium().openWindow("http://127.0.0.1:8080" + getUrl(space, page1, "view"), getTestMethodName()); |
383 |
0 |
getSelenium().selectWindow(getTestMethodName()); |
384 |
0 |
assertTextPresent("Is This Page Locked true"); |
385 |
|
|
386 |
0 |
open("http://127.0.0.1:8080" + getUrl(space, page2, "view")); |
387 |
0 |
assertTextPresent("Is This Page Locked false"); |
388 |
|
|
389 |
0 |
getSelenium().selectWindow(null); |
390 |
0 |
open("XWiki", "XWikiPreferences", "admin", "editor=globaladmin§ion=TestSection5"); |
391 |
|
|
392 |
0 |
getSelenium().selectWindow(getTestMethodName()); |
393 |
0 |
open("http://127.0.0.1:8080" + getUrl(space, page1, "view")); |
394 |
0 |
assertTextPresent("Is This Page Locked false"); |
395 |
|
|
396 |
0 |
open("http://127.0.0.1:8080" + getUrl(space, page2, "view")); |
397 |
0 |
assertTextPresent("Is This Page Locked true"); |
398 |
|
|
399 |
|
|
400 |
0 |
getSelenium().close(); |
401 |
|
} finally { |
402 |
0 |
getSelenium().selectWindow(null); |
403 |
|
} |
404 |
|
} |
405 |
|
|
406 |
|
|
407 |
|
|
408 |
|
|
409 |
|
|
410 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
411 |
1 |
@Test... |
412 |
|
public void testCodeToExecutionAndAutoSandboxing() |
413 |
|
{ |
414 |
1 |
String space = "Main"; |
415 |
1 |
String page = "TestConfigurable"; |
416 |
1 |
String codeToExecute = "#set($code = 's sh')" |
417 |
|
+ "Thi${code}ould be displayed." |
418 |
|
+ "#if($xcontext.hasProgrammingRights())" |
419 |
|
+ "This should not be displayed." |
420 |
|
+ "#end"; |
421 |
1 |
String heading = "#set($code = 'his sho')" |
422 |
|
+ "T${code}uld also be displayed."; |
423 |
1 |
createConfigurableApplication(space, page, "TestSection6", true); |
424 |
1 |
open(space, page, "edit", "editor=object"); |
425 |
1 |
expandObject("XWiki.ConfigurableClass", 0); |
426 |
1 |
setFieldValue("XWiki.ConfigurableClass_0_codeToExecute", codeToExecute); |
427 |
1 |
setFieldValue("XWiki.ConfigurableClass_0_heading", heading); |
428 |
1 |
setFieldValue("XWiki.ConfigurableClass_0_configurationClass", ""); |
429 |
1 |
clickEditSaveAndView(); |
430 |
|
|
431 |
|
|
432 |
1 |
open("XWiki", "ConfigurableClass", "edit", "editor=wiki"); |
433 |
|
|
434 |
1 |
try { |
435 |
|
|
436 |
|
|
437 |
1 |
getDriver().findElement(By.id("content")).sendKeys(Keys.chord(Keys.CONTROL, "a"), |
438 |
|
Keys.chord(Keys.CONTROL, "c"), Keys.ARROW_RIGHT, |
439 |
|
"{{velocity}}Has Programming permission: $xcontext.hasProgrammingRights(){{/velocity}}"); |
440 |
1 |
clickEditSaveAndContinue(); |
441 |
|
|
442 |
|
|
443 |
1 |
open("XWiki", "ConfigurableClass", "view", "editor=globaladmin§ion=TestSection6"); |
444 |
|
|
445 |
1 |
assertTextPresent("This should be displayed."); |
446 |
1 |
assertTextPresent("This should also be displayed."); |
447 |
1 |
assertTextNotPresent("This should not be displayed."); |
448 |
1 |
assertTextPresent("Has Programming permission: false"); |
449 |
|
|
450 |
1 |
assertElementNotPresent("//div/div/p/span/input[@type='submit'][@value='Save']"); |
451 |
|
} finally { |
452 |
1 |
open("XWiki", "ConfigurableClass", "edit", "editor=wiki"); |
453 |
1 |
getDriver().findElement(By.id("content")).sendKeys(Keys.chord(Keys.CONTROL, "a"), |
454 |
|
Keys.chord(Keys.CONTROL, "v")); |
455 |
1 |
clickEditSaveAndContinue(); |
456 |
|
} |
457 |
|
} |
458 |
|
|
459 |
|
|
460 |
|
|
461 |
|
|
462 |
|
|
463 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
3FAIL
|
|
464 |
0 |
@Test... |
465 |
|
public void testCodeToExecuteNotInlineIfNoConfigurationClass() |
466 |
|
{ |
467 |
0 |
String space = "Main"; |
468 |
0 |
String page = "TestConfigurable"; |
469 |
0 |
String test = "{{html}} <div> <p> hello </p> </div> {{/html}}"; |
470 |
|
|
471 |
0 |
open(space, page, "delete", "confirm=1"); |
472 |
0 |
createConfigurableApplication(space, page, "TestSection1", true); |
473 |
0 |
open(space, page, "edit", "editor=object"); |
474 |
0 |
expandObject("XWiki.ConfigurableClass", 0); |
475 |
0 |
setFieldValue("XWiki.ConfigurableClass_0_configurationClass", ""); |
476 |
0 |
setFieldValue("XWiki.ConfigurableClass_0_codeToExecute", test); |
477 |
0 |
clickEditSaveAndView(); |
478 |
|
|
479 |
0 |
open("XWiki", "XWikiPreferences", "admin", "editor=globaladmin§ion=TestSection1"); |
480 |
0 |
assertElementNotPresent("//span[@class='xwikirenderingerror']"); |
481 |
|
} |
482 |
|
|
483 |
|
|
484 |
|
|
485 |
|
|
486 |
|
|
487 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 1 |
Complexity Density: 0.06 |
3FAIL
|
|
488 |
0 |
@Test... |
489 |
|
public void testCodeToExecuteNotInline() |
490 |
|
{ |
491 |
0 |
String space = "Main"; |
492 |
0 |
String page = "TestConfigurable"; |
493 |
0 |
String test = "{{html}} <div> <p> hello </p> </div> {{/html}}"; |
494 |
|
|
495 |
0 |
createConfigurableApplication(space, page, "TestSection1", true); |
496 |
0 |
open(space, page, "edit", "editor=object"); |
497 |
0 |
expandObject("XWiki.ConfigurableClass", 0); |
498 |
0 |
setFieldValue("XWiki.ConfigurableClass_0_codeToExecute", test); |
499 |
0 |
setFieldValue("XWiki.ConfigurableClass_0_propertiesToShow", "String, Boolean"); |
500 |
|
|
501 |
0 |
getSelenium().select("classname", "value=XWiki.ConfigurableClass"); |
502 |
0 |
clickButtonAndContinue("//input[@name='action_objectadd']"); |
503 |
0 |
setFieldValue("XWiki.ConfigurableClass_1_displayInSection", "TestSection1"); |
504 |
0 |
setFieldValue("XWiki.ConfigurableClass_1_configurationClass", space + "." + page); |
505 |
0 |
setFieldValue("XWiki.ConfigurableClass_1_propertiesToShow", "TextArea, Select"); |
506 |
0 |
setFieldValue("XWiki.ConfigurableClass_1_codeToExecute", test); |
507 |
0 |
getSelenium().check("XWiki.ConfigurableClass_1_configureGlobally"); |
508 |
0 |
clickEditSaveAndView(); |
509 |
|
|
510 |
0 |
open("XWiki", "XWikiPreferences", "admin", "editor=globaladmin§ion=TestSection1"); |
511 |
0 |
assertElementNotPresent("//span[@class='xwikirenderingerror']"); |
512 |
|
} |
513 |
|
|
514 |
|
|
515 |
|
|
516 |
|
|
517 |
|
|
518 |
|
|
519 |
|
|
520 |
|
|
521 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
522 |
1 |
@Test... |
523 |
|
public void testForgotUsername() |
524 |
|
{ |
525 |
1 |
String space = "Test"; |
526 |
1 |
String page = "SQLTestPage"; |
527 |
1 |
String mail = "webmaster@xwiki.org"; |
528 |
1 |
String user = "Admin"; |
529 |
1 |
String badMail = "bad_mail@evil.com"; |
530 |
|
|
531 |
|
|
532 |
1 |
editInWikiEditor(space, page); |
533 |
1 |
setFieldValue("title", page); |
534 |
1 |
setFieldValue("content", page); |
535 |
1 |
clickEditSaveAndView(); |
536 |
|
|
537 |
|
|
538 |
1 |
open("XWiki", "ForgotUsername"); |
539 |
1 |
setFieldValue("e", mail); |
540 |
1 |
submit("//input[@type='submit']"); |
541 |
1 |
assertTextNotPresent("No account is registered using this email address"); |
542 |
1 |
assertElementPresent("//div[@id='xwikicontent']//strong[text()='" + user + "']"); |
543 |
|
|
544 |
|
|
545 |
1 |
open("XWiki", "ForgotUsername"); |
546 |
1 |
setFieldValue("e", badMail); |
547 |
1 |
submit("//input[@type='submit']"); |
548 |
1 |
assertTextPresent("No account is registered using this email address"); |
549 |
1 |
assertElementNotPresent("//div[@id='xwikicontent']//strong[@value='" + user + "']"); |
550 |
|
|
551 |
|
|
552 |
1 |
open("XWiki", "ForgotUsername"); |
553 |
1 |
setFieldValue("e", "a' synta\\'x error"); |
554 |
1 |
submit("//input[@type='submit']"); |
555 |
1 |
assertTextPresent("No account is registered using this email address"); |
556 |
1 |
assertTextNotPresent("Error"); |
557 |
|
} |
558 |
|
|
559 |
|
|
560 |
|
@return |
561 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
562 |
2 |
public String getAdminMenuItemLocator(String label)... |
563 |
|
{ |
564 |
2 |
return "//*[contains(@class, 'admin-menu')]//a[. = '" + label + "']"; |
565 |
|
} |
566 |
|
|
567 |
|
|
568 |
|
|
569 |
|
|
570 |
|
|
571 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
572 |
0 |
public void assertConfigurationIconNotPresent(String section)... |
573 |
|
{ |
574 |
0 |
assertElementNotPresent("//div[contains(@class,'admin-menu')]//li[contains(@href,'section=" + section + "')]"); |
575 |
|
} |
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
|
581 |
3 |
public void assertConfigurationPresent(String space, String page)... |
582 |
|
{ |
583 |
3 |
assertElementPresent("//div[@id='admin-page-content']/h2[@id='HSomeHeading']/span"); |
584 |
|
|
585 |
3 |
String fullName = space + "." + page; |
586 |
3 |
String form = "//div[@id='admin-page-content']/form[@action='/xwiki/bin/save/" + space + "/" + page + "']"; |
587 |
3 |
assertElementPresent(form + "/fieldset/dl/dt[1]/label"); |
588 |
3 |
assertElementPresent(form + "/fieldset/dl/dd[1]/input[@name='" + fullName + "_0_String']"); |
589 |
3 |
assertElementPresent(form + "/fieldset/dl/dt[2]/label"); |
590 |
3 |
assertElementPresent(form + "/fieldset/dl/dd[2]/select[@name='" + fullName + "_0_Boolean']"); |
591 |
3 |
assertElementPresent(form + "/fieldset/dl/dt[3]/label"); |
592 |
3 |
assertElementPresent(form + "/fieldset/dl/dd[3]/textarea[@name='" + fullName + "_0_TextArea']"); |
593 |
3 |
assertElementPresent(form + "/fieldset/dl/dt[4]/label"); |
594 |
3 |
assertElementPresent(form + "/fieldset/dl/dd[4]/select[@name='" + fullName + "_0_Select']"); |
595 |
3 |
assertElementPresent(form + "/fieldset/input[@id='" + fullName + "_redirect']"); |
596 |
3 |
assertElementPresent(form + "/fieldset/input[@value='" + getSelenium().getLocation() + "'][@name='xredirect']"); |
597 |
|
|
598 |
3 |
waitForElement("//*[@class = 'admin-buttons']//input[@type = 'submit' and @value = 'Save']"); |
599 |
|
} |
600 |
|
|
601 |
|
|
602 |
|
|
603 |
|
|
604 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
605 |
3 |
public void assertConfigurationNotPresent(String space, String page)... |
606 |
|
{ |
607 |
3 |
assertElementNotPresent("//div[@id='admin-page-content']/h1[@id='HCustomize" + space + "." + page + ":']/span"); |
608 |
3 |
assertElementNotPresent("//div[@id='admin-page-content']/h2[@id='HSomeHeading']/span"); |
609 |
3 |
assertConfigurationNotEditable(space, page); |
610 |
|
} |
611 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
612 |
4 |
public void assertConfigurationNotEditable(String space, String page)... |
613 |
|
{ |
614 |
4 |
assertElementNotPresent("//div[@id='admin-page-content']/form[@action='/xwiki/bin/save/" |
615 |
|
+ space + "/" + page + "']"); |
616 |
|
} |
617 |
|
|
618 |
|
|
619 |
|
|
620 |
|
|
621 |
|
|
622 |
|
|
|
|
| 91.3% |
Uncovered Elements: 4 (46) |
Complexity: 4 |
Complexity Density: 0.1 |
|
623 |
11 |
public void createConfigurableApplication(String space, String page, String section, boolean global)... |
624 |
|
{ |
625 |
|
|
626 |
11 |
String storageSpace = "Sandbox"; |
627 |
11 |
String storagePage = "CreateConfigurableApplication"; |
628 |
|
|
629 |
11 |
if (!tryToCopyPage(storageSpace, storagePage, space, page)) { |
630 |
|
|
631 |
8 |
createPage(space, page, "Test configurable application.", "xwiki/2.1"); |
632 |
8 |
open(space, page, "edit", "editor=class"); |
633 |
8 |
setFieldValue("propname", "String"); |
634 |
8 |
setFieldValue("proptype", "String"); |
635 |
8 |
clickButtonAndContinue("//input[@name='action_propadd']"); |
636 |
8 |
setFieldValue("propname", "Boolean"); |
637 |
8 |
setFieldValue("proptype", "Boolean"); |
638 |
8 |
clickButtonAndContinue("//input[@name='action_propadd']"); |
639 |
8 |
setFieldValue("propname", "TextArea"); |
640 |
8 |
setFieldValue("proptype", "TextArea"); |
641 |
8 |
clickButtonAndContinue("//input[@name='action_propadd']"); |
642 |
|
|
643 |
8 |
getSelenium().click("xproperty_TextArea"); |
644 |
8 |
getSelenium().select("TextArea_editor", "value=Text"); |
645 |
8 |
clickEditSaveAndContinue(); |
646 |
8 |
setFieldValue("propname", "Select"); |
647 |
8 |
setFieldValue("proptype", "StaticList"); |
648 |
8 |
clickButtonAndContinue("//input[@name='action_propadd']"); |
649 |
|
|
650 |
|
|
651 |
8 |
open(space, page, "edit", "editor=object"); |
652 |
|
|
653 |
|
|
654 |
8 |
getSelenium().select("classname", "value=XWiki.ConfigurableClass"); |
655 |
8 |
clickButtonAndContinue("//input[@name='action_objectadd']"); |
656 |
8 |
clickEditSaveAndView(); |
657 |
|
|
658 |
|
|
659 |
8 |
tryToCopyPage(space, page, storageSpace, storagePage); |
660 |
|
} |
661 |
|
|
662 |
|
|
663 |
11 |
open(space, page, "edit", "editor=object"); |
664 |
|
|
665 |
|
|
666 |
11 |
waitForElement("classname"); |
667 |
11 |
getSelenium().select("classname", "value=" + space + "." + page); |
668 |
|
|
669 |
11 |
getSelenium().runScript("window.scrollTo(0, 0)"); |
670 |
11 |
clickButtonAndContinue("//input[@name='action_objectadd']"); |
671 |
|
|
672 |
11 |
setFieldValue("XWiki.ConfigurableClass_0_displayInSection", section); |
673 |
11 |
setFieldValue("XWiki.ConfigurableClass_0_heading", "Some Heading"); |
674 |
11 |
setFieldValue("XWiki.ConfigurableClass_0_configurationClass", space + "." + page); |
675 |
|
|
676 |
|
|
677 |
11 |
WebElement configurableClassObj = getDriver().findElement(By.id("xobject_XWiki.ConfigurableClass_0")); |
678 |
11 |
if (configurableClassObj.getAttribute("class").contains("collapsed")) { |
679 |
0 |
configurableClassObj.click(); |
680 |
|
} |
681 |
|
|
682 |
11 |
if (global) { |
683 |
11 |
getSelenium().check("XWiki.ConfigurableClass_0_configureGlobally"); |
684 |
|
} else { |
685 |
0 |
getSelenium().uncheck("XWiki.ConfigurableClass_0_configureGlobally"); |
686 |
|
} |
687 |
|
|
688 |
|
|
689 |
11 |
clickEditSaveAndView(); |
690 |
|
} |
691 |
|
|
692 |
|
|
693 |
|
|
694 |
|
|
695 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
696 |
19 |
public boolean tryToCopyPage(String fromSpace, String fromPage, String toSpace, String toPage)... |
697 |
|
{ |
698 |
19 |
open(fromSpace, fromPage); |
699 |
19 |
if (!isExistingPage()) { |
700 |
1 |
return false; |
701 |
|
} |
702 |
18 |
return copyPage(fromSpace, fromPage, toSpace, toPage); |
703 |
|
} |
704 |
|
} |