1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.test.wysiwyg; |
21 |
|
|
22 |
|
import java.util.Arrays; |
23 |
|
|
24 |
|
import org.junit.Test; |
25 |
|
import org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase; |
26 |
|
import org.xwiki.test.wysiwyg.framework.XWikiExplorer; |
27 |
|
|
28 |
|
import static org.junit.Assert.*; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (73) |
Complexity: 10 |
Complexity Density: 0.16 |
|
33 |
|
public class RegularUserTest extends AbstractWysiwygTestCase |
34 |
|
{ |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
private XWikiExplorer explorer; |
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
40 |
3 |
@Override... |
41 |
|
public void setUp() |
42 |
|
{ |
43 |
3 |
super.setUp(); |
44 |
|
|
45 |
3 |
this.explorer = new XWikiExplorer(getDriver()); |
46 |
|
} |
47 |
|
|
48 |
|
|
49 |
|
@inheritDoc |
50 |
|
|
51 |
|
|
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
53 |
3 |
@Override... |
54 |
|
protected void login() |
55 |
|
{ |
56 |
3 |
loginAndRegisterUser("Pokemon", "Pokemon", false); |
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
65 |
1 |
@Test... |
66 |
|
public void testWikiLinkSearchedPageHidesTechnicalSpaces() |
67 |
|
{ |
68 |
1 |
openDialog("Link", "Wiki Page..."); |
69 |
|
|
70 |
1 |
waitForStepToLoad("xSelectorAggregatorStep"); |
71 |
1 |
clickTab("Search"); |
72 |
1 |
waitForStepToLoad("xPagesSearch"); |
73 |
|
|
74 |
1 |
checkSpaceInSearchResults("Blog", true); |
75 |
1 |
checkSpaceInSearchResults("Main", true); |
76 |
1 |
checkSpaceInSearchResults("Sandbox", true); |
77 |
|
|
78 |
1 |
checkSpaceInSearchResults("ColorThemes", false); |
79 |
1 |
checkSpaceInSearchResults("Panels", false); |
80 |
1 |
checkSpaceInSearchResults("Scheduler", false); |
81 |
1 |
checkSpaceInSearchResults("Stats", false); |
82 |
1 |
checkSpaceInSearchResults("XWiki", false); |
83 |
|
|
84 |
1 |
closeDialog(); |
85 |
|
} |
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
@param |
91 |
|
@param |
92 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
93 |
8 |
private void checkSpaceInSearchResults(String spaceName, boolean expected)... |
94 |
|
{ |
95 |
8 |
typeInInput("Type a keyword to search for a wiki page", spaceName + ".WebHome"); |
96 |
8 |
clickButtonWithText("Search"); |
97 |
|
|
98 |
|
|
99 |
8 |
String newPageSelector = |
100 |
|
"//div[contains(@class, 'xPagesSearch')]" + "//div[contains(@class, 'xListItem')]" |
101 |
|
+ "//div[contains(@class, 'xNewPagePreview')]"; |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
8 |
waitForElement(newPageSelector); |
106 |
|
|
107 |
8 |
String pageInListLocator = |
108 |
|
"//div[contains(@class, 'xPagesSearch')]" + "//div[contains(@class, 'xListItem')]" + "//div[. = '" |
109 |
|
+ String.format(LinkTest.PAGE_LOCATION, spaceName, "WebHome") + "']"; |
110 |
8 |
if (expected) { |
111 |
3 |
assertElementPresent(pageInListLocator); |
112 |
|
} else { |
113 |
5 |
assertElementNotPresent(pageInListLocator); |
114 |
|
} |
115 |
|
} |
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
121 |
1 |
@Test... |
122 |
|
public void testWikiLinkAllPagesPageHidesTechnicalSpaces() |
123 |
|
{ |
124 |
1 |
String currentSpace = getClass().getSimpleName(); |
125 |
1 |
String currentPage = getTestMethodName(); |
126 |
|
|
127 |
|
|
128 |
1 |
clickEditSaveAndContinue(); |
129 |
|
|
130 |
1 |
openDialog("Link", "Wiki Page..."); |
131 |
1 |
waitForStepToLoad("xSelectorAggregatorStep"); |
132 |
1 |
clickTab("All pages"); |
133 |
1 |
waitForStepToLoad("xExplorerPanel"); |
134 |
1 |
explorer.waitForPageSelected(currentSpace, currentPage); |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
1 |
for (String page : Arrays.asList("Blog", "Home", "Sandbox", "XWiki Syntax Guide")) { |
141 |
4 |
explorer.findAndSelectPage(page); |
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
1 |
for (String space : Arrays.asList("ColorThemes", "Panels", "Scheduler", "Stats")) { |
146 |
4 |
assertFalse(explorer.hasPage(space, "WebHome")); |
147 |
|
} |
148 |
1 |
for (String page : Arrays.asList("Color Themes", "Panels", "Job Scheduler", "Statistics")) { |
149 |
4 |
assertFalse(explorer.find(page).hasPage(page)); |
150 |
|
} |
151 |
|
|
152 |
1 |
closeDialog(); |
153 |
|
} |
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
159 |
1 |
@Test... |
160 |
|
public void testImageSelectorHidesTechnicalSpaces() |
161 |
|
{ |
162 |
1 |
String currentSpace = getClass().getSimpleName(); |
163 |
|
|
164 |
|
|
165 |
1 |
clickEditSaveAndContinue(); |
166 |
|
|
167 |
1 |
openDialog(ImageTest.MENU_IMAGE, ImageTest.MENU_INSERT_ATTACHED_IMAGE); |
168 |
1 |
waitForStepToLoad("xSelectorAggregatorStep"); |
169 |
1 |
clickTab("All pages"); |
170 |
1 |
waitForStepToLoad("xImagesExplorer"); |
171 |
|
|
172 |
1 |
waitForElement(ImageTest.SPACE_SELECTOR + "/option[@value=\"" + currentSpace + "\"]"); |
173 |
|
|
174 |
1 |
assertElementPresent(ImageTest.SPACE_SELECTOR + "/option[@value=\"Blog\"]"); |
175 |
1 |
assertElementPresent(ImageTest.SPACE_SELECTOR + "/option[@value=\"Main\"]"); |
176 |
1 |
assertElementPresent(ImageTest.SPACE_SELECTOR + "/option[@value=\"Sandbox\"]"); |
177 |
|
|
178 |
1 |
assertElementNotPresent(ImageTest.SPACE_SELECTOR + "/option[@value=\"ColorThemes\"]"); |
179 |
1 |
assertElementNotPresent(ImageTest.SPACE_SELECTOR + "/option[@value=\"Panels\"]"); |
180 |
1 |
assertElementNotPresent(ImageTest.SPACE_SELECTOR + "/option[@value=\"Scheduler\"]"); |
181 |
1 |
assertElementNotPresent(ImageTest.SPACE_SELECTOR + "/option[@value=\"Stats\"]"); |
182 |
|
|
183 |
|
|
184 |
1 |
assertElementPresent(ImageTest.SPACE_SELECTOR + "/option[@value=\"XWiki\"]"); |
185 |
|
|
186 |
1 |
closeDialog(); |
187 |
|
} |
188 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
189 |
6 |
protected void waitForStepToLoad(String name)... |
190 |
|
{ |
191 |
6 |
waitForElement("//*[contains(@class, '" + name + "')]"); |
192 |
|
} |
193 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
194 |
3 |
private void openDialog(String menuName, String menuItemName)... |
195 |
|
{ |
196 |
3 |
clickMenu(menuName); |
197 |
3 |
assertTrue(isMenuEnabled(menuItemName)); |
198 |
3 |
clickMenu(menuItemName); |
199 |
3 |
waitForDialogToLoad(); |
200 |
|
} |
201 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
202 |
3 |
private void clickTab(String tabName)... |
203 |
|
{ |
204 |
3 |
String tabSelector = "//div[.='" + tabName + "']"; |
205 |
3 |
getSelenium().click(tabSelector); |
206 |
|
} |
207 |
|
} |