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 org.junit.Assert; |
23 |
|
import org.junit.Before; |
24 |
|
import org.junit.Rule; |
25 |
|
import org.junit.Test; |
26 |
|
import org.xwiki.test.ui.po.CommentForm; |
27 |
|
import org.xwiki.test.ui.po.CommentsTab; |
28 |
|
import org.xwiki.test.ui.po.ViewPage; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@version |
34 |
|
@since |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (45) |
Complexity: 8 |
Complexity Density: 0.22 |
|
36 |
|
public class CommentAsAdminTest extends AbstractTest |
37 |
|
{ |
38 |
|
@Rule |
39 |
|
public AdminAuthenticationRule adminAuthenticationRule = new AdminAuthenticationRule(getUtil()); |
40 |
|
|
41 |
|
private CommentsTab commentsTab; |
42 |
|
|
43 |
|
private static final String CONTENT = "Some dummy Content"; |
44 |
|
|
45 |
|
private static final String TITLE = "CommentsTest Page"; |
46 |
|
|
47 |
|
private static final String COMMENT_CONTENT = "Some content"; |
48 |
|
|
49 |
|
private static final String COMMENT_REPLACED_CONTENT = "Some replaced content"; |
50 |
|
|
51 |
|
private static final String ADMIN = "Administrator"; |
52 |
|
|
53 |
|
private static final String COMMENT_REPLY = "Comment Reply"; |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
55 |
7 |
@Before... |
56 |
|
public void setUp() throws Exception |
57 |
|
{ |
58 |
7 |
getUtil().rest().deletePage(getTestClassName(), getTestMethodName()); |
59 |
7 |
ViewPage vp = getUtil().createPage(getTestClassName(), getTestMethodName(), CONTENT, TITLE); |
60 |
7 |
this.commentsTab = vp.openCommentsDocExtraPane(); |
61 |
|
} |
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
63 |
1 |
@Test... |
64 |
|
public void testPostCommentAsAdmin() |
65 |
|
{ |
66 |
1 |
Assert.assertTrue(this.commentsTab.isCommentFormShown()); |
67 |
1 |
this.commentsTab.postComment(COMMENT_CONTENT, true); |
68 |
1 |
Assert.assertEquals(COMMENT_CONTENT, |
69 |
|
this.commentsTab.getCommentContentByID(this.commentsTab.getCommentID(COMMENT_CONTENT))); |
70 |
1 |
Assert.assertEquals(ADMIN, |
71 |
|
this.commentsTab.getCommentAuthorByID(this.commentsTab.getCommentID(COMMENT_CONTENT))); |
72 |
|
} |
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
74 |
1 |
@Test... |
75 |
|
public void testReplyToCommentAsAdmin() |
76 |
|
{ |
77 |
1 |
this.commentsTab.postComment(COMMENT_CONTENT, true); |
78 |
1 |
this.commentsTab.replyToCommentByID(this.commentsTab.getCommentID(COMMENT_CONTENT), COMMENT_REPLY); |
79 |
1 |
Assert.assertEquals(COMMENT_REPLY, |
80 |
|
this.commentsTab.getCommentContentByID(this.commentsTab.getCommentID(COMMENT_REPLY))); |
81 |
1 |
Assert.assertEquals(ADMIN, this.commentsTab.getCommentAuthorByID(this.commentsTab.getCommentID(COMMENT_REPLY))); |
82 |
|
} |
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
84 |
1 |
@Test... |
85 |
|
public void testDeleteCommentAsAdmin() |
86 |
|
{ |
87 |
1 |
Assert.assertTrue(this.commentsTab.isCommentFormShown()); |
88 |
1 |
this.commentsTab.postComment(COMMENT_CONTENT, true); |
89 |
1 |
this.commentsTab.deleteCommentByID(this.commentsTab.getCommentID(COMMENT_CONTENT)); |
90 |
1 |
Assert.assertTrue(this.commentsTab.getCommentID(COMMENT_CONTENT) == -1); |
91 |
|
} |
92 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
93 |
1 |
@Test... |
94 |
|
public void testEditCommentAsAdmin() |
95 |
|
{ |
96 |
1 |
Assert.assertTrue(this.commentsTab.isCommentFormShown()); |
97 |
1 |
this.commentsTab.postComment(COMMENT_CONTENT, true); |
98 |
1 |
this.commentsTab.editCommentByID(0, COMMENT_REPLACED_CONTENT); |
99 |
1 |
Assert.assertEquals(COMMENT_REPLACED_CONTENT, |
100 |
|
this.commentsTab.getCommentContentByID(this.commentsTab.getCommentID(COMMENT_REPLACED_CONTENT))); |
101 |
|
} |
102 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
103 |
1 |
@Test... |
104 |
|
public void testPostCommentAsAdminNoJs() |
105 |
|
{ |
106 |
|
|
107 |
1 |
getUtil().gotoPage(getTestClassName(), getTestMethodName(), "view", "xpage=xpart&vm=commentsinline.vm"); |
108 |
1 |
this.commentsTab.postComment(COMMENT_CONTENT, false); |
109 |
1 |
ViewPage vp = new ViewPage(); |
110 |
|
|
111 |
1 |
vp.waitUntilPageIsLoaded(); |
112 |
1 |
Assert.assertEquals(COMMENT_CONTENT, |
113 |
|
this.commentsTab.getCommentContentByID(this.commentsTab.getCommentID(COMMENT_CONTENT))); |
114 |
1 |
Assert.assertEquals(ADMIN, |
115 |
|
this.commentsTab.getCommentAuthorByID(this.commentsTab.getCommentID(COMMENT_CONTENT))); |
116 |
|
} |
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
121 |
1 |
@Test... |
122 |
|
public void testPreviewComment() |
123 |
|
{ |
124 |
1 |
CommentForm addCommentForm = commentsTab.getAddCommentForm(); |
125 |
1 |
addCommentForm.getContentField().sendKeys("one **two** three"); |
126 |
1 |
Assert.assertEquals("one two three", addCommentForm.clickPreview().getText()); |
127 |
1 |
addCommentForm.clickBack(); |
128 |
1 |
addCommentForm.getContentField().sendKeys(" //four//"); |
129 |
1 |
addCommentForm.clickPreview(); |
130 |
1 |
addCommentForm.clickSubmit(); |
131 |
1 |
Assert.assertTrue(commentsTab.getCommentID("one two three four") >= 0); |
132 |
|
} |
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
137 |
1 |
@Test... |
138 |
|
public void testPreviewCommentOnPageWithSheet() |
139 |
|
{ |
140 |
|
|
141 |
1 |
commentsTab = getUtil().gotoPage("Blog", "BlogIntroduction").openCommentsDocExtraPane(); |
142 |
1 |
CommentForm addCommentForm = commentsTab.getAddCommentForm(); |
143 |
1 |
addCommentForm.getContentField().sendKeys("xyz"); |
144 |
1 |
Assert.assertEquals("xyz", addCommentForm.clickPreview().getText()); |
145 |
|
} |
146 |
|
} |