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 java.util.Arrays; |
23 |
|
|
24 |
|
import org.junit.Assert; |
25 |
|
import org.junit.Rule; |
26 |
|
import org.junit.Test; |
27 |
|
import org.xwiki.index.test.po.CopyPage; |
28 |
|
import org.xwiki.index.tree.test.po.DocumentPickerModal; |
29 |
|
import org.xwiki.model.reference.LocalDocumentReference; |
30 |
|
import org.xwiki.test.ui.browser.IgnoreBrowser; |
31 |
|
import org.xwiki.test.ui.po.AttachmentsPane; |
32 |
|
import org.xwiki.test.ui.po.CopyOrRenameStatusPage; |
33 |
|
import org.xwiki.test.ui.po.CopyOverwritePromptPage; |
34 |
|
import org.xwiki.test.ui.po.DocumentPicker; |
35 |
|
import org.xwiki.test.ui.po.ViewPage; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
@version |
41 |
|
@since |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (80) |
Complexity: 2 |
Complexity Density: 0.03 |
|
43 |
|
public class CopyPageTest extends AbstractTest |
44 |
|
{ |
45 |
|
@Rule |
46 |
|
public AdminAuthenticationRule adminAuthenticationRule = new AdminAuthenticationRule(getUtil()); |
47 |
|
|
48 |
|
private static final String PAGE_CONTENT = "This page is used for copying purposes"; |
49 |
|
|
50 |
|
private static final String OVERWRITTEN_PAGE_CONTENT = "This page is used for overwritten copy purposes"; |
51 |
|
|
52 |
|
private static final String COPY_SUCCESSFUL = "Done."; |
53 |
|
|
54 |
|
private static final String OVERWRITE_PROMPT1 = "Warning: The page "; |
55 |
|
|
56 |
|
private static final String OVERWRITE_PROMPT2 = |
57 |
|
" already exists. Are you sure you want to overwrite it (all its content would be lost)?"; |
58 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (36) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
59 |
1 |
@Test... |
60 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See http://jira.xwiki.org/browse/XE-1146") |
61 |
|
public void testCopyPage() throws Exception |
62 |
|
{ |
63 |
1 |
String sourceSpaceName = getTestClassName(); |
64 |
1 |
String sourcePageName = getTestMethodName(); |
65 |
1 |
String targetSpaceName = getTestClassName() + "Copy"; |
66 |
1 |
String targetPageName = getTestMethodName() + "Copy"; |
67 |
|
|
68 |
|
|
69 |
1 |
getUtil().rest().deletePage(sourceSpaceName, sourcePageName); |
70 |
1 |
getUtil().rest().deletePage(targetSpaceName, targetPageName); |
71 |
|
|
72 |
|
|
73 |
1 |
ViewPage viewPage = getUtil().createPage(sourceSpaceName, sourcePageName, PAGE_CONTENT, sourcePageName); |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
1 |
viewPage.waitForDocExtraPaneActive("comments"); |
78 |
1 |
AttachmentsPane attachmentsPane = viewPage.openAttachmentsDocExtraPane(); |
79 |
1 |
attachmentsPane.setFileToUpload(getClass().getResource("/image.gif").getPath()); |
80 |
1 |
attachmentsPane.waitForUploadToFinish("image.gif"); |
81 |
1 |
Assert.assertEquals("1.1", attachmentsPane.getLatestVersionOfAttachment("image.gif")); |
82 |
|
|
83 |
|
|
84 |
1 |
viewPage.copy(); |
85 |
1 |
CopyPage copyPage = new CopyPage(); |
86 |
|
|
87 |
|
|
88 |
1 |
Assert.assertEquals(Arrays.asList("", sourceSpaceName, sourcePageName), copyPage.getSourceLocation().getPath()); |
89 |
1 |
Assert.assertEquals(sourceSpaceName, copyPage.getSourceSpaceName()); |
90 |
1 |
Assert.assertEquals(sourcePageName, copyPage.getSourcePageName()); |
91 |
|
|
92 |
|
|
93 |
1 |
DocumentPicker documentPicker = copyPage.getDocumentPicker(); |
94 |
1 |
Assert.assertEquals(sourcePageName, documentPicker.getTitle()); |
95 |
1 |
Assert.assertEquals(Arrays.asList("", sourceSpaceName, sourcePageName), documentPicker.getLocation().getPath()); |
96 |
1 |
Assert.assertEquals(sourceSpaceName, copyPage.getTargetSpaceName()); |
97 |
1 |
Assert.assertEquals(sourcePageName, copyPage.getTargetPageName()); |
98 |
|
|
99 |
|
|
100 |
1 |
documentPicker.setTitle(targetPageName); |
101 |
|
|
102 |
1 |
Assert.assertEquals(targetPageName, copyPage.getTargetPageName()); |
103 |
1 |
documentPicker.waitForLocation(Arrays.asList("", sourceSpaceName, targetPageName)); |
104 |
|
|
105 |
1 |
documentPicker.toggleLocationAdvancedEdit().setParent(targetSpaceName); |
106 |
1 |
documentPicker.waitForLocation(Arrays.asList("", targetSpaceName, targetPageName)); |
107 |
|
|
108 |
|
|
109 |
1 |
CopyOrRenameStatusPage copyStatusPage = copyPage.clickCopyButton().waitUntilFinished(); |
110 |
|
|
111 |
|
|
112 |
1 |
Assert.assertEquals(COPY_SUCCESSFUL, copyStatusPage.getInfoMessage()); |
113 |
1 |
viewPage = copyStatusPage.gotoNewPage(); |
114 |
|
|
115 |
1 |
Assert.assertEquals(Arrays.asList("", targetSpaceName, targetPageName), viewPage.getBreadcrumb().getPath()); |
116 |
|
|
117 |
|
|
118 |
1 |
Assert.assertEquals(targetPageName, viewPage.getDocumentTitle()); |
119 |
1 |
Assert.assertEquals(PAGE_CONTENT, viewPage.getContent()); |
120 |
|
|
121 |
|
|
122 |
|
|
123 |
1 |
viewPage.waitForDocExtraPaneActive("comments"); |
124 |
1 |
attachmentsPane = viewPage.openAttachmentsDocExtraPane(); |
125 |
1 |
Assert.assertEquals("1.1", attachmentsPane.getLatestVersionOfAttachment("image.gif")); |
126 |
|
} |
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (42) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
128 |
1 |
@Test... |
129 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See http://jira.xwiki.org/browse/XE-1146") |
130 |
|
public void testCopyOverwritePage() throws Exception |
131 |
|
{ |
132 |
1 |
String sourceSpaceName = getTestClassName(); |
133 |
1 |
String sourcePageName = getTestMethodName(); |
134 |
1 |
String targetSpaceName = getTestClassName() + "Copy"; |
135 |
1 |
String targetPageName = getTestMethodName() + "Copy"; |
136 |
|
|
137 |
|
|
138 |
1 |
getUtil().rest().deletePage(sourceSpaceName, sourcePageName); |
139 |
1 |
getUtil().rest().deletePage(targetSpaceName, targetPageName); |
140 |
|
|
141 |
|
|
142 |
1 |
getUtil().rest().savePage(new LocalDocumentReference(targetSpaceName, targetPageName), |
143 |
|
OVERWRITTEN_PAGE_CONTENT, targetPageName); |
144 |
|
|
145 |
|
|
146 |
1 |
ViewPage viewPage = getUtil().createPage(sourceSpaceName, sourcePageName, PAGE_CONTENT, sourcePageName); |
147 |
|
|
148 |
|
|
149 |
1 |
viewPage.copy(); |
150 |
1 |
CopyPage copyPage = new CopyPage(); |
151 |
|
|
152 |
|
|
153 |
1 |
DocumentPicker documentPicker = copyPage.getDocumentPicker(); |
154 |
1 |
documentPicker.setTitle(targetPageName); |
155 |
1 |
documentPicker.browseDocuments(); |
156 |
1 |
DocumentPickerModal documentPickerModal = new DocumentPickerModal(); |
157 |
1 |
documentPickerModal.waitForDocumentSelected(sourceSpaceName, "WebHome").selectDocument(targetSpaceName, |
158 |
|
"WebHome"); |
159 |
1 |
documentPicker.waitForLocation(Arrays.asList("", targetSpaceName, targetPageName)); |
160 |
1 |
Assert.assertEquals(targetSpaceName, copyPage.getTargetSpaceName()); |
161 |
|
|
162 |
|
|
163 |
1 |
CopyOverwritePromptPage copyOverwritePrompt = copyPage.clickCopyButtonExpectingOverwritePrompt(); |
164 |
|
|
165 |
|
|
166 |
1 |
Assert.assertEquals(OVERWRITE_PROMPT1 + targetSpaceName + '.' + targetPageName + OVERWRITE_PROMPT2, |
167 |
|
copyOverwritePrompt.getWarningMessage()); |
168 |
|
|
169 |
|
|
170 |
1 |
viewPage = copyOverwritePrompt.clickCancelButton(); |
171 |
|
|
172 |
|
|
173 |
1 |
Assert.assertEquals(sourcePageName, viewPage.getDocumentTitle()); |
174 |
|
|
175 |
|
|
176 |
1 |
viewPage.copy(); |
177 |
1 |
copyPage = new CopyPage(); |
178 |
|
|
179 |
|
|
180 |
1 |
copyPage.getDocumentPicker().toggleLocationAdvancedEdit().setParent(targetSpaceName).setName(targetPageName); |
181 |
|
|
182 |
|
|
183 |
1 |
copyOverwritePrompt = copyPage.clickCopyButtonExpectingOverwritePrompt(); |
184 |
|
|
185 |
|
|
186 |
1 |
copyOverwritePrompt.clickChangeTargetButton(); |
187 |
1 |
copyPage = new CopyPage(); |
188 |
|
|
189 |
|
|
190 |
1 |
Assert.assertEquals(Arrays.asList("", sourceSpaceName, sourcePageName), copyPage.getSourceLocation().getPath()); |
191 |
1 |
Assert.assertEquals(sourceSpaceName, copyPage.getSourceSpaceName()); |
192 |
1 |
Assert.assertEquals(sourcePageName, copyPage.getSourcePageName()); |
193 |
|
|
194 |
|
|
195 |
1 |
documentPicker = copyPage.getDocumentPicker(); |
196 |
1 |
Assert.assertEquals(sourcePageName, documentPicker.getTitle()); |
197 |
1 |
Assert.assertEquals(Arrays.asList("", sourceSpaceName, sourcePageName), documentPicker.getLocation().getPath()); |
198 |
1 |
Assert.assertEquals(sourceSpaceName, copyPage.getTargetSpaceName()); |
199 |
1 |
Assert.assertEquals(sourcePageName, copyPage.getTargetPageName()); |
200 |
|
|
201 |
|
|
202 |
1 |
documentPicker.setTitle("My copy").toggleLocationAdvancedEdit().setParent(targetSpaceName) |
203 |
|
.setName(targetPageName); |
204 |
|
|
205 |
|
|
206 |
1 |
copyOverwritePrompt = copyPage.clickCopyButtonExpectingOverwritePrompt(); |
207 |
1 |
CopyOrRenameStatusPage copyStatusPage = copyOverwritePrompt.clickCopyButton().waitUntilFinished(); |
208 |
|
|
209 |
|
|
210 |
1 |
Assert.assertEquals(COPY_SUCCESSFUL, copyStatusPage.getInfoMessage()); |
211 |
1 |
viewPage = copyStatusPage.gotoNewPage(); |
212 |
|
|
213 |
|
|
214 |
1 |
Assert.assertEquals("My copy", viewPage.getDocumentTitle()); |
215 |
1 |
Assert.assertEquals(PAGE_CONTENT, viewPage.getContent()); |
216 |
|
} |
217 |
|
} |