Skip to content
Snippets Groups Projects
Commit 95aeed38 authored by Marius Dumitru Florea's avatar Marius Dumitru Florea
Browse files

XWIKI-21034: Write functional tests and Page Object for Quick Actions

* Fix since version and remove whitespace.
parent a7c2f70e
No related branches found
No related tags found
No related merge requests found
......@@ -44,7 +44,8 @@
* All functional tests for Quick Actions.
*
* @version $Id$
* @since 15.5
* @since 15.5.1
* @since 15.6RC1
*/
@UITest(
......@@ -67,7 +68,7 @@
)
public class QuickActionsIT
{
/**
* Test string that will be inserted to check formatting.
*/
......@@ -79,13 +80,13 @@ void setUp(TestUtils setup)
// Run the tests as a normal user. We make the user advanced only to enable the Edit drop down menu.
createAndLoginStandardUser(setup);
}
@BeforeEach
void cleanUp(TestUtils setup, TestReference testReference)
{
setup.deletePage(testReference);
}
@AfterEach
void exitEditMode(TestUtils setup, TestReference testReference)
{
......@@ -100,20 +101,19 @@ void exitEditMode(TestUtils setup, TestReference testReference)
}
}
}
private static void createAndLoginStandardUser(TestUtils setup)
{
setup.createUserAndLogin("alice", "pa$$word", "editor", "Wysiwyg", "usertype", "Advanced");
}
@Test
@Order(1)
void heading1AndParagraph(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Switch to another style
......@@ -123,12 +123,12 @@ void heading1AndParagraph(TestUtils setup, TestReference testReference) throws E
qa.waitForItemSelected("Heading 1");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
// Write some text
textArea.sendKeys(TEST_TEXT);
Assertions.assertTrue(textArea.getContent().contains("<h1>" + TEST_TEXT + "<br></h1>"));
// Switch back to paragraph
textArea.sendKeys("/");
qa = new AutocompleteDropdown();
......@@ -136,17 +136,17 @@ void heading1AndParagraph(TestUtils setup, TestReference testReference) throws E
qa.waitForItemSelected("Paragraph");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
Assertions.assertTrue(textArea.getContent().contains("<p>" + TEST_TEXT + "<br></p>"));
}
@Test
@Order(2)
void heading2(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -158,20 +158,20 @@ void heading2(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Heading 2");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
// Write some text
textArea.sendKeys(TEST_TEXT);
Assertions.assertTrue(textArea.getContent().contains("<h2>" + TEST_TEXT + "<br></h2>"));
}
@Test
@Order(3)
void heading3(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -183,20 +183,20 @@ void heading3(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Heading 3");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
// Write some text
textArea.sendKeys(TEST_TEXT);
Assertions.assertTrue(textArea.getContent().contains("<h3>" + TEST_TEXT + "<br></h3>"));
}
@Test
@Order(4)
void bulletedList(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -206,10 +206,10 @@ void bulletedList(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Bulleted List");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
// Write some text
textArea.sendKeys(TEST_TEXT);
Assertions.assertTrue(textArea.getContent().contains("<ul><li>" + TEST_TEXT + "<br></li></ul>"));
}
......@@ -219,7 +219,7 @@ void numberedList(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -229,10 +229,10 @@ void numberedList(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Numbered List");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
// Write some text
textArea.sendKeys(TEST_TEXT);
Assertions.assertTrue(textArea.getContent().contains("<ol><li>" + TEST_TEXT + "<br></li></ol>"));
}
......@@ -242,7 +242,7 @@ void table(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -252,10 +252,10 @@ void table(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Table");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
// Click OK on the table insertion dialog
new CKEditorDialog().submitDialog();
// Write some text
textArea.sendKeys(TEST_TEXT);
......@@ -263,15 +263,14 @@ void table(TestUtils setup, TestReference testReference) throws Exception
+ "<tr><td><br></td><td><br></td></tr>"
+ "<tr><td><br></td><td><br></td></tr></tbody></table>");
}
@Test
@Order(7)
void blockQuote(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -281,20 +280,20 @@ void blockQuote(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Quote");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
// Write some text
textArea.sendKeys(TEST_TEXT);
Assertions.assertTrue(textArea.getContent().contains("<blockquote><p>" + TEST_TEXT + "<br></p></blockquote>"));
}
@Test
@Order(8)
void infoBox(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -304,10 +303,10 @@ void infoBox(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Info Box");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
textArea = editor.getRichTextArea();
textArea.waitUntilContentEditable();
WikiEditPage wikiEditPage = editPage.clickSaveAndView().editWiki();
Assertions.assertTrue(wikiEditPage.getContent().contains("{{info}}\n"
+ "Type your information message here.\n"
......@@ -320,7 +319,7 @@ void successBox(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -330,10 +329,10 @@ void successBox(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Success Box");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
textArea = editor.getRichTextArea();
textArea.waitUntilContentEditable();
WikiEditPage wikiEditPage = editPage.clickSaveAndView().editWiki();
Assertions.assertTrue(wikiEditPage.getContent().contains("{{success}}\n"
+ "Type your success message here.\n"
......@@ -345,7 +344,7 @@ void warningBox(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -355,10 +354,10 @@ void warningBox(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Warning Box");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
textArea = editor.getRichTextArea();
textArea.waitUntilContentEditable();
WikiEditPage wikiEditPage = editPage.clickSaveAndView().editWiki();
Assertions.assertTrue(wikiEditPage.getContent().contains("{{warning}}\n"
+ "Type your warning message here.\n"
......@@ -371,7 +370,7 @@ void errorBox(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -381,23 +380,23 @@ void errorBox(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Error Box");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
textArea = editor.getRichTextArea();
textArea.waitUntilContentEditable();
WikiEditPage wikiEditPage = editPage.clickSaveAndView().editWiki();
Assertions.assertTrue(wikiEditPage.getContent().contains("{{error}}\n"
+ "Type your error message here.\n"
+ "{{/error}}"));
}
@Test
@Order(12)
void divider(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -407,17 +406,17 @@ void divider(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Divider");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
Assertions.assertTrue(textArea.getContent().contains("<hr>"));
}
@Test
@Order(13)
void link(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -427,20 +426,20 @@ void link(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Link");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
textArea.sendKeys("ali");
AutocompleteDropdown link = new AutocompleteDropdown();
link.waitForItemSelected("alice");
Assertions.assertTrue(textArea.getText().contains("["));
}
@Test
@Order(14)
void image(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -450,7 +449,7 @@ void image(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Image");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
new ImageDialogSelectModal().waitUntilReady().clickCancel();
}
......@@ -460,7 +459,7 @@ void mention(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -470,19 +469,19 @@ void mention(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Mention");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
AutocompleteDropdown mention = new AutocompleteDropdown();
mention.waitForItemSelected("alice");
Assertions.assertTrue(textArea.getText().contains("@"));
}
@Test
@Order(16)
void emoji(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -491,19 +490,19 @@ void emoji(TestUtils setup, TestReference testReference) throws Exception
textArea.sendKeys("emo");
qa.waitForItemSelected("Emoji");
textArea.sendKeys(Keys.ENTER);
AutocompleteDropdown emoji = new AutocompleteDropdown();
emoji.waitForItemSelected("🛩");
Assertions.assertTrue(textArea.getText().contains(":sm"));
}
@Test
@Order(17)
void include(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -513,24 +512,24 @@ void include(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Include Page");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
// Empty form
new MacroDialogEditModal().waitUntilReady().clickSubmit();
textArea = editor.getRichTextArea();
textArea.waitUntilContentEditable();
WikiEditPage wikiEditPage = editPage.clickSaveAndView().editWiki();
Assertions.assertTrue(wikiEditPage.getContent().contains("{{include/}}"));
}
@Test
@Order(18)
void code(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -540,24 +539,24 @@ void code(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Code Snippet");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
// Empty form
new MacroDialogEditModal().waitUntilReady().clickSubmit();
textArea = editor.getRichTextArea();
textArea.waitUntilContentEditable();
WikiEditPage wikiEditPage = editPage.clickSaveAndView().editWiki();
Assertions.assertTrue(wikiEditPage.getContent().contains("{{code language=\"none\"}}{{/code}}"));
}
@Test
@Order(19)
void toc(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -567,21 +566,21 @@ void toc(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Table of Contents");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
textArea = editor.getRichTextArea();
textArea.waitUntilContentEditable();
WikiEditPage wikiEditPage = editPage.clickSaveAndView().editWiki();
Assertions.assertTrue(wikiEditPage.getContent().contains("{{toc/}}"));
}
@Test
@Order(20)
void find(TestUtils setup, TestReference testReference) throws Exception
{
WYSIWYGEditPage editPage = setup.gotoPage(testReference).editWYSIWYG();
CKEditor editor = new CKEditor("content").waitToLoad();
RichTextAreaElement textArea = editor.getRichTextArea();
// Run the action
......@@ -591,7 +590,7 @@ void find(TestUtils setup, TestReference testReference) throws Exception
qa.waitForItemSelected("Find and Replace");
textArea.sendKeys(Keys.ENTER);
qa.waitForItemSubmitted();
// Click close on the Find and Replace dialog
new CKEditorDialog().cancelDialog();
}
......
......@@ -28,7 +28,8 @@
* Models an auto-complete drop-down.
*
* @version $Id$
* @since 15.5
* @since 15.5.1
* @since 15.6RC1
*/
@Unstable
public class AutocompleteDropdown extends BaseElement
......@@ -42,7 +43,7 @@ public void waitForItemSelected(String label)
{
getDriver().findElement(By.xpath("//*[contains(@class, 'cke_autocomplete_selected')]//*[. = '" + label + "']"));
}
/**
* Waits for the auto-complete drop-down to disappear.
*/
......
......@@ -28,13 +28,12 @@
* Models a CKEditor Dialog.
*
* @version $Id$
* @since 1.15
* @since 15.5.1
* @since 15.6RC1
*/
@Unstable
public class CKEditorDialog extends BaseElement
{
/**
* Creates a CKEditor Dialog instance.
*/
......@@ -42,7 +41,7 @@ public CKEditorDialog()
{
getDriver().waitUntilElementIsVisible(By.className("cke_dialog_contents"));
}
/**
* Clicks OK on a CKEditor dialog.
*/
......@@ -51,7 +50,7 @@ public void submitDialog()
getDriver().findElement(By.className("cke_dialog_ui_button_ok")).click();
getDriver().waitUntilElementDisappears(By.className("cke_dialog_contents"));
}
/**
* Clicks close on a CKEditor dialog.
*/
......
......@@ -156,9 +156,12 @@ private WebElement getActiveElement()
getDriver().switchTo().frame(this.iframe);
return getDriver().switchTo().activeElement();
}
/**
* Waits until the content is editable.
*
* @since 15.5.1
* @since 15.6RC1
*/
public void waitUntilContentEditable()
{
......
......@@ -57,9 +57,12 @@ public ImageDialogEditModal clickSelect()
element.click();
return new ImageDialogEditModal().waitUntilReady();
}
/**
* Click on the cancel button.
*
* @since 15.5.1
* @since 15.6RC1
*/
public void clickCancel()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment