1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.panels.test.ui; |
21 |
|
|
22 |
|
import java.util.Arrays; |
23 |
|
import java.util.Iterator; |
24 |
|
import java.util.List; |
25 |
|
|
26 |
|
import org.junit.Rule; |
27 |
|
import org.junit.Test; |
28 |
|
import org.openqa.selenium.WebElement; |
29 |
|
import org.xwiki.model.reference.LocalDocumentReference; |
30 |
|
import org.xwiki.panels.test.po.ApplicationsPanel; |
31 |
|
import org.xwiki.panels.test.po.ApplicationsPanelAdministrationPage; |
32 |
|
import org.xwiki.test.ui.AbstractTest; |
33 |
|
import org.xwiki.test.ui.SuperAdminAuthenticationRule; |
34 |
|
import org.xwiki.test.ui.po.ViewPage; |
35 |
|
import org.xwiki.test.ui.po.editor.ObjectEditPage; |
36 |
|
import org.xwiki.test.ui.po.editor.ObjectEditPane; |
37 |
|
|
38 |
|
import static org.junit.Assert.assertEquals; |
39 |
|
import static org.junit.Assert.assertFalse; |
40 |
|
import static org.junit.Assert.assertTrue; |
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
@version |
46 |
|
@since |
47 |
|
@since |
48 |
|
@since |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (78) |
Complexity: 8 |
Complexity Density: 0.11 |
|
50 |
|
public class ApplicationsPanelAdministrationTest extends AbstractTest |
51 |
|
{ |
52 |
|
@Rule |
53 |
|
public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil()); |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (35) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
55 |
1 |
@Test... |
56 |
|
public void testApplicationsPanelAdministration() throws Exception |
57 |
|
{ |
58 |
1 |
createApplicationUIXs(); |
59 |
|
|
60 |
|
|
61 |
1 |
checkInitialState(ApplicationsPanel.gotoPage()); |
62 |
|
|
63 |
|
|
64 |
1 |
ApplicationsPanelAdministrationPage appPanelAdminPage = ApplicationsPanelAdministrationPage.gotoPage(); |
65 |
|
|
66 |
|
|
67 |
1 |
checkInitialState(appPanelAdminPage); |
68 |
|
|
69 |
|
|
70 |
1 |
applyChanges(appPanelAdminPage); |
71 |
1 |
appPanelAdminPage.revert(); |
72 |
1 |
checkInitialState(appPanelAdminPage); |
73 |
|
|
74 |
|
|
75 |
1 |
applyChanges(appPanelAdminPage); |
76 |
1 |
appPanelAdminPage.save(); |
77 |
1 |
assertTrue(appPanelAdminPage.hasSuccessNotification()); |
78 |
|
|
79 |
|
|
80 |
1 |
ApplicationsPanel applicationsPanel = ApplicationsPanel.gotoPage(); |
81 |
1 |
List<String> applications = applicationsPanel.getApplications(); |
82 |
1 |
assertEquals(3, applications.size()); |
83 |
1 |
Iterator<String> iterator = applications.iterator(); |
84 |
1 |
assertEquals("App3", iterator.next()); |
85 |
1 |
assertEquals("App1", iterator.next()); |
86 |
1 |
assertEquals("App2", iterator.next()); |
87 |
|
|
88 |
|
|
89 |
1 |
appPanelAdminPage = ApplicationsPanelAdministrationPage.gotoPage(); |
90 |
1 |
assertFalse(appPanelAdminPage.getApplicationsInBar().contains("Panels")); |
91 |
1 |
assertTrue(appPanelAdminPage.getApplicationsNotInBar().contains("Panels")); |
92 |
1 |
iterator = appPanelAdminPage.getApplicationsInBar().iterator(); |
93 |
1 |
assertEquals("App3", iterator.next()); |
94 |
1 |
assertEquals("App1", iterator.next()); |
95 |
1 |
assertEquals("App2", iterator.next()); |
96 |
|
|
97 |
|
|
98 |
1 |
appPanelAdminPage.addApplicationInBar("Panels"); |
99 |
1 |
assertTrue(appPanelAdminPage.getApplicationsInBar().contains("Panels")); |
100 |
1 |
assertFalse(appPanelAdminPage.getApplicationsNotInBar().contains("Panels")); |
101 |
|
|
102 |
|
|
103 |
1 |
appPanelAdminPage.moveAppBefore("App1", appPanelAdminPage.getApplicationsInBar().get(0)); |
104 |
1 |
appPanelAdminPage.moveAppBefore("App2", appPanelAdminPage.getApplicationsInBar().get(1)); |
105 |
1 |
appPanelAdminPage.moveAppBefore("App3", appPanelAdminPage.getApplicationsInBar().get(2)); |
106 |
|
|
107 |
|
|
108 |
1 |
appPanelAdminPage.save(); |
109 |
1 |
assertTrue(appPanelAdminPage.hasSuccessNotification()); |
110 |
|
|
111 |
|
|
112 |
1 |
checkInitialState(ApplicationsPanel.gotoPage()); |
113 |
|
|
114 |
|
|
115 |
1 |
checkInitialState(ApplicationsPanelAdministrationPage.gotoPage()); |
116 |
|
|
117 |
|
|
118 |
1 |
cleanUp(); |
119 |
|
} |
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
121 |
1 |
private void createApplicationUIXs()... |
122 |
|
{ |
123 |
1 |
createApplicationUIX("App1"); |
124 |
1 |
createApplicationUIX("App2"); |
125 |
1 |
createApplicationUIX("App3"); |
126 |
|
} |
127 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
128 |
3 |
private void createApplicationUIX(String applicationName)... |
129 |
|
{ |
130 |
3 |
ViewPage page = getUtil().gotoPage("Apps", applicationName); |
131 |
3 |
ObjectEditPage editPage = page.editObjects(); |
132 |
3 |
ObjectEditPane object = editPage.addObject("XWiki.UIExtensionClass"); |
133 |
3 |
fillField(object, "extensionPointId", "org.xwiki.platform.panels.Applications"); |
134 |
3 |
fillField(object, "name", applicationName); |
135 |
3 |
fillField(object, "parameters", |
136 |
|
String.format("label=%s\ntarget=Apps.%s\nicon=icon:home", applicationName, applicationName)); |
137 |
3 |
editPage.clickSaveAndView(); |
138 |
|
} |
139 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
140 |
3 |
private void checkInitialState(ApplicationsPanelAdministrationPage appPanelAdminPage) throws Exception... |
141 |
|
{ |
142 |
3 |
assertEquals(4, appPanelAdminPage.getApplicationsInBar().size()); |
143 |
3 |
assertTrue(appPanelAdminPage.getApplicationsNotInBar().isEmpty()); |
144 |
|
|
145 |
|
|
146 |
3 |
Iterator<String> iterator = appPanelAdminPage.getApplicationsInBar().iterator(); |
147 |
3 |
assertEquals("App1", iterator.next()); |
148 |
3 |
assertEquals("App2", iterator.next()); |
149 |
3 |
assertEquals("App3", iterator.next()); |
150 |
3 |
assertEquals("Panels", iterator.next()); |
151 |
|
} |
152 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
153 |
2 |
private void checkInitialState(ApplicationsPanel applicationsPanel) throws Exception... |
154 |
|
{ |
155 |
2 |
List<String> applications = applicationsPanel.getApplications(); |
156 |
2 |
assertEquals(4, applications.size()); |
157 |
2 |
Iterator<String> iterator = applications.iterator(); |
158 |
2 |
assertEquals("App1", iterator.next()); |
159 |
2 |
assertEquals("App2", iterator.next()); |
160 |
2 |
assertEquals("App3", iterator.next()); |
161 |
2 |
assertEquals("Panels", iterator.next()); |
162 |
|
} |
163 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
164 |
2 |
private void applyChanges(ApplicationsPanelAdministrationPage appPanelAdminPage) throws Exception... |
165 |
|
{ |
166 |
|
|
167 |
2 |
appPanelAdminPage.removeApplicationFromBar("Panels"); |
168 |
2 |
assertFalse(appPanelAdminPage.getApplicationsInBar().contains("Panels")); |
169 |
2 |
assertTrue(appPanelAdminPage.getApplicationsNotInBar().contains("Panels")); |
170 |
|
|
171 |
|
|
172 |
2 |
appPanelAdminPage.moveAppBefore("App3", "App1"); |
173 |
|
} |
174 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
175 |
9 |
private void fillField(ObjectEditPane object, String propertyName, String value)... |
176 |
|
{ |
177 |
9 |
WebElement field = getDriver().findElement(object.byPropertyName(propertyName)); |
178 |
9 |
field.clear(); |
179 |
9 |
field.sendKeys(value); |
180 |
|
} |
181 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
182 |
1 |
private void cleanUp() throws Exception... |
183 |
|
{ |
184 |
1 |
getUtil().rest().delete( |
185 |
|
new LocalDocumentReference(Arrays.asList("Apps", "App1"), "WebHome")); |
186 |
1 |
getUtil().rest().delete( |
187 |
|
new LocalDocumentReference(Arrays.asList("Apps", "App2"), "WebHome")); |
188 |
1 |
getUtil().rest().delete( |
189 |
|
new LocalDocumentReference(Arrays.asList("Apps", "App3"), "WebHome")); |
190 |
1 |
getUtil().rest().delete( |
191 |
|
new LocalDocumentReference(Arrays.asList("PanelsCode"), "ApplicationsPanelConfiguration")); |
192 |
|
} |
193 |
|
} |