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.BeforeClass; |
25 |
|
import org.junit.ClassRule; |
26 |
|
import org.junit.Rule; |
27 |
|
import org.junit.Test; |
28 |
|
import org.xwiki.administration.test.po.GlobalRightsAdministrationSectionPage; |
29 |
|
import org.xwiki.test.ui.browser.IgnoreBrowser; |
30 |
|
import org.xwiki.test.ui.browser.IgnoreBrowsers; |
31 |
|
import org.xwiki.test.ui.po.CommentsTab; |
32 |
|
import org.xwiki.test.ui.po.EditRightsPane.Right; |
33 |
|
import org.xwiki.test.ui.po.EditRightsPane.State; |
34 |
|
import org.xwiki.test.ui.po.ViewPage; |
35 |
|
|
36 |
|
|
37 |
|
@version |
38 |
|
@since |
39 |
|
|
|
|
| 0% |
Uncovered Elements: 34 (34) |
Complexity: 7 |
Complexity Density: 0.26 |
|
40 |
|
public class CommentAsGuestTest extends AbstractTest |
41 |
|
{ |
42 |
|
@ClassRule |
43 |
|
public static AdminAuthenticationRule adminAuthenticationClassRule = new AdminAuthenticationRule(getUtil()); |
44 |
|
|
45 |
|
@Rule |
46 |
|
public AdminAuthenticationRule adminAuthenticationRule = new AdminAuthenticationRule(getUtil()); |
47 |
|
|
48 |
|
private static final String CONTENT = "Some dummy Content"; |
49 |
|
|
50 |
|
private static final String TITLE = "CommentsTest Page"; |
51 |
|
|
52 |
|
private static final String COMMENT_CONTENT = "Some content"; |
53 |
|
|
54 |
|
private static final String COMMENT_AUTHOR = "Anonymous"; |
55 |
|
|
56 |
|
private static final String COMMENT_REPLY = "Comment Reply"; |
57 |
|
|
58 |
|
private ViewPage vp; |
59 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
60 |
0 |
@BeforeClass... |
61 |
|
public static void initializeCommentRights() |
62 |
|
{ |
63 |
|
|
64 |
0 |
setRightsOnGuest(Right.COMMENT, State.ALLOW); |
65 |
|
} |
66 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
67 |
0 |
@Before... |
68 |
|
public void setUp() throws Exception |
69 |
|
{ |
70 |
0 |
getUtil().rest().deletePage(getTestClassName(), getTestMethodName()); |
71 |
0 |
this.vp = getUtil().createPage(getTestClassName(), getTestMethodName(), CONTENT, TITLE); |
72 |
|
|
73 |
|
|
74 |
0 |
getUtil().forceGuestUser(); |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
0 |
getDriver().navigate().refresh(); |
80 |
|
} |
81 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
82 |
0 |
private static void setRightsOnGuest(Right right, State state)... |
83 |
|
{ |
84 |
0 |
GlobalRightsAdministrationSectionPage globalRights = GlobalRightsAdministrationSectionPage.gotoPage(); |
85 |
|
|
86 |
0 |
globalRights.getEditRightsPane().getRightsTable().waitUntilReady(); |
87 |
0 |
globalRights.getEditRightsPane().switchToUsers(); |
88 |
0 |
globalRights.getEditRightsPane().setGuestRight(right, state); |
89 |
|
} |
90 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
4-
|
|
91 |
0 |
@Test... |
92 |
|
@IgnoreBrowsers({ |
93 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
94 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
95 |
|
}) |
96 |
|
public void testPostCommentAsGuest() |
97 |
|
{ |
98 |
0 |
CommentsTab commentsTab = this.vp.openCommentsDocExtraPane(); |
99 |
|
|
100 |
0 |
commentsTab.postCommentAsGuest(COMMENT_CONTENT, COMMENT_AUTHOR, true); |
101 |
0 |
Assert.assertEquals(COMMENT_CONTENT, commentsTab.getCommentContentByID(0)); |
102 |
0 |
Assert.assertEquals(COMMENT_AUTHOR, commentsTab.getCommentAuthorByID(0)); |
103 |
|
} |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
4-
|
|
105 |
0 |
@Test... |
106 |
|
@IgnoreBrowsers({ |
107 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
108 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
109 |
|
}) |
110 |
|
public void testPostCommentAsGuestNoJs() |
111 |
|
{ |
112 |
0 |
getUtil().gotoPage(getTestClassName(), getTestMethodName(), "view", "xpage=xpart&vm=commentsinline.vm"); |
113 |
0 |
CommentsTab commentsTab = new CommentsTab(); |
114 |
|
|
115 |
0 |
commentsTab.postComment(COMMENT_CONTENT, false); |
116 |
|
|
117 |
0 |
new ViewPage().waitUntilPageIsLoaded(); |
118 |
0 |
Assert.assertEquals(COMMENT_CONTENT, |
119 |
|
commentsTab.getCommentContentByID(commentsTab.getCommentID(COMMENT_CONTENT))); |
120 |
0 |
Assert.assertEquals(COMMENT_AUTHOR, |
121 |
|
commentsTab.getCommentAuthorByID(commentsTab.getCommentID(COMMENT_CONTENT))); |
122 |
|
} |
123 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
4-
|
|
124 |
0 |
@Test... |
125 |
|
@IgnoreBrowsers({ |
126 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
127 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
128 |
|
}) |
129 |
|
public void testReplyCommentAsAnonymous() |
130 |
|
{ |
131 |
0 |
CommentsTab commentsTab = this.vp.openCommentsDocExtraPane(); |
132 |
|
|
133 |
0 |
commentsTab.postCommentAsGuest(COMMENT_CONTENT, COMMENT_AUTHOR, true); |
134 |
0 |
commentsTab.replyToCommentByID(commentsTab.getCommentID(COMMENT_CONTENT), COMMENT_REPLY); |
135 |
0 |
Assert.assertEquals(COMMENT_REPLY, |
136 |
|
commentsTab.getCommentContentByID(commentsTab.getCommentID(COMMENT_REPLY))); |
137 |
0 |
Assert.assertEquals(COMMENT_AUTHOR, |
138 |
|
commentsTab.getCommentAuthorByID(commentsTab.getCommentID(COMMENT_REPLY))); |
139 |
|
} |
140 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
4-
|
|
141 |
0 |
@Test... |
142 |
|
@IgnoreBrowsers({ |
143 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
144 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
145 |
|
}) |
146 |
|
public void testCannotEditCommentAsAnonymous() |
147 |
|
{ |
148 |
0 |
CommentsTab commentsTab = this.vp.openCommentsDocExtraPane(); |
149 |
0 |
commentsTab.postCommentAsGuest(COMMENT_CONTENT, COMMENT_AUTHOR, true); |
150 |
0 |
Assert.assertFalse(commentsTab.hasEditButtonForCommentByID(commentsTab.getCommentID(COMMENT_CONTENT))); |
151 |
|
} |
152 |
|
} |