Search in sources :

Example 1 with TreeNodeElement

use of org.xwiki.tree.test.po.TreeNodeElement 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 2 with TreeNodeElement

use of org.xwiki.tree.test.po.TreeNodeElement in project xwiki-platform by xwiki.

the class AllDocsTest method treeViewTab.

/**
 * Validate the tree view.
 */
@Test
public void treeViewTab() throws Exception {
    // Create a tree structure.
    String spaceName = getTestClassName();
    getUtil().createPage(spaceName, "WebHome", null, null);
    getUtil().createPageWithAttachment(Arrays.asList(spaceName, "A", "B"), "C", null, "Child Page", null, null, "file.txt", getClass().getResourceAsStream("/file.txt"), TestUtils.SUPER_ADMIN_CREDENTIALS);
    DocumentTreeElement tree = AllDocsPage.gotoPage().clickTreeTab();
    TreeNodeElement root = tree.getDocumentNode(spaceName, "WebHome");
    assertEquals(spaceName, root.getLabel());
    assertFalse(tree.hasDocument(spaceName, "A", "WebHome"));
    root.open().waitForIt();
    TreeNodeElement alice = tree.getDocumentNode(spaceName, "A", "WebHome");
    assertEquals("A", alice.getLabel());
    assertFalse(tree.hasDocument(spaceName, "A", "B", "WebHome"));
    alice.open().waitForIt();
    TreeNodeElement bob = tree.getDocumentNode(spaceName, "A", "B", "WebHome");
    assertEquals("B", bob.getLabel());
    assertFalse(tree.hasDocument(spaceName, "A", "B", "C"));
    bob.open().waitForIt();
    TreeNodeElement child = tree.getDocumentNode(spaceName, "A", "B", "C");
    assertEquals("Child Page", child.getLabel());
    assertFalse(tree.hasAttachment(spaceName, "A", "B", "C", "file.txt"));
    // Open the Attachments node.
    child.open().waitForIt().getChildren().get(0).open().waitForIt();
    TreeNodeElement file = tree.getAttachmentNode(spaceName, "A", "B", "C", "file.txt");
    assertEquals("file.txt", file.getLabel());
}
Also used : TreeNodeElement(org.xwiki.tree.test.po.TreeNodeElement) DocumentTreeElement(org.xwiki.index.tree.test.po.DocumentTreeElement) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Aggregations

Test (org.junit.Test)2 AbstractTest (org.xwiki.test.ui.AbstractTest)2 TreeNodeElement (org.xwiki.tree.test.po.TreeNodeElement)2 DocumentTreeElement (org.xwiki.index.tree.test.po.DocumentTreeElement)1 ViewPage (org.xwiki.test.ui.po.ViewPage)1 TreeElement (org.xwiki.tree.test.po.TreeElement)1