First of all, I believe there are two kinds of functional tests we can
write for the WYSIWYG editor:
1) test the behavior of the editor while the user is editing
2) test the integration with the rendering
See below,
Vincent Massol wrote:
On Oct 10, 2008, at 11:53 AM, jvdrean (SVN) wrote:
Author: jvdrean
Date: 2008-10-10 11:53:57 +0200 (Fri, 10 Oct 2008)
New Revision: 13481
Added:
enterprise/trunk/distribution-test/wysiwyg-tests/
enterprise/trunk/distribution-test/wysiwyg-tests/pom.xml
enterprise/trunk/distribution-test/wysiwyg-tests/src/
enterprise/trunk/distribution-test/wysiwyg-tests/src/test/
enterprise/trunk/distribution-test/wysiwyg-tests/src/test/it/
enterprise/trunk/distribution-test/wysiwyg-tests/src/test/it/com/
enterprise/trunk/distribution-test/wysiwyg-tests/src/test/it/com/xpn/
enterprise/trunk/distribution-test/wysiwyg-tests/src/test/it/com/
xpn/xwiki/
enterprise/trunk/distribution-test/wysiwyg-tests/src/test/it/com/
xpn/xwiki/it/
enterprise/trunk/distribution-test/wysiwyg-tests/src/test/it/com/
xpn/xwiki/it/selenium/
enterprise/trunk/distribution-test/wysiwyg-tests/src/test/it/com/
xpn/xwiki/it/selenium/AllTests.java
enterprise/trunk/distribution-test/wysiwyg-tests/src/test/it/com/
xpn/xwiki/it/selenium/StandardFeaturesTest.java
enterprise/trunk/distribution-test/wysiwyg-tests/src/test/it/com/
xpn/xwiki/it/selenium/framework/
enterprise/trunk/distribution-test/wysiwyg-tests/src/test/it/com/
xpn/xwiki/it/selenium/framework/AbstractWysiwygTestCase.java
Log:
XE-319 : Write an integration tests framework for the new wysiwyg
editor
Initial version, the XHTML assertions must be reviewed since some
behaviors looks weird.
[snip]
+ public void testTypingAndDeletion()
+ {
+ typeText("foobar");
+ assertXHTML("foobar<br>");
This is not correct. There should be no br.
1) assertDisplayedText("foobar");
2) switchToWikiEditor();
assertText("foobar");
+
typeBackspaces("foobar".length());
+ assertXHTML(WYSIWYG_DEFAULT_CONTENT);
Maybe an assertEmptyXHTML() would be better?
switchToWYSIWYGEditor();
1) assertDisplayedText("");
2) -
+ public void testParagraphs()
+ {
+ typeTextThenEnter("a");
+ typeTextThenEnter("b");
+ typeText("c");
+
assertXHTML("<p>a</p><p>b</p><p>c<br></p>");
The br is wrong.
1) selectText("b");
assertSelectionInsideParagraph();
2) switchToWikiEditor();
assertText("a\n\nb\n\nc");
+ public void testBold()
+ {
+ typeTextThenEnter("foobar");
+ selectElement("p", 1);
What does this mean? Select the first <p> element in the DOM?
Couldn't we have instead: selectText("foobar")? It would seems easier
to write and easier to understand.
+ clickBoldButton();
+
assertXHTML("<p><strong>foobar</strong></p><p><strong></
strong><br></p>");
The second paragraph shouldn't be there.
1) selectText("ba");
assertSelectionIsBold();
2) switchToWikiEditor();
assertText("**foobar**\n\n");
+ public void testItalics()
+ {
+ typeTextThenEnter("foobar");
+ selectElement("p", 1);
+ clickItalicsButton();
+
assertXHTML("<p><em>foobar</em></p><p><em></em><br></p>");
Same
+ }
+
+ public void testUnderline()
+ {
+ typeTextThenEnter("foobar");
+ selectElement("p", 1);
+ clickUnderlineButton();
+
assertXHTML("<p><ins>foobar</ins></p><p><ins></ins><br></
p>");
same
+ }
+
+ public void testStrikethrough()
+ {
+ typeTextThenEnter("foobar");
+ selectElement("p", 1);
+ clickStrikethroughButton();
+
assertXHTML("<p><del>foobar</del></p><p><del></del><br></
p>");
same
+ }
+
+ public void testSubscript()
+ {
+ typeTextThenEnter("foobar");
+ selectElement("p", 1);
+ clickSubscriptButton();
+
assertXHTML("<p><sub>foobar</sub></p><p><br></p>");
same
+ }
+
+ public void testSuperscript()
+ {
+ typeTextThenEnter("foobar");
+ selectElement("p", 1);
+ clickSuperscriptButton();
+
assertXHTML("<p><sup>foobar</sup></p><p><br></p>");
same
+ }
+
+ public void testUnorderedList()
+ {
+ // Create a list with 3 items
+ typeTextThenEnter("a");
+ typeTextThenEnter("b");
+ typeText("c");
+ selectAllContent();
+ clickUnorderedListButton();
+
assertXHTML("<ul><li>a</li><li>b</li><li>c<br></li></ul>");
+
+ // Undo
+ clickUnorderedListButton();
+
assertXHTML("<p>a</p><p>b</p><p>c<br></p>");
br shouldn't be there
+
+ // Create a list with 1 item and delete it
+ resetContent();
clearContent()?
+ typeText("a");
+ selectAllContent();
+ clickUnorderedListButton();
+ typeBackspaces(2);
+ assertXHTML("<br>");
should be empty.
+
+ // Create a list with 1 item and delete the bullet
+ resetContent();
+ typeText("a");
+ selectAllContent();
+ clickUnorderedListButton();
+ typeLeftArrow();
+ typeBackspace();
+ assertXHTML("a");
[snip] (other tests also need to be fixed)
+
+ public static final String WYSIWYG_DEFAULT_CONTENT = "<br>";
This is not correct. It should be empty.
My idea is to first test what the user sees and experiences while he is
editing and then test what happens when the user switches to wiki and
back to wysiwyg. It doesn't matter the HTML has br's while the user
edits (they could be removed later). What is important is that he sees
what he is expecting and when he saves or switches the editor the result
in wiki syntax is equivalent. This is probably not easy to do.
Thanks,
Marius
Thanks
-Vincent
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs