1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.administration.test.ui; |
21 |
|
|
22 |
|
import java.net.URL; |
23 |
|
|
24 |
|
import org.junit.*; |
25 |
|
import org.openqa.selenium.By; |
26 |
|
import org.openqa.selenium.WebElement; |
27 |
|
import org.xwiki.administration.test.po.AdministrationPage; |
28 |
|
import org.xwiki.administration.test.po.ImportAdministrationSectionPage; |
29 |
|
import org.xwiki.test.ui.AbstractTest; |
30 |
|
import org.xwiki.test.ui.SuperAdminAuthenticationRule; |
31 |
|
import org.xwiki.test.ui.browser.IgnoreBrowser; |
32 |
|
import org.xwiki.test.ui.browser.IgnoreBrowsers; |
33 |
|
import org.xwiki.test.ui.po.HistoryPane; |
34 |
|
import org.xwiki.test.ui.po.ViewPage; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
@version |
40 |
|
@since |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (63) |
Complexity: 9 |
Complexity Density: 0.18 |
|
42 |
|
public class ImportTest extends AbstractTest |
43 |
|
{ |
44 |
|
@Rule |
45 |
|
public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil()); |
46 |
|
|
47 |
|
private static final String PACKAGE_WITHOUT_HISTORY = "Main.TestPage-no-history.xar"; |
48 |
|
|
49 |
|
private static final String PACKAGE_WITH_HISTORY = "Main.TestPage-with-history.xar"; |
50 |
|
|
51 |
|
private static final String BACKUP_PACKAGE = "Main.TestPage-backup.xar"; |
52 |
|
|
53 |
|
private AdministrationPage adminPage; |
54 |
|
|
55 |
|
private ImportAdministrationSectionPage sectionPage; |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 4 |
Complexity Density: 0.44 |
|
57 |
5 |
@Before... |
58 |
|
public void setUp() throws Exception |
59 |
|
{ |
60 |
|
|
61 |
5 |
getUtil().rest().deletePage("Main", "TestPage"); |
62 |
|
|
63 |
5 |
this.adminPage = AdministrationPage.gotoPage(); |
64 |
5 |
this.sectionPage = this.adminPage.clickImportSection(); |
65 |
|
|
66 |
|
|
67 |
5 |
if (this.sectionPage.isPackagePresent(PACKAGE_WITH_HISTORY)) { |
68 |
1 |
this.sectionPage.deletePackage(PACKAGE_WITH_HISTORY); |
69 |
|
} |
70 |
5 |
if (this.sectionPage.isPackagePresent(PACKAGE_WITHOUT_HISTORY)) { |
71 |
1 |
this.sectionPage.deletePackage(PACKAGE_WITHOUT_HISTORY); |
72 |
|
} |
73 |
5 |
if (this.sectionPage.isPackagePresent(BACKUP_PACKAGE)) { |
74 |
1 |
this.sectionPage.deletePackage(BACKUP_PACKAGE); |
75 |
|
} |
76 |
|
} |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
@since |
82 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1PASS
|
|
83 |
1 |
@Test... |
84 |
|
public void testImportHasNoPackageByDefault() |
85 |
|
{ |
86 |
1 |
Assert.assertEquals(0, this.sectionPage.getPackageNames().size()); |
87 |
|
} |
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
89 |
1 |
@Test... |
90 |
|
@IgnoreBrowsers({ |
91 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
92 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
93 |
|
}) |
94 |
|
public void testImportWithHistory() |
95 |
|
{ |
96 |
1 |
URL fileUrl = this.getClass().getResource("/" + PACKAGE_WITH_HISTORY); |
97 |
|
|
98 |
1 |
this.sectionPage.attachPackage(fileUrl); |
99 |
1 |
this.sectionPage.selectPackage(PACKAGE_WITH_HISTORY); |
100 |
|
|
101 |
1 |
this.sectionPage.selectReplaceHistoryOption(); |
102 |
1 |
this.sectionPage.importPackage(); |
103 |
|
|
104 |
1 |
ViewPage importedPage = this.sectionPage.clickImportedPage("Main.TestPage"); |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
1 |
importedPage.openCommentsDocExtraPane(); |
109 |
1 |
HistoryPane history = importedPage.openHistoryDocExtraPane(); |
110 |
|
|
111 |
1 |
Assert.assertEquals("3.1", history.getCurrentVersion()); |
112 |
1 |
Assert.assertEquals("A third version of the document", history.getCurrentVersionComment()); |
113 |
1 |
Assert.assertTrue(history.hasVersionWithSummary("A new version of the document")); |
114 |
|
} |
115 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
116 |
1 |
@Test... |
117 |
|
@IgnoreBrowsers({ |
118 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
119 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
120 |
|
}) |
121 |
|
public void testImportWithNewHistoryVersion() |
122 |
|
{ |
123 |
1 |
URL fileUrl = this.getClass().getResource("/" + PACKAGE_WITHOUT_HISTORY); |
124 |
|
|
125 |
1 |
this.sectionPage.attachPackage(fileUrl); |
126 |
1 |
this.sectionPage.selectPackage(PACKAGE_WITHOUT_HISTORY); |
127 |
|
|
128 |
1 |
this.sectionPage.importPackage(); |
129 |
|
|
130 |
1 |
ViewPage importedPage = this.sectionPage.clickImportedPage("Main.TestPage"); |
131 |
|
|
132 |
|
|
133 |
|
|
134 |
1 |
importedPage.openCommentsDocExtraPane(); |
135 |
1 |
HistoryPane history = importedPage.openHistoryDocExtraPane(); |
136 |
|
|
137 |
1 |
Assert.assertEquals("1.1", history.getCurrentVersion()); |
138 |
1 |
Assert.assertEquals("Imported from XAR", history.getCurrentVersionComment()); |
139 |
|
} |
140 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
141 |
1 |
@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 testImportAsBackup() |
147 |
|
{ |
148 |
1 |
URL fileUrl = this.getClass().getResource("/" + BACKUP_PACKAGE); |
149 |
|
|
150 |
1 |
this.sectionPage.attachPackage(fileUrl); |
151 |
1 |
this.sectionPage.selectPackage(BACKUP_PACKAGE); |
152 |
|
|
153 |
1 |
WebElement importAsBackup = getDriver().findElement(By.name("importAsBackup")); |
154 |
1 |
Assert.assertTrue(importAsBackup.isSelected()); |
155 |
|
|
156 |
1 |
this.sectionPage.importPackage(); |
157 |
|
|
158 |
1 |
ViewPage importedPage = this.sectionPage.clickImportedPage("Main.TestPage"); |
159 |
|
|
160 |
|
|
161 |
|
|
162 |
1 |
importedPage.openCommentsDocExtraPane(); |
163 |
1 |
HistoryPane history = importedPage.openHistoryDocExtraPane(); |
164 |
|
|
165 |
1 |
Assert.assertEquals("JohnDoe", history.getCurrentAuthor()); |
166 |
|
} |
167 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
168 |
1 |
@Test... |
169 |
|
@IgnoreBrowsers({ |
170 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
171 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
172 |
|
}) |
173 |
|
public void testImportWhenImportAsBackupIsNotSelected() |
174 |
|
{ |
175 |
1 |
URL fileUrl = this.getClass().getResource("/" + BACKUP_PACKAGE); |
176 |
|
|
177 |
1 |
this.sectionPage.attachPackage(fileUrl); |
178 |
1 |
this.sectionPage.selectPackage(BACKUP_PACKAGE); |
179 |
|
|
180 |
1 |
WebElement importAsBackup = getDriver().findElement(By.name("importAsBackup")); |
181 |
1 |
importAsBackup.click(); |
182 |
1 |
Assert.assertFalse(importAsBackup.isSelected()); |
183 |
|
|
184 |
1 |
this.sectionPage.importPackage(); |
185 |
|
|
186 |
1 |
ViewPage importedPage = this.sectionPage.clickImportedPage("Main.TestPage"); |
187 |
|
|
188 |
|
|
189 |
|
|
190 |
1 |
importedPage.openCommentsDocExtraPane(); |
191 |
1 |
HistoryPane history = importedPage.openHistoryDocExtraPane(); |
192 |
|
|
193 |
1 |
Assert.assertEquals("superadmin", history.getCurrentAuthor()); |
194 |
|
} |
195 |
|
} |