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.net.MalformedURLException; |
23 |
|
import java.net.URL; |
24 |
|
|
25 |
|
import org.apache.commons.lang3.RandomStringUtils; |
26 |
|
import org.junit.Test; |
27 |
|
import org.openqa.selenium.Keys; |
28 |
|
import org.xwiki.test.wysiwyg.framework.AbstractWysiwygTestCase; |
29 |
|
|
30 |
|
import static org.junit.Assert.*; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (53) |
Complexity: 8 |
Complexity Density: 0.18 |
|
37 |
|
public class SubmitTest extends AbstractWysiwygTestCase |
38 |
|
{ |
39 |
|
|
40 |
|
|
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
42 |
1 |
@Test... |
43 |
|
public void testSubmitAfterEditorIsLoadedAndHasFocus() |
44 |
|
{ |
45 |
|
|
46 |
1 |
clickEditPageInWikiSyntaxEditor(); |
47 |
1 |
setFieldValue("content", "a**b**c"); |
48 |
1 |
clickEditPageInWysiwyg(); |
49 |
1 |
waitForEditorToLoad(); |
50 |
|
|
51 |
1 |
focusRichTextArea(); |
52 |
|
|
53 |
1 |
clickEditPageInWikiSyntaxEditor(); |
54 |
1 |
assertEquals("a**b**c", getFieldValue("content")); |
55 |
|
} |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
60 |
1 |
@Test... |
61 |
|
public void testSubmitAfterEditorIsLoadedWithoutGainingFocus() |
62 |
|
{ |
63 |
|
|
64 |
1 |
clickEditPageInWikiSyntaxEditor(); |
65 |
1 |
setFieldValue("content", "1**2**3"); |
66 |
|
|
67 |
1 |
clickEditPageInWysiwyg(); |
68 |
1 |
waitForEditorToLoad(); |
69 |
|
|
70 |
1 |
clickEditPageInWikiSyntaxEditor(); |
71 |
1 |
assertEquals("1**2**3", getFieldValue("content")); |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
78 |
1 |
@Test... |
79 |
|
public void testSubmitAfterChangingContentWithFocus() |
80 |
|
{ |
81 |
|
|
82 |
1 |
focusRichTextArea(); |
83 |
|
|
84 |
1 |
setContent("x<em>y</em>z"); |
85 |
|
|
86 |
1 |
blurRichTextArea(); |
87 |
|
|
88 |
1 |
clickEditPageInWikiSyntaxEditor(); |
89 |
1 |
assertEquals("x//y//z", getFieldValue("content")); |
90 |
|
} |
91 |
|
|
92 |
|
|
93 |
|
|
94 |
|
|
95 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
96 |
1 |
@Test... |
97 |
|
public void testSubmitAfterChangingContentWithoutFocus() |
98 |
|
{ |
99 |
|
|
100 |
1 |
getSelenium().click("title"); |
101 |
|
|
102 |
1 |
setContent("u<tt>v</tt>w"); |
103 |
|
|
104 |
1 |
clickEditSaveAndView(); |
105 |
|
|
106 |
1 |
clickEditPageInWikiSyntaxEditor(); |
107 |
1 |
assertEquals("u##v##w", getFieldValue("content")); |
108 |
|
} |
109 |
|
|
110 |
|
|
111 |
|
@see |
112 |
|
@throws |
113 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
114 |
1 |
@Test... |
115 |
|
public void testShortcutsForSaveAndView() throws MalformedURLException |
116 |
|
{ |
117 |
|
|
118 |
1 |
switchToSource(); |
119 |
|
|
120 |
1 |
String content = RandomStringUtils.randomAlphanumeric(5); |
121 |
1 |
setSourceText(content); |
122 |
|
|
123 |
1 |
typeShortcutsForSaveAndView(); |
124 |
|
|
125 |
1 |
URL viewPageUrl = new URL(getSelenium().getLocation()); |
126 |
|
|
127 |
1 |
assertEquals(viewPageUrl.getPath(), getUrl(getClass().getSimpleName(), getTestMethodName())); |
128 |
|
|
129 |
1 |
clickEditPageInWikiSyntaxEditor(); |
130 |
1 |
assertEquals(content, getFieldValue("content")); |
131 |
|
} |
132 |
|
|
133 |
|
|
134 |
|
@see |
135 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
136 |
1 |
@Test... |
137 |
|
public void testShortcutsForSaveAndContinue() |
138 |
|
{ |
139 |
|
|
140 |
1 |
switchToSource(); |
141 |
|
|
142 |
1 |
String currentUrlBeforeSave = getSelenium().getLocation(); |
143 |
1 |
String content = RandomStringUtils.randomAlphanumeric(5); |
144 |
|
|
145 |
1 |
setSourceText(content); |
146 |
|
|
147 |
1 |
typeShortcutsForSaveAndContinue(); |
148 |
|
|
149 |
1 |
String currentUrlAfterSave = getSelenium().getLocation(); |
150 |
|
|
151 |
1 |
assertEquals(currentUrlBeforeSave, currentUrlAfterSave); |
152 |
|
|
153 |
|
|
154 |
1 |
clickEditCancelEdition(); |
155 |
|
|
156 |
1 |
clickEditPageInWikiSyntaxEditor(); |
157 |
1 |
assertEquals(content, getFieldValue("content")); |
158 |
|
} |
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
163 |
1 |
private void typeShortcutsForSaveAndView()... |
164 |
|
{ |
165 |
1 |
getSourceTextArea().sendKeys(Keys.chord(Keys.ALT, "s")); |
166 |
|
|
167 |
1 |
waitPage(); |
168 |
|
} |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
173 |
1 |
private void typeShortcutsForSaveAndContinue()... |
174 |
|
{ |
175 |
1 |
getSourceTextArea().sendKeys(Keys.chord(Keys.ALT, Keys.SHIFT, "s")); |
176 |
1 |
waitForNotificationSuccessMessage("Saved"); |
177 |
|
} |
178 |
|
} |