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 org.junit.*; |
23 |
|
import org.xwiki.administration.test.po.PageElementsAdministrationSectionPage; |
24 |
|
import org.xwiki.panels.test.po.ApplicationsPanel; |
25 |
|
import org.xwiki.panels.test.po.PageWithPanels; |
26 |
|
import org.xwiki.panels.test.po.PanelEditPage; |
27 |
|
import org.xwiki.panels.test.po.PanelsHomePage; |
28 |
|
import org.xwiki.test.ui.AbstractTest; |
29 |
|
import org.xwiki.test.ui.SuperAdminAuthenticationRule; |
30 |
|
import org.xwiki.test.ui.po.EditRightsPane.Right; |
31 |
|
import org.xwiki.test.ui.po.EditRightsPane.State; |
32 |
|
import org.xwiki.test.ui.po.ViewPage; |
33 |
|
import org.xwiki.test.ui.po.editor.RightsEditPage; |
34 |
|
import org.xwiki.text.StringUtils; |
35 |
|
|
36 |
|
import static org.junit.Assert.*; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@version |
42 |
|
@since |
43 |
|
|
|
|
| 97.8% |
Uncovered Elements: 1 (46) |
Complexity: 5 |
Complexity Density: 0.12 |
|
44 |
|
public class PanelTest extends AbstractTest |
45 |
|
{ |
46 |
|
@Rule |
47 |
|
public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil()); |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
49 |
1 |
@Test... |
50 |
|
public void verifyApplicationsPanelEntry() |
51 |
|
{ |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
1 |
ApplicationsPanel applicationPanel = ApplicationsPanel.gotoPage(); |
56 |
1 |
ViewPage vp = applicationPanel.clickApplication("Panels"); |
57 |
|
|
58 |
|
|
59 |
1 |
assertEquals(PanelsHomePage.getSpace(), vp.getMetaDataValue("space")); |
60 |
1 |
assertEquals(PanelsHomePage.getPage(), vp.getMetaDataValue("page")); |
61 |
|
|
62 |
|
|
63 |
1 |
getUtil().forceGuestUser(); |
64 |
|
|
65 |
1 |
applicationPanel = ApplicationsPanel.gotoPage(); |
66 |
1 |
assertFalse(applicationPanel.containsApplication("Panels")); |
67 |
|
} |
68 |
|
|
69 |
|
|
70 |
|
@see |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
72 |
1 |
@Test... |
73 |
|
public void addPanelWithSpacesInName() |
74 |
|
{ |
75 |
|
|
76 |
1 |
String panelName = "My First Panel"; |
77 |
1 |
getUtil().deletePage("Panels", panelName); |
78 |
|
|
79 |
|
|
80 |
1 |
PanelEditPage panelEditPage = PanelsHomePage.gotoPage().createPanel(panelName); |
81 |
1 |
panelEditPage.setContent(String.format(PanelEditPage.DEFAULT_CONTENT_FORMAT, panelName, getTestMethodName())); |
82 |
1 |
panelEditPage.clickSaveAndContinue(); |
83 |
|
|
84 |
|
|
85 |
1 |
setRightPanelInAdministration(panelName); |
86 |
1 |
assertTrue(new PageWithPanels().hasPanel(panelName)); |
87 |
|
} |
88 |
|
|
89 |
|
|
90 |
|
@see |
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
92 |
1 |
@Test... |
93 |
|
public void limitPanelViewRight() |
94 |
|
{ |
95 |
|
|
96 |
1 |
String panelName = getTestMethodName(); |
97 |
1 |
getUtil().deletePage("Panels", panelName); |
98 |
|
|
99 |
|
|
100 |
1 |
String userName = String.format("%s%s", getTestClassName(), getTestMethodName()); |
101 |
1 |
getUtil().createUser(userName, "password", getUtil().getURLToNonExistentPage()); |
102 |
|
|
103 |
|
|
104 |
1 |
PanelEditPage panelEditPage = PanelsHomePage.gotoPage().createPanel(panelName); |
105 |
1 |
panelEditPage.setContent(String.format(PanelEditPage.DEFAULT_CONTENT_FORMAT, panelName, "Panel content.")); |
106 |
1 |
panelEditPage.clickSaveAndContinue(); |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
1 |
setRightPanelInAdministration(panelName); |
111 |
|
|
112 |
|
|
113 |
1 |
assertTrue(new PageWithPanels().hasPanel(panelName)); |
114 |
|
|
115 |
|
|
116 |
1 |
getUtil().gotoPage(getTestClassName(), getTestMethodName()); |
117 |
1 |
getUtil().forceGuestUser(); |
118 |
1 |
assertTrue(new PageWithPanels().hasPanel(panelName)); |
119 |
|
|
120 |
|
|
121 |
1 |
this.authenticationRule.authenticate(); |
122 |
1 |
RightsEditPage rightsEditor = getUtil().gotoPage("Panels", panelName).editRights(); |
123 |
1 |
rightsEditor.switchToUsers(); |
124 |
|
|
125 |
1 |
rightsEditor.setRight(userName, Right.VIEW, State.ALLOW); |
126 |
|
|
127 |
|
|
128 |
1 |
getUtil().loginAndGotoPage(userName, "password", getUtil().getURL(getTestClassName(), getTestMethodName())); |
129 |
1 |
assertTrue(new PageWithPanels().hasPanel(panelName)); |
130 |
1 |
getUtil().forceGuestUser(); |
131 |
1 |
assertFalse(new PageWithPanels().hasPanel(panelName)); |
132 |
|
} |
133 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
134 |
2 |
private void setRightPanelInAdministration(String panelName)... |
135 |
|
{ |
136 |
2 |
PageElementsAdministrationSectionPage peasp = PageElementsAdministrationSectionPage.gotoPage(); |
137 |
2 |
String rightPanels = peasp.getRightPanels(); |
138 |
2 |
String newPanelString = "Panels." + panelName; |
139 |
2 |
if (!rightPanels.contains(newPanelString)) { |
140 |
2 |
peasp.setRightPanels(StringUtils.join(new Object[]{ rightPanels, newPanelString }, ',')); |
141 |
|
} |
142 |
2 |
peasp.clickSave(); |
143 |
|
} |
144 |
|
} |