Search in sources :

Example 6 with HistoryPane

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

the class ImportIT method testImportWithNewHistoryVersion.

@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 testImportWithNewHistoryVersion() {
    URL fileUrl = this.getClass().getResource("/" + PACKAGE_WITHOUT_HISTORY);
    this.sectionPage.attachPackage(fileUrl);
    this.sectionPage.selectPackage(PACKAGE_WITHOUT_HISTORY);
    this.sectionPage.importPackage();
    ViewPage importedPage = this.sectionPage.clickImportedPage("Main.TestPage");
    // Since the page by default opens the comments pane, if we instantly click on the history, the two tabs
    // will race for completion. Let's wait for comments first.
    importedPage.openCommentsDocExtraPane();
    HistoryPane history = importedPage.openHistoryDocExtraPane();
    Assert.assertEquals("1.1", history.getCurrentVersion());
    Assert.assertEquals("Imported from XAR", history.getCurrentVersionComment());
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) URL(java.net.URL) HistoryPane(org.xwiki.test.ui.po.HistoryPane) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 7 with HistoryPane

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

the class VersionTest method testDeleteLatestVersion.

/**
 * See XWIKI-8781
 */
@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 testDeleteLatestVersion() throws Exception {
    getUtil().rest().deletePage(SPACE_NAME, PAGE_NAME);
    // Create first version of the page
    ViewPage vp = getUtil().createPage(SPACE_NAME, PAGE_NAME, CONTENT1, TITLE);
    // Adds second version
    WikiEditPage wikiEditPage = vp.editWiki();
    wikiEditPage.setContent(CONTENT2);
    wikiEditPage.clickSaveAndView();
    // 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");
    // Verify and delete the latest version.
    HistoryPane historyTab = vp.openHistoryDocExtraPane();
    Assert.assertEquals("2.1", historyTab.getCurrentVersion());
    historyTab = historyTab.deleteVersion("2.1");
    // Verify that the current version is now the previous one.
    Assert.assertEquals("1.1", historyTab.getCurrentVersion());
    Assert.assertEquals("Administrator", historyTab.getCurrentAuthor());
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) HistoryPane(org.xwiki.test.ui.po.HistoryPane) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 8 with HistoryPane

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

the class CompareVersionsTest method testAllChanges.

/**
 * Tests that all changes are displayed.
 */
@Test
public void testAllChanges() {
    HistoryPane historyTab = testPage.openHistoryDocExtraPane().showMinorEdits();
    String currentVersion = historyTab.getCurrentVersion();
    // TODO: If the document has many versions, like in this case, the versions are paginated and currently there's
    // no way to compare two versions from two different pagination pages using the UI. Thus we have to build the
    // URL and load the compare page manually. Update the code when we remove this UI limitation.
    // ChangesPane changesPane = historyTab.compare("1.1", currentVersion).getChangesPane();
    String queryString = String.format("viewer=changes&rev1=1.1&rev2=%s", currentVersion);
    getUtil().gotoPage(getTestClassName(), testPage.getMetaDataValue("page"), "view", queryString);
    ChangesPane changesPane = new ChangesPane();
    // Version summary.
    String today = new SimpleDateFormat("yyyy/MM/dd").format(new Date());
    assertTrue(changesPane.getFromVersionSummary().startsWith("From version 1.1\nedited by Administrator\non " + today));
    assertTrue(changesPane.getToVersionSummary().startsWith("To version " + currentVersion + "\nedited by Alice\non " + today));
    assertEquals("Change comment: Deleted object", changesPane.getChangeComment());
    // Diff summary.
    DocumentDiffSummary diffSummary = changesPane.getDiffSummary();
    assertThat(Arrays.asList("Page properties", "Attachments", "Objects", "Class properties"), containsInAnyOrder(diffSummary.getItems().toArray()));
    assertEquals("(5 modified, 0 added, 0 removed)", diffSummary.getPagePropertiesSummary());
    assertEquals("(0 modified, 1 added, 0 removed)", diffSummary.getAttachmentsSummary());
    assertEquals("(0 modified, 2 added, 0 removed)", diffSummary.getObjectsSummary());
    assertEquals("(0 modified, 1 added, 0 removed)", diffSummary.getClassPropertiesSummary());
    assertEquals(Arrays.asList("SmallAttachment.txt"), diffSummary.toggleAttachmentsDetails().getAddedAttachments());
    assertEquals(Arrays.asList("XWiki.JavaScriptExtension[0]", "XWiki.XWikiComments[0]"), diffSummary.toggleObjectsDetails().getAddedObjects());
    assertEquals(Arrays.asList("age"), diffSummary.toggleClassPropertiesDetails().getAddedClassProperties());
    // Diff details.
    assertThat(Arrays.asList("Page properties", "SmallAttachment.txt", "XWiki.JavaScriptExtension[0]", "XWiki.XWikiComments[0]", "age"), containsInAnyOrder(changesPane.getChangedEntities().toArray()));
    // Page properties changes.
    EntityDiff pageProperties = changesPane.getEntityDiff("Page properties");
    assertThat(Arrays.asList("Title", "Parent", "Author", "Tags", "Content"), containsInAnyOrder(pageProperties.getPropertyNames().toArray()));
    assertDiff(pageProperties.getDiff("Title"), "-<del>T</del>est", "+<ins>Compar</ins>e<ins> ver</ins>s<ins>ions </ins>t<ins>est</ins>");
    assertDiff(pageProperties.getDiff("Parent"), "+Sandbox.WebHome");
    assertDiff(pageProperties.getDiff("Author"), "-XWiki.A<del>dm</del>i<del>n</del>", "+XWiki.A<ins>l</ins>i<ins>ce</ins>");
    assertDiff(pageProperties.getDiff("Tags"), "+bar");
    assertDiff(pageProperties.getDiff("Content"), "@@ -1,3 +1,3 @@", " one", "-two", "-<del>th</del>r<del>ee</del>", "+<ins>**</ins>two<ins>**</ins>", "+<ins>fou</ins>r");
    // Attachment changes.
    EntityDiff attachmentDiff = changesPane.getEntityDiff("SmallAttachment.txt");
    assertThat(Arrays.asList("Author", "Size", "Content"), containsInAnyOrder(attachmentDiff.getPropertyNames().toArray()));
    assertDiff(attachmentDiff.getDiff("Author"), "+XWiki.Admin");
    assertDiff(attachmentDiff.getDiff("Size"), "+27 bytes");
    assertDiff(attachmentDiff.getDiff("Content"), "+This is a small attachment.");
    // Object changes.
    EntityDiff jsxDiff = changesPane.getEntityDiff("XWiki.JavaScriptExtension[0]");
    assertThat(Arrays.asList("Caching policy", "Name", "Use this extension", "Code"), containsInAnyOrder(jsxDiff.getPropertyNames().toArray()));
    assertDiff(jsxDiff.getDiff("Caching policy"), "+long");
    assertDiff(jsxDiff.getDiff("Name"), "+Code snippet");
    assertDiff(jsxDiff.getDiff("Use this extension"), "+onDemand");
    assertDiff(jsxDiff.getDiff("Code"), "+var tmp = alice;", "+alice = 2 * bob;", "+bob = tmp;");
    // Comment changes.
    EntityDiff commentDiff = changesPane.getEntityDiff("XWiki.XWikiComments[0]");
    assertThat(Arrays.asList("Author", "Date", "Comment"), containsInAnyOrder(commentDiff.getPropertyNames().toArray()));
    assertDiff(commentDiff.getDiff("Author"), "+XWiki.Alice");
    assertEquals(2, commentDiff.getDiff("Date").size());
    assertDiff(commentDiff.getDiff("Comment"), "+first line", "+line in between", "+second line");
    // Class property changes.
    EntityDiff ageDiff = changesPane.getEntityDiff("age");
    assertThat(Arrays.asList("Name", "Number", "Pretty Name", "Size", "Number Type"), containsInAnyOrder(ageDiff.getPropertyNames().toArray()));
    assertDiff(ageDiff.getDiff("Name"), "+age");
    assertDiff(ageDiff.getDiff("Number"), "+1");
    assertDiff(ageDiff.getDiff("Pretty Name"), "+age");
    assertDiff(ageDiff.getDiff("Size"), "+30");
    assertDiff(ageDiff.getDiff("Number Type"), "+integer");
}
Also used : DocumentDiffSummary(org.xwiki.test.ui.po.diff.DocumentDiffSummary) SimpleDateFormat(java.text.SimpleDateFormat) EntityDiff(org.xwiki.test.ui.po.diff.EntityDiff) HistoryPane(org.xwiki.test.ui.po.HistoryPane) ChangesPane(org.xwiki.test.ui.po.ChangesPane) Date(java.util.Date) Test(org.junit.Test)

Example 9 with HistoryPane

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

the class CompareVersionsTest method testNoChanges.

/**
 * Tests that a message is displayed when there are no changes.
 */
@Test
public void testNoChanges() {
    HistoryPane historyTab = testPage.openHistoryDocExtraPane();
    String currentVersion = historyTab.getCurrentVersion();
    assertTrue(historyTab.compare(currentVersion, currentVersion).getChangesPane().hasNoChanges());
}
Also used : HistoryPane(org.xwiki.test.ui.po.HistoryPane) Test(org.junit.Test)

Aggregations

HistoryPane (org.xwiki.test.ui.po.HistoryPane)9 ViewPage (org.xwiki.test.ui.po.ViewPage)7 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)6 Test (org.junit.Test)5 AbstractTest (org.xwiki.test.ui.AbstractTest)5 URL (java.net.URL)4 WebElement (org.openqa.selenium.WebElement)2 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 AttachmentsPane (org.xwiki.test.ui.po.AttachmentsPane)1 ChangesPane (org.xwiki.test.ui.po.ChangesPane)1 DeletingPage (org.xwiki.test.ui.po.DeletingPage)1 DocumentDiffSummary (org.xwiki.test.ui.po.diff.DocumentDiffSummary)1 EntityDiff (org.xwiki.test.ui.po.diff.EntityDiff)1