Search in sources :

Example 66 with ViewPage

use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.

the class OfficeImporterTest method testChild.

/**
 * Test if the expected child exists at the expected place (as a children of the target page).
 */
private void testChild(String expectedName, String expectedContent) {
    ViewPage child = getUtil().gotoPage(new DocumentReference("xwiki", Arrays.asList(getTestClassName(), getTestMethodName()), expectedName));
    assertTrue(child.exists());
    assertEquals(expectedName, child.getDocumentTitle());
    assertTrue(StringUtils.contains(child.getContent(), expectedContent));
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) DocumentReference(org.xwiki.model.reference.DocumentReference)

Example 67 with ViewPage

use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.

the class OfficeImporterTest method importFile.

/**
 * Import an office file in the wiki.
 *
 * @param fileName name of the file to import (the file should be located in test /resources/ folder)
 * @param splitByHeadings either the option splitByHeadings should be use or not
 * @return the result page
 */
private ViewPage importFile(String fileName, boolean splitByHeadings) {
    ViewPage page = getUtil().gotoPage(new DocumentReference("xwiki", Arrays.asList(getTestClassName(), getTestMethodName()), "WebHome"));
    CreatePagePage createPage = page.createPage();
    createPage.setType("office");
    createPage.clickCreate();
    OfficeImporterPage officeImporterPage = new OfficeImporterPage();
    officeImporterPage.setFile(new File(getClass().getResource(fileName).getPath()));
    officeImporterPage.setFilterStyle(true);
    officeImporterPage.setSplitDocument(splitByHeadings);
    OfficeImporterResultPage officeImporterResultPage = officeImporterPage.clickImport();
    assertEquals("Conversion succeeded. You can view the result, or you can Go back to convert another document.", officeImporterResultPage.getMessage());
    return officeImporterResultPage.viewResult();
}
Also used : CreatePagePage(org.xwiki.test.ui.po.CreatePagePage) OfficeImporterPage(org.xwiki.officeimporter.test.po.OfficeImporterPage) OfficeImporterResultPage(org.xwiki.officeimporter.test.po.OfficeImporterResultPage) ViewPage(org.xwiki.test.ui.po.ViewPage) File(java.io.File) DocumentReference(org.xwiki.model.reference.DocumentReference)

Example 68 with ViewPage

use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.

the class SharePageTest method testShareByEmail.

@Test
public void testShareByEmail() throws Exception {
    // Delete any existing test page
    getUtil().deletePage(getTestClassName(), getTestMethodName());
    ViewPage vp = getUtil().createPage(getTestClassName(), getTestMethodName(), "something", "title");
    ShareableViewPage svp = new ShareableViewPage();
    svp.clickShareByEmail();
    ShareDialog sd = new ShareDialog();
    sd.setEmailField("john@doe.com");
    sd.setMessage("test");
    ShareResultDialog srd = sd.sendMail();
    assertEquals("The message has been sent to john.", srd.getResultMessage());
    srd.clickBackLink();
    // Verify we received the email and that its content is valid
    this.mail.waitForIncomingEmail(10000L, 1);
    MimeMessage mimeMessage = this.mail.getReceivedMessages()[0];
    assertEquals("superadmin wants to share a document with you", mimeMessage.getSubject());
}
Also used : ShareResultDialog(org.xwiki.sharepage.test.po.ShareResultDialog) ShareDialog(org.xwiki.sharepage.test.po.ShareDialog) MimeMessage(javax.mail.internet.MimeMessage) ShareableViewPage(org.xwiki.sharepage.test.po.ShareableViewPage) ShareableViewPage(org.xwiki.sharepage.test.po.ShareableViewPage) ViewPage(org.xwiki.test.ui.po.ViewPage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest) ServerSetupTest(com.icegreen.greenmail.util.ServerSetupTest)

Example 69 with ViewPage

use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.

the class VfsTest method testVfsMacro.

@Test
public void testVfsMacro() throws Exception {
    // Delete pages that we create in the test
    getUtil().rest().deletePage(getTestClassName(), getTestMethodName());
    // Scenario:
    // - Attach a zip to a wiki page
    // - Use the VFS Tree Macro to display the content of that zip
    // - Click on a tree node to display the content of a file inside the zip
    getUtil().attachFile(getTestClassName(), getTestMethodName(), "test.zip", createZipInputStream(), false);
    String content = "{{vfsTree root=\"attach:test.zip\"/}}";
    ViewPage vp = getUtil().createPage(getTestClassName(), getTestMethodName(), content, "VFS Test");
    // Get hold of the Tree and expand the directory node and the click on the first children node
    TreeElement tree = new TreeElement(getDriver().findElement(By.cssSelector(".xtree")));
    tree.waitForIt();
    TreeNodeElement node = tree.getNode("//directory");
    node = node.open();
    node.waitForIt();
    node.getChildren().get(0).select();
    assertEquals("content2", getDriver().findElement(By.tagName("body")).getText());
}
Also used : TreeNodeElement(org.xwiki.tree.test.po.TreeNodeElement) ViewPage(org.xwiki.test.ui.po.ViewPage) TreeElement(org.xwiki.tree.test.po.TreeElement) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 70 with ViewPage

use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.

the class UIExtensionTest method testUIExtension.

@Test
public void testUIExtension() throws Exception {
    // Test Java UI extensions
    getUtil().rest().savePage(new LocalDocumentReference(getTestClassName(), HELLOWORLD_UIX_PAGE), "{{velocity}}\n" + "\n" + "{{html}}\n" + "#foreach($uix in $services.uix.getExtensions('hello', {'sortByParameter' : 'HelloWorldKey'}))" + "$services.rendering.render($uix.execute(), " + "'xhtml/1.0')#end\n" + "{{/html}}\n" + "\n" + "#foreach($uix in $services.uix.getExtensions('hello', {'sortByParameter' : 'HelloWorldKey'}))\n" + "$uix.parameters\n" + "#end\n" + "{{/velocity}}\n", "");
    // Test Wiki UI extension
    Page extensionsPage = getUtil().rest().page(new LocalDocumentReference(getTestClassName(), HELLOWIKIWORLD_UIX_PAGE));
    Objects objects = new Objects();
    extensionsPage.setObjects(objects);
    Object object = RestTestUtils.object(WikiUIExtensionConstants.CLASS_REFERENCE_STRING);
    object.setNumber(0);
    object.withProperties(RestTestUtils.property("name", "helloWikiWorld2"));
    object.withProperties(RestTestUtils.property("extensionPointId", "hello"));
    object.withProperties(RestTestUtils.property("content", "HelloWikiWorld2"));
    object.withProperties(RestTestUtils.property("parameters", "HelloWorldKey=zz2_$xcontext.user"));
    objects.withObjectSummaries(object);
    object = RestTestUtils.object(WikiUIExtensionConstants.CLASS_REFERENCE_STRING);
    object.setNumber(1);
    object.withProperties(RestTestUtils.property("name", "helloWikiWorld1"));
    object.withProperties(RestTestUtils.property("extensionPointId", "hello"));
    object.withProperties(RestTestUtils.property("content", "HelloWikiWorld1"));
    object.withProperties(RestTestUtils.property("parameters", "HelloWorldKey=zz1_$xcontext.user"));
    objects.withObjectSummaries(object);
    getUtil().rest().save(extensionsPage);
    ViewPage page = getUtil().gotoPage(getTestClassName(), HELLOWORLD_UIX_PAGE);
    Assert.assertEquals("HelloWorld\n" + "HelloWikiWorld1\n" + "HelloWikiWorld2\n" + "{HelloWorldKey=HelloWorldValue}\n" + "{HelloWorldKey=zz1_XWiki.superadmin}\n" + "{HelloWorldKey=zz2_XWiki.superadmin}", page.getContent());
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) Objects(org.xwiki.rest.model.jaxb.Objects) Page(org.xwiki.rest.model.jaxb.Page) ViewPage(org.xwiki.test.ui.po.ViewPage) Object(org.xwiki.rest.model.jaxb.Object) ViewPage(org.xwiki.test.ui.po.ViewPage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Aggregations

ViewPage (org.xwiki.test.ui.po.ViewPage)93 Test (org.junit.Test)75 AbstractTest (org.xwiki.test.ui.AbstractTest)41 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)26 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)18 ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)11 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)10 DocumentReference (org.xwiki.model.reference.DocumentReference)8 CreatePagePage (org.xwiki.test.ui.po.CreatePagePage)8 FormElement (org.xwiki.test.ui.po.FormElement)7 HistoryPane (org.xwiki.test.ui.po.HistoryPane)7 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)7 WebElement (org.openqa.selenium.WebElement)6 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)6 AttachmentsPane (org.xwiki.test.ui.po.AttachmentsPane)6 URL (java.net.URL)5 ApplicationClassEditPage (org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage)5 ClassFieldEditPane (org.xwiki.appwithinminutes.test.po.ClassFieldEditPane)5 ExtensionId (org.xwiki.extension.ExtensionId)5 ExtensionAdministrationPage (org.xwiki.extension.test.po.ExtensionAdministrationPage)5