Search in sources :

Example 1 with AttachmentsPane

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

the class OfficeImporterTest method testImports.

/**
 * A basic test that imports some documents and verify they are correctly imported TODO: do a more advanced check
 * about styling and content
 */
@Test
public void testImports() {
    // Test word file
    ViewPage resultPage = importFile("/msoffice.97-2003/Test.doc");
    assertTrue(StringUtils.contains(resultPage.getContent(), "This is a test document."));
    deletePage();
    // Test power point file
    resultPage = importFile("/msoffice.97-2003/Test.ppt");
    AttachmentsPane attachmentsPane = resultPage.openAttachmentsDocExtraPane();
    assertTrue(attachmentsPane.attachmentExistsByFileName("Test-slide0.jpg"));
    assertTrue(attachmentsPane.attachmentExistsByFileName("Test-slide1.jpg"));
    assertTrue(attachmentsPane.attachmentExistsByFileName("Test-slide2.jpg"));
    assertTrue(attachmentsPane.attachmentExistsByFileName("Test-slide3.jpg"));
    deletePage();
    // Test excel file
    resultPage = importFile("/msoffice.97-2003/Test.xls");
    assertTrue(StringUtils.contains(resultPage.getContent(), "Sheet1"));
    assertTrue(StringUtils.contains(resultPage.getContent(), "Sheet2"));
    deletePage();
    // Test ODT file
    resultPage = importFile("/ooffice.3.0/Test.odt");
    assertTrue(StringUtils.contains(resultPage.getContent(), "This is a test document."));
    deletePage();
    // Test ODP file
    resultPage = importFile("/ooffice.3.0/Test.odp");
    attachmentsPane = resultPage.openAttachmentsDocExtraPane();
    assertTrue(attachmentsPane.attachmentExistsByFileName("Test-slide0.jpg"));
    assertTrue(attachmentsPane.attachmentExistsByFileName("Test-slide1.jpg"));
    assertTrue(attachmentsPane.attachmentExistsByFileName("Test-slide2.jpg"));
    assertTrue(attachmentsPane.attachmentExistsByFileName("Test-slide3.jpg"));
    deletePage();
    // Test ODS file
    resultPage = importFile("/ooffice.3.0/Test.ods");
    assertTrue(StringUtils.contains(resultPage.getContent(), "Sheet1"));
    assertTrue(StringUtils.contains(resultPage.getContent(), "Sheet2"));
    deletePage();
}
Also used : AttachmentsPane(org.xwiki.test.ui.po.AttachmentsPane) ViewPage(org.xwiki.test.ui.po.ViewPage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 2 with AttachmentsPane

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

the class AttachmentTest method testUploadDownloadTwoAttachmentsInSequence.

@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testUploadDownloadTwoAttachmentsInSequence() {
    ViewPage vp = getUtil().createPage(getTestClassName(), getTestMethodName(), null, getTestClassName() + "#" + getTestMethodName());
    // TODO: Remove when XWIKI-6688 (Possible race condition when clicking on a tab at the bottom of a page in
    // view mode) is fixed.
    vp.waitForDocExtraPaneActive("comments");
    AttachmentsPane ap = vp.openAttachmentsDocExtraPane();
    ap.setFileToUpload(this.getClass().getResource("/" + this.testAttachment).getPath());
    ap.waitForUploadToFinish(this.testAttachment);
    ap.clickHideProgress();
    ap.setFileToUpload(this.getClass().getResource("/" + this.testAttachment2).getPath());
    ap.waitForUploadToFinish(this.testAttachment2);
    Assert.assertEquals("1.1", ap.getLatestVersionOfAttachment(this.testAttachment));
    Assert.assertEquals("1.1", ap.getLatestVersionOfAttachment(this.testAttachment2));
    // Verify attachment contents
    ap.getAttachmentLink(this.testAttachment).click();
    Assert.assertEquals("This is a small attachment.", getDriver().findElement(By.tagName("html")).getText());
    getDriver().navigate().back();
    vp.waitForDocExtraPaneActive("attachments");
    ap.getAttachmentLink(this.testAttachment2).click();
    Assert.assertEquals("This is another small attachment.", getDriver().findElement(By.tagName("html")).getText());
}
Also used : AttachmentsPane(org.xwiki.test.ui.po.AttachmentsPane) ViewPage(org.xwiki.test.ui.po.ViewPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 3 with AttachmentsPane

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

the class CompareVersionsTest method setUp.

@Before
public void setUp() throws Exception {
    String pageName = "PageWithManyVersions";
    // Check if the test page exists.
    testPage = getUtil().gotoPage(getTestClassName(), pageName);
    if (testPage.exists()) {
        // TODO: Remove when XWIKI-6688 (Possible race condition when clicking on a tab at the bottom of a page in
        // view mode) is fixed.
        testPage.waitForDocExtraPaneActive("comments");
        // versions of the test page.
        return;
    }
    // Since this test also verifies diffs when the parent/child relationship is modified, use this mode (which
    // isn't the default) for testing purpose. Also note that in the "reference" mode there's no diff to display
    // when the document is moved to a different parent since it means changing the identity of the document for
    // now and thus changing it means getting a new document.
    getUtil().setHierarchyMode("parentchild");
    getDriver().navigate().refresh();
    // Create the test page.
    testPage = getUtil().createPage(getTestClassName(), pageName, "one\ntwo\nthree", "Test");
    // Change the content and the meta data.
    WikiEditPage wikiEditPage = testPage.editWiki();
    wikiEditPage.setContent("one\n**two**\nfour");
    wikiEditPage.setTitle("Compare verSions test");
    wikiEditPage.setParent("Sandbox.WebHome");
    wikiEditPage.setEditComment("Changed content and meta data.");
    wikiEditPage.clickSaveAndContinue();
    wikiEditPage.setTitle("Compare versions test");
    wikiEditPage.setMinorEdit(true);
    wikiEditPage.setEditComment("Fix typo in title.");
    wikiEditPage.clickSaveAndContinue();
    // Add objects.
    ObjectEditPage objectEditPage = wikiEditPage.editObjects();
    FormElement form = objectEditPage.addObject("XWiki.JavaScriptExtension");
    Map<String, String> assignment = new HashMap<String, String>();
    assignment.put("XWiki.JavaScriptExtension_0_name", "JavaScript code");
    assignment.put("XWiki.JavaScriptExtension_0_code", "var tmp = alice;\nalice = bob;\nbob = tmp;");
    assignment.put("XWiki.JavaScriptExtension_0_use", "onDemand");
    form.fillFieldsByName(assignment);
    objectEditPage.clickSaveAndContinue();
    assignment.put("XWiki.JavaScriptExtension_0_name", "Code snippet");
    assignment.put("XWiki.JavaScriptExtension_0_code", "var tmp = alice;\nalice = 2 * bob;\nbob = tmp;");
    form.fillFieldsByName(assignment);
    objectEditPage.clickSaveAndContinue();
    // Create class.
    ClassEditPage classEditPage = objectEditPage.editClass();
    classEditPage.addProperty("age", "Number");
    classEditPage.addProperty("color", "String");
    classEditPage.getNumberClassEditElement("age").setNumberType("integer");
    classEditPage.clickSaveAndContinue();
    classEditPage.deleteProperty("color");
    testPage = classEditPage.clickSaveAndView();
    // Add tags.
    TaggablePage taggablePage = new TaggablePage();
    AddTagsPane addTagsPane = taggablePage.addTags();
    addTagsPane.setTags("foo,bar");
    addTagsPane.add();
    taggablePage.removeTag("foo");
    // Attach files.
    AttachmentsPane attachmentsPane = testPage.openAttachmentsDocExtraPane();
    // TODO: Update this code when we (re)add support for uploading multiple files at once.
    for (String fileName : new String[] { "SmallAttachment.txt", "SmallAttachment2.txt", "SmallAttachment.txt" }) {
        attachmentsPane.setFileToUpload(this.getClass().getResource('/' + fileName).getPath());
        attachmentsPane.waitForUploadToFinish(fileName);
        attachmentsPane.clickHideProgress();
    }
    attachmentsPane.deleteAttachmentByFileByName("SmallAttachment2.txt");
    // Add comments.
    getUtil().createUserAndLogin("Alice", "ecila");
    testPage = getUtil().gotoPage(getTestClassName(), pageName);
    CommentsTab commentsTab = testPage.openCommentsDocExtraPane();
    commentsTab.postComment("first line\nsecond line", true);
    commentsTab.editCommentByID(0, "first line\nline in between\nsecond line");
    commentsTab.replyToCommentByID(0, "this is a reply");
    commentsTab.deleteCommentByID(1);
}
Also used : ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) HashMap(java.util.HashMap) AttachmentsPane(org.xwiki.test.ui.po.AttachmentsPane) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) CommentsTab(org.xwiki.test.ui.po.CommentsTab) TaggablePage(org.xwiki.tag.test.po.TaggablePage) AddTagsPane(org.xwiki.tag.test.po.AddTagsPane) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) FormElement(org.xwiki.test.ui.po.FormElement) Before(org.junit.Before)

Example 4 with AttachmentsPane

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

the class RestoreDeletedPageTest method restore.

/**
 * @see "XWIKI-9421: Attachment version is incremented when a document is restored from recycle bin"
 */
@Test
public void restore() throws Exception {
    // Clean up.
    getUtil().rest().deletePage(getTestClassName(), getTestMethodName());
    // Create a new page.
    ViewPage page = getUtil().createPage(getTestClassName(), getTestMethodName(), "Once upon a time..", "A story");
    // Add an attachment.
    page.openAttachmentsDocExtraPane().setFileToUpload(getClass().getResource("/SmallAttachment.txt").getPath());
    // Delete the page.
    page.delete().clickYes();
    DeletingPage deletingPage = new DeletingPage();
    deletingPage.waitUntilIsTerminated();
    // Restore the page.
    page = deletingPage.getDeletePageOutcomePage().clickRestore();
    // Check the page title and content.
    assertEquals("A story", page.getDocumentTitle());
    assertEquals("Once upon a time..", page.getContent());
    // Check document version/history.
    HistoryPane historyPane = page.openHistoryDocExtraPane();
    assertEquals("2.1", historyPane.getCurrentVersion());
    // Check the attachment.
    AttachmentsPane attachmentsPane = page.openAttachmentsDocExtraPane();
    assertEquals(1, attachmentsPane.getNumberOfAttachments());
    assertEquals("1.1", attachmentsPane.getLatestVersionOfAttachment("SmallAttachment.txt"));
    // Check the attachment content.
    attachmentsPane.getAttachmentLink("SmallAttachment.txt").click();
    Assert.assertEquals("This is a small attachment.", getDriver().findElement(By.tagName("html")).getText());
}
Also used : DeletingPage(org.xwiki.test.ui.po.DeletingPage) AttachmentsPane(org.xwiki.test.ui.po.AttachmentsPane) ViewPage(org.xwiki.test.ui.po.ViewPage) HistoryPane(org.xwiki.test.ui.po.HistoryPane) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 5 with AttachmentsPane

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

the class AttachmentTest method testUploadDownloadTwoAttachmentsInParallel.

@Test
@Ignore("WebDriver doesn't support uploading multiple files in one input, see http://code.google.com/p/selenium/issues/detail?id=2239")
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testUploadDownloadTwoAttachmentsInParallel() {
    ViewPage vp = getUtil().createPage(getTestClassName(), getTestMethodName(), null, getTestClassName() + "#" + getTestMethodName());
    // TODO: Remove when XWIKI-6688 (Possible race condition when clicking on a tab at the bottom of a page in
    // view mode) is fixed.
    vp.waitForDocExtraPaneActive("comments");
    AttachmentsPane ap = vp.openAttachmentsDocExtraPane();
    ap.setFileToUpload(this.getClass().getResource("/" + this.testAttachment).getPath());
    ap.addAnotherFile();
    ap.setFileToUpload(this.getClass().getResource("/" + this.testAttachment2).getPath());
    ap.clickAttachFiles();
    Assert.assertEquals("1.1", ap.getLatestVersionOfAttachment(this.testAttachment));
    Assert.assertEquals("1.1", ap.getLatestVersionOfAttachment(this.testAttachment2));
    // Verify attachment contents
    ap.getAttachmentLink(this.testAttachment).click();
    Assert.assertEquals("This is a small attachment.", getDriver().findElement(By.tagName("html")).getText());
    getDriver().navigate().back();
    vp.waitForDocExtraPaneActive("attachments");
    ap.getAttachmentLink(this.testAttachment2).click();
    Assert.assertEquals("This is another small attachment.", getDriver().findElement(By.tagName("html")).getText());
}
Also used : AttachmentsPane(org.xwiki.test.ui.po.AttachmentsPane) ViewPage(org.xwiki.test.ui.po.ViewPage) Ignore(org.junit.Ignore) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Aggregations

AttachmentsPane (org.xwiki.test.ui.po.AttachmentsPane)7 Test (org.junit.Test)6 ViewPage (org.xwiki.test.ui.po.ViewPage)6 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)3 AbstractTest (org.xwiki.test.ui.AbstractTest)2 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 Ignore (org.junit.Ignore)1 CopyPage (org.xwiki.index.test.po.CopyPage)1 AddTagsPane (org.xwiki.tag.test.po.AddTagsPane)1 TaggablePage (org.xwiki.tag.test.po.TaggablePage)1 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)1 CommentsTab (org.xwiki.test.ui.po.CommentsTab)1 CopyOrRenameStatusPage (org.xwiki.test.ui.po.CopyOrRenameStatusPage)1 DeletingPage (org.xwiki.test.ui.po.DeletingPage)1 DocumentPicker (org.xwiki.test.ui.po.DocumentPicker)1 FormElement (org.xwiki.test.ui.po.FormElement)1 HistoryPane (org.xwiki.test.ui.po.HistoryPane)1 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)1 ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)1