1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.wysiwyg.test.ui; |
21 |
|
|
22 |
|
import java.net.URLDecoder; |
23 |
|
|
24 |
|
import org.junit.Assert; |
25 |
|
import org.junit.Test; |
26 |
|
import org.openqa.selenium.Keys; |
27 |
|
import org.openqa.selenium.WebElement; |
28 |
|
import org.xwiki.test.ui.browser.IgnoreBrowser; |
29 |
|
import org.xwiki.test.ui.browser.IgnoreBrowsers; |
30 |
|
import org.xwiki.test.ui.po.editor.wysiwyg.RichTextAreaElement; |
31 |
|
import org.xwiki.wysiwyg.test.po.EditorElement; |
32 |
|
import org.xwiki.wysiwyg.test.po.TableConfigPane; |
33 |
|
import org.xwiki.wysiwyg.test.po.UploadImagePane; |
34 |
|
import org.xwiki.wysiwyg.test.po.WYSIWYGEditPage; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
@version |
40 |
|
@since |
41 |
|
|
|
|
| 83.2% |
Uncovered Elements: 17 (101) |
Complexity: 10 |
Complexity Density: 0.11 |
|
42 |
|
public class EditWYSIWYGTest extends AbstractWYSIWYGEditorTest |
43 |
|
{ |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
@see |
48 |
|
|
49 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
3FAIL
|
|
50 |
0 |
@Test... |
51 |
|
@IgnoreBrowsers({ |
52 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
53 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
54 |
|
}) |
55 |
|
public void testUploadImageAfterPreview() throws Exception |
56 |
|
{ |
57 |
0 |
this.editPage.clickPreview().clickBackToEdit(); |
58 |
|
|
59 |
0 |
this.editPage = new WYSIWYGEditPage().waitUntilPageIsLoaded(); |
60 |
0 |
UploadImagePane uploadImagePane = this.editPage.insertAttachedImage().selectFromCurrentPage().uploadImage(); |
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
|
65 |
0 |
String path = URLDecoder.decode(this.getClass().getResource("/image.png").getPath(), "UTF-8"); |
66 |
0 |
uploadImagePane.setImageToUpload(path); |
67 |
|
|
68 |
0 |
uploadImagePane.configureImage(); |
69 |
|
} |
70 |
|
|
71 |
|
|
72 |
|
@see |
73 |
|
|
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
75 |
1 |
@Test... |
76 |
|
@IgnoreBrowsers({ |
77 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
78 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
79 |
|
}) |
80 |
|
public void testBackForwardCache() |
81 |
|
{ |
82 |
1 |
StringBuilder code = new StringBuilder(); |
83 |
1 |
code.append("; Description\n"); |
84 |
1 |
code.append(": {{html}}<textarea id=\"description\">f>o**o**</textarea>{{/html}}\n"); |
85 |
1 |
code.append("; Summary\n"); |
86 |
1 |
code.append(": {{html}}<textarea id=\"summary\">b<a//r//</textarea>{{/html}}\n\n"); |
87 |
|
|
88 |
1 |
code.append("{{velocity}}\n"); |
89 |
1 |
code.append("{{html}}\n"); |
90 |
1 |
code.append("#wysiwyg_editProperty($tdoc 'description')\n"); |
91 |
1 |
code.append("#wysiwyg_editProperty($tdoc 'summary')\n"); |
92 |
1 |
code.append("{{/html}}\n"); |
93 |
1 |
code.append("{{/velocity}}"); |
94 |
|
|
95 |
|
|
96 |
1 |
getUtil().createPage(getTestClassName(), getTestMethodName(), code.toString(), null); |
97 |
|
|
98 |
1 |
EditorElement descriptionEditor = new EditorElement("description").waitToLoad(); |
99 |
1 |
EditorElement summaryEditor = new EditorElement("summary").waitToLoad(); |
100 |
|
|
101 |
1 |
String description = descriptionEditor.getRichTextArea().getText(); |
102 |
1 |
String summary = summaryEditor.getRichTextArea().getText(); |
103 |
1 |
getDriver().navigate().back(); |
104 |
1 |
getDriver().navigate().forward(); |
105 |
|
|
106 |
1 |
descriptionEditor = new EditorElement("description").waitToLoad(); |
107 |
1 |
summaryEditor = new EditorElement("summary").waitToLoad(); |
108 |
|
|
109 |
1 |
Assert.assertEquals(description, descriptionEditor.getRichTextArea().getText()); |
110 |
1 |
Assert.assertEquals(summary, summaryEditor.getRichTextArea().getText()); |
111 |
|
} |
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
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 testPreserveUnsavedRichContentAgainstRefresh() |
122 |
|
{ |
123 |
|
|
124 |
1 |
this.editPage.getContentEditor().getRichTextArea().sendKeys("2"); |
125 |
1 |
this.editPage.sendKeys(Keys.F5); |
126 |
|
|
127 |
1 |
this.editPage = new WYSIWYGEditPage(); |
128 |
1 |
EditorElement editor = this.editPage.getContentEditor(); |
129 |
1 |
editor.waitToLoad(); |
130 |
|
|
131 |
|
|
132 |
1 |
RichTextAreaElement textArea = editor.getRichTextArea(); |
133 |
1 |
textArea.sendKeys("1"); |
134 |
1 |
Assert.assertEquals("12", textArea.getText()); |
135 |
|
} |
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
140 |
1 |
@Test... |
141 |
|
@IgnoreBrowsers({ |
142 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
143 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
144 |
|
}) |
145 |
|
public void testPreserveUnsavedSourceAgainstRefresh() |
146 |
|
{ |
147 |
1 |
EditorElement editor = this.editPage.getContentEditor(); |
148 |
1 |
editor.switchToSource(); |
149 |
|
|
150 |
|
|
151 |
1 |
editor.getSourceTextArea().sendKeys("1" + Keys.F5); |
152 |
|
|
153 |
1 |
this.editPage = new WYSIWYGEditPage(); |
154 |
1 |
editor = this.editPage.getContentEditor(); |
155 |
1 |
editor.waitToLoad(); |
156 |
1 |
editor.switchToSource(); |
157 |
|
|
158 |
|
|
159 |
1 |
editor.getSourceTextArea().sendKeys("2"); |
160 |
1 |
Assert.assertEquals("12", editor.getSourceTextArea().getAttribute("value")); |
161 |
|
} |
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
166 |
1 |
@Test... |
167 |
|
@IgnoreBrowsers({ |
168 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
169 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
170 |
|
}) |
171 |
|
public void testPreserveSelectedEditorAgainstRefresh() |
172 |
|
{ |
173 |
|
|
174 |
1 |
EditorElement editor = this.editPage.getContentEditor(); |
175 |
1 |
Assert.assertFalse(editor.getSourceTextArea().isEnabled()); |
176 |
|
|
177 |
|
|
178 |
1 |
editor.switchToSource(); |
179 |
1 |
editor.getSourceTextArea().sendKeys(Keys.F5); |
180 |
|
|
181 |
1 |
this.editPage = new WYSIWYGEditPage(); |
182 |
1 |
editor = this.editPage.getContentEditor(); |
183 |
1 |
editor.waitToLoad(); |
184 |
|
|
185 |
|
|
186 |
1 |
Assert.assertTrue(editor.getSourceTextArea().isEnabled()); |
187 |
|
|
188 |
|
|
189 |
1 |
editor.switchToWysiwyg(); |
190 |
1 |
this.editPage.sendKeys(Keys.F5); |
191 |
|
|
192 |
1 |
this.editPage = new WYSIWYGEditPage(); |
193 |
1 |
editor = this.editPage.getContentEditor(); |
194 |
1 |
editor.waitToLoad(); |
195 |
|
|
196 |
|
|
197 |
1 |
Assert.assertFalse(editor.getSourceTextArea().isEnabled()); |
198 |
|
} |
199 |
|
|
200 |
|
|
201 |
|
|
202 |
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
3FAIL
|
|
203 |
0 |
@Test... |
204 |
|
@IgnoreBrowsers({ |
205 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
206 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
207 |
|
}) |
208 |
|
public void testUndoRepeatedPaste() |
209 |
|
{ |
210 |
0 |
EditorElement editor = this.editPage.getContentEditor(); |
211 |
0 |
RichTextAreaElement textArea = editor.getRichTextArea(); |
212 |
|
|
213 |
|
|
214 |
0 |
textArea.sendKeys("q", Keys.chord(Keys.SHIFT, Keys.ARROW_LEFT), Keys.chord(Keys.CONTROL, "c")); |
215 |
|
|
216 |
0 |
for (int i = 0; i < 4; i++) { |
217 |
|
|
218 |
|
|
219 |
|
|
220 |
0 |
textArea.sendKeys(Keys.chord(Keys.CONTROL, "v")); |
221 |
|
} |
222 |
|
|
223 |
0 |
editor.getToolBar().clickUndoButton(); |
224 |
0 |
Assert.assertEquals("qqq", textArea.getText()); |
225 |
|
} |
226 |
|
|
227 |
|
|
228 |
|
@see |
229 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
230 |
1 |
@Test... |
231 |
|
public void testTabInTableConfigDialog() |
232 |
|
{ |
233 |
1 |
TableConfigPane tableConfig = this.editPage.insertTable(); |
234 |
|
|
235 |
|
|
236 |
1 |
Assert.assertEquals(tableConfig.getRowCountInput(), getDriver().switchTo().activeElement()); |
237 |
1 |
getDriver().switchTo().defaultContent(); |
238 |
|
|
239 |
|
|
240 |
1 |
tableConfig.getRowCountInput().sendKeys(Keys.TAB); |
241 |
|
|
242 |
|
|
243 |
1 |
Assert.assertEquals(tableConfig.getColumnCountInput(), getDriver().switchTo().activeElement()); |
244 |
1 |
getDriver().switchTo().defaultContent(); |
245 |
|
} |
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
@see |
251 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
252 |
1 |
@Test... |
253 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146") |
254 |
|
public void testDotAtEndDoesNotDelete() |
255 |
|
{ |
256 |
1 |
EditorElement editor = this.editPage.getContentEditor(); |
257 |
|
|
258 |
|
|
259 |
1 |
editor.switchToSource(); |
260 |
1 |
WebElement sourceTextArea = editor.getSourceTextArea(); |
261 |
1 |
sourceTextArea.clear(); |
262 |
1 |
sourceTextArea.sendKeys("* foo\n* bar"); |
263 |
1 |
editor.switchToWysiwyg(); |
264 |
|
|
265 |
|
|
266 |
1 |
RichTextAreaElement textArea = editor.getRichTextArea(); |
267 |
1 |
textArea.sendKeys(Keys.ARROW_RIGHT, Keys.ARROW_RIGHT, Keys.ARROW_RIGHT, "."); |
268 |
|
|
269 |
1 |
Assert.assertEquals("foo.\nbar", textArea.getText()); |
270 |
|
} |
271 |
|
|
272 |
|
|
273 |
|
@see |
274 |
|
@see |
275 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
276 |
1 |
@Test... |
277 |
|
public void testRecoverAfterConversionException() |
278 |
|
{ |
279 |
1 |
EditorElement editor = this.editPage.getContentEditor(); |
280 |
|
|
281 |
|
|
282 |
1 |
String html = "<span class=\"wikiexternallink\"><a href=\"mailto:x@y.z\">xyz</a></span><!--stopwikilink-->"; |
283 |
1 |
editor.getRichTextArea().setContent(html); |
284 |
|
|
285 |
|
|
286 |
1 |
Assert.assertEquals("xyz", editor.getRichTextArea().getText()); |
287 |
|
|
288 |
|
|
289 |
1 |
this.editPage.clickSaveAndContinue(false); |
290 |
1 |
this.editPage.waitForNotificationErrorMessage("Failed to save the page. " |
291 |
|
+ "Reason: content: Exception while parsing HTML"); |
292 |
|
|
293 |
|
|
294 |
1 |
this.editPage.clickSaveAndView(); |
295 |
1 |
this.editPage = new WYSIWYGEditPage().waitUntilPageIsLoaded(); |
296 |
1 |
Assert.assertEquals("xyz", this.editPage.getContentEditor().getRichTextArea().getText()); |
297 |
|
} |
298 |
|
} |