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));
}
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();
}
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());
}
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());
}
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());
}
Aggregations