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 static org.junit.Assert.*; |
23 |
|
|
24 |
|
import org.junit.Rule; |
25 |
|
import org.junit.Test; |
26 |
|
import org.xwiki.model.reference.LocalDocumentReference; |
27 |
|
import org.xwiki.test.ui.po.InlinePage; |
28 |
|
import org.xwiki.test.ui.po.editor.ClassEditPage; |
29 |
|
import org.xwiki.test.ui.po.editor.ObjectEditPage; |
30 |
|
import org.xwiki.test.ui.po.editor.ObjectEditPane; |
31 |
|
import org.xwiki.test.ui.po.editor.PreviewEditPage; |
32 |
|
import org.xwiki.test.ui.po.editor.PreviewableEditPage; |
33 |
|
import org.xwiki.test.ui.po.editor.WikiEditPage; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@version |
39 |
|
@since |
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (29) |
Complexity: 2 |
Complexity Density: 0.07 |
|
41 |
|
public class PreviewTest extends AbstractTest |
42 |
|
{ |
43 |
|
@Rule |
44 |
|
public AdminAuthenticationRule adminAuthenticationRule = new AdminAuthenticationRule(getUtil()); |
45 |
|
|
46 |
|
|
47 |
|
@see |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
49 |
1 |
@Test... |
50 |
|
public void previewWithProgrammingRights() |
51 |
|
{ |
52 |
1 |
WikiEditPage wikiEditPage = WikiEditPage.gotoPage(getTestClassName(), getTestMethodName()); |
53 |
1 |
wikiEditPage.setContent("{{velocity}}$xwiki.hasAccessLevel('programming')" |
54 |
|
+ " $tdoc.author $tdoc.contentAuthor $tdoc.creator{{/velocity}}"); |
55 |
1 |
PreviewEditPage previewPage = wikiEditPage.clickPreview(); |
56 |
1 |
assertEquals("true XWiki.Admin XWiki.Admin XWiki.Admin", previewPage.getContent()); |
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
@see |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (23) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
62 |
1 |
@Test... |
63 |
|
public void previewWithSheet() throws Exception |
64 |
|
{ |
65 |
|
|
66 |
1 |
getUtil().rest().deletePage(getTestClassName(), getTestMethodName() + "Class"); |
67 |
1 |
ClassEditPage classEditor = ClassEditPage.gotoPage(getTestClassName(), getTestMethodName() + "Class"); |
68 |
1 |
classEditor.addProperty("color", "String"); |
69 |
|
|
70 |
|
|
71 |
1 |
getUtil().rest().savePage(new LocalDocumentReference(getTestClassName(), getTestMethodName() + "Sheet"), |
72 |
|
"{{velocity}}$doc.display('color'){{/velocity}}", ""); |
73 |
|
|
74 |
|
|
75 |
1 |
ObjectEditPage objectEditor = ObjectEditPage.gotoPage(getTestClassName(), getTestMethodName() + "Class"); |
76 |
1 |
ObjectEditPane objectEditPane = objectEditor.addObject("XWiki.ClassSheetBinding"); |
77 |
1 |
objectEditPane.setFieldValue(objectEditPane.byPropertyName("sheet"), getTestClassName() + "." |
78 |
|
+ getTestMethodName() + "Sheet"); |
79 |
1 |
objectEditor.clickSaveAndContinue(); |
80 |
|
|
81 |
|
|
82 |
1 |
String classFullName = getTestClassName() + "." + getTestMethodName() + "Class"; |
83 |
1 |
getUtil().rest().deletePage(getTestClassName(), getTestMethodName() + "Template"); |
84 |
1 |
objectEditor = ObjectEditPage.gotoPage(getTestClassName(), getTestMethodName() + "Template"); |
85 |
1 |
objectEditPane = objectEditor.addObject(classFullName); |
86 |
1 |
objectEditPane.setFieldValue(objectEditPane.byPropertyName("color"), "red"); |
87 |
1 |
objectEditor.clickSaveAndContinue(); |
88 |
|
|
89 |
|
|
90 |
1 |
getUtil().rest().deletePage(getTestClassName(), getTestMethodName()); |
91 |
1 |
getUtil().gotoPage(getTestClassName(), getTestMethodName(), "edit", |
92 |
|
"template=" + getTestClassName() + "." + getTestMethodName() + "Template"); |
93 |
1 |
objectEditPane = new ObjectEditPane(new InlinePage().getForm(), classFullName, 0); |
94 |
1 |
objectEditPane.setFieldValue(objectEditPane.byPropertyName("color"), "green"); |
95 |
|
|
96 |
|
|
97 |
1 |
PreviewableEditPage editPage = new PreviewableEditPage(); |
98 |
1 |
PreviewEditPage previewPage = editPage.clickPreview(); |
99 |
1 |
assertEquals("green", previewPage.getContent()); |
100 |
|
|
101 |
|
|
102 |
1 |
previewPage.clickBackToEdit().clickSaveAndView().editInline().clickPreview(); |
103 |
1 |
assertEquals("green", previewPage.getContent()); |
104 |
|
} |
105 |
|
} |