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.xwiki.test.selenium.framework.AbstractXWikiTestCase; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
@version |
29 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 1 |
Complexity Density: 0.04 |
|
30 |
|
public class ValidationTest extends AbstractXWikiTestCase |
31 |
|
{ |
32 |
|
private static final String SYNTAX = "xwiki/2.1"; |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (24) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
34 |
1 |
@Test... |
35 |
|
public void testSaveActionValidatesWhenXValidateIsPresent() |
36 |
|
{ |
37 |
1 |
deletePage("Main", "ValidatedClass"); |
38 |
1 |
open("Main", "ValidatedClass", "edit", "editor=class"); |
39 |
1 |
setFieldValue("propname", "prop"); |
40 |
1 |
setFieldValue("proptype", "String"); |
41 |
1 |
clickButtonAndContinue("//input[@name='action_propadd']"); |
42 |
1 |
setFieldValue("prop_validationRegExp", "/^[0-4][0-2]$/"); |
43 |
1 |
setFieldValue("prop_validationMessage", "invalid value for prop"); |
44 |
1 |
clickEditSaveAndView(); |
45 |
1 |
createPage("Main", "ValidatedObject", |
46 |
|
"{{velocity}}value: $doc.display('prop')\n\n#foreach($e in $xcontext.validationStatus.errors)$e #end{{/velocity}}", SYNTAX); |
47 |
1 |
open("Main", "ValidatedObject", "edit", "editor=object"); |
48 |
1 |
getSelenium().select("classname", "value=Main.ValidatedClass"); |
49 |
1 |
clickButtonAndContinue("//input[@name='action_objectadd']"); |
50 |
1 |
setFieldValue("Main.ValidatedClass_0_prop", "22"); |
51 |
1 |
clickEditSaveAndView(); |
52 |
1 |
open("Main", "ValidatedObject", "save", "xvalidate=1"); |
53 |
1 |
assertTextPresent("value: 22"); |
54 |
1 |
open("Main", "ValidatedObject", "edit", "editor=object"); |
55 |
1 |
setFieldValue("Main.ValidatedClass_0_prop", "44"); |
56 |
1 |
clickEditSaveAndView(); |
57 |
1 |
open("Main", "ValidatedObject", "save", "xvalidate=1"); |
58 |
1 |
assertTextNotPresent("value: 44"); |
59 |
1 |
assertTextPresent("invalid value for prop"); |
60 |
1 |
open("Main", "ValidatedObject", "save", "xvalidate=1&Main.ValidatedClass_0_prop=11"); |
61 |
1 |
assertTextPresent("value: 11"); |
62 |
|
} |
63 |
|
} |