Search in sources :

Example 6 with ViewPage

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

the class ExtensionIT method testUpgradeWithMergeConflict.

/**
 * Tests how an extension is upgraded when there is a merge conflict.
 */
@Test
public void testUpgradeWithMergeConflict() throws Exception {
    // Setup the extension.
    String extensionId = "alice-xar-extension";
    String oldVersion = "1.3";
    String newVersion = "2.1.4";
    TestExtension oldExtension = getRepositoryTestUtils().getTestExtension(new ExtensionId(extensionId, oldVersion), "xar");
    getRepositoryTestUtils().addExtension(oldExtension);
    TestExtension newExtension = getRepositoryTestUtils().getTestExtension(new ExtensionId(extensionId, newVersion), "xar");
    getRepositoryTestUtils().attachFile(newExtension);
    getRepositoryTestUtils().addVersionObject(newExtension, newVersion, "attach:" + newExtension.getFile().getName());
    // Make sure the old version is installed.
    getExtensionTestUtils().install(new ExtensionId(extensionId, oldVersion));
    // Edit the installed version so that we have a merge conflict.
    Map<String, String> queryParameters = new HashMap<String, String>();
    queryParameters.put("title", "Alice Extension");
    queryParameters.put("content", "== Usage ==\n\n{{code language=\"none\"}}\n" + "{{alice/}}\n{{/code}}\n\n== Output ==\n\n{{alice/}}");
    queryParameters.put("XWiki.WikiMacroClass_0_code", "{{info}}Alice says hello!{{/info}}");
    getUtil().gotoPage("ExtensionTest", "Alice", "save", queryParameters);
    // Initiate the upgrade process.
    ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
    SearchResultsPane searchResults = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId, newVersion);
    ExtensionPane extensionPane = searchResults.getExtension(0);
    extensionPane = extensionPane.upgrade().confirm();
    // Check the merge conflict UI.
    assertEquals("loading", extensionPane.getStatus());
    assertNull(extensionPane.getStatusMessage());
    ProgressBarPane progressBar = extensionPane.getProgressBar();
    assertEquals(66, progressBar.getPercent());
    assertEquals("Conflict between [@@ -1,1 +1,1 @@] and [@@ -1,1 +1,1 @@]", progressBar.getMessage());
    ExtensionProgressPane progressPane = extensionPane.openProgressSection();
    WebElement jobLogLabel = progressPane.getJobLogLabel();
    assertEquals("INSTALL LOG".toLowerCase(), jobLogLabel.getText().toLowerCase());
    // The job log is collapsed when the job is waiting for user input so we need to expand it before asserting its
    // content (otherwise #getText() returns the empty string because the text is not visible).
    jobLogLabel.click();
    List<LogItemPane> upgradeLog = progressPane.getJobLog();
    LogItemPane lastLogItem = upgradeLog.get(upgradeLog.size() - 1);
    assertEquals("loading", lastLogItem.getLevel());
    assertEquals(progressBar.getMessage(), lastLogItem.getMessage());
    MergeConflictPane mergeConflictPane = progressPane.getMergeConflict();
    ChangesPane changesPane = mergeConflictPane.getChanges();
    assertEquals(Arrays.asList("Page properties", "XWiki.WikiMacroClass[0]"), changesPane.getChangedEntities());
    EntityDiff pagePropertiesDiff = changesPane.getEntityDiff("Page properties");
    assertEquals(Arrays.asList("Parent", "Content"), pagePropertiesDiff.getPropertyNames());
    assertFalse(pagePropertiesDiff.getDiff("Content").isEmpty());
    EntityDiff macroDiff = changesPane.getEntityDiff("XWiki.WikiMacroClass[0]");
    assertEquals(Arrays.asList("Macro description"), macroDiff.getPropertyNames());
    assertEquals(Arrays.asList("@@ -1,1 +1,1 @@", "-<del>Test</del> macro.", "+<ins>A</ins> <ins>cool </ins>macro."), macroDiff.getDiff("Macro description"));
    mergeConflictPane.getFromVersionSelect().selectByVisibleText("Previous version");
    mergeConflictPane.getToVersionSelect().selectByVisibleText("Current version");
    mergeConflictPane = mergeConflictPane.clickShowChanges();
    changesPane = mergeConflictPane.getChanges();
    List<String> expectedDiff = new ArrayList<>();
    expectedDiff.add("@@ -1,9 +1,9 @@");
    expectedDiff.add("-= Usage =");
    expectedDiff.add("+=<ins>=</ins> Usage =<ins>=</ins>");
    expectedDiff.add(" ");
    expectedDiff.add("-{{code}}");
    expectedDiff.add("+{{code<ins> language=\"none\"</ins>}}");
    expectedDiff.add(" {{alice/}}");
    expectedDiff.add(" {{/code}}");
    expectedDiff.add(" ");
    expectedDiff.add("-= <del>Res</del>u<del>l</del>t =");
    expectedDiff.add("+=<ins>=</ins> <ins>O</ins>ut<ins>put</ins> =<ins>=</ins>");
    expectedDiff.add(" ");
    expectedDiff.add(" {{alice/}}");
    assertEquals(expectedDiff, changesPane.getEntityDiff("Page properties").getDiff("Content"));
    assertEquals(1, changesPane.getDiffSummary().toggleObjectsDetails().getModifiedObjects().size());
    assertEquals(Arrays.asList("@@ -1,1 +1,1 @@", "-Alice says hello!", "+<ins>{{info}}</ins>Alice says hello!<ins>{{/info}}</ins>"), changesPane.getEntityDiff("XWiki.WikiMacroClass[0]").getDiff("Macro code"));
    // Finish the merge.
    mergeConflictPane.getVersionToKeepSelect().selectByValue("NEXT");
    // FIXME: We get the extension pane from the search results because it is reloaded when we compare the versions.
    extensionPane = searchResults.getExtension(0).confirm();
    assertEquals("installed", extensionPane.getStatus());
    assertNull(extensionPane.getProgressBar());
    upgradeLog = extensionPane.openProgressSection().getJobLog();
    lastLogItem = upgradeLog.get(upgradeLog.size() - 1);
    assertEquals("info", lastLogItem.getLevel());
    assertEquals("Finished job of type [install] with identifier " + "[extension/action/alice-xar-extension/wiki:xwiki]", lastLogItem.getMessage());
    // Check the merge result.
    ViewPage mergedPage = getUtil().gotoPage("ExtensionTest", "Alice");
    assertEquals("Alice Wiki Macro (upgraded)", mergedPage.getDocumentTitle());
}
Also used : ExtensionAdministrationPage(org.xwiki.extension.test.po.ExtensionAdministrationPage) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TestExtension(org.xwiki.repository.test.TestExtension) ExtensionId(org.xwiki.extension.ExtensionId) ViewPage(org.xwiki.test.ui.po.ViewPage) ExtensionPane(org.xwiki.extension.test.po.ExtensionPane) ProgressBarPane(org.xwiki.extension.test.po.ProgressBarPane) WebElement(org.openqa.selenium.WebElement) EntityDiff(org.xwiki.test.ui.po.diff.EntityDiff) LogItemPane(org.xwiki.extension.test.po.LogItemPane) MergeConflictPane(org.xwiki.extension.test.po.MergeConflictPane) ExtensionProgressPane(org.xwiki.extension.test.po.ExtensionProgressPane) SearchResultsPane(org.xwiki.extension.test.po.SearchResultsPane) ChangesPane(org.xwiki.test.ui.po.ChangesPane) Test(org.junit.Test)

Example 7 with ViewPage

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

the class OfficeImporterTest method testSplitByHeadings.

@Test
public void testSplitByHeadings() {
    ViewPage resultPage = importFile("/ToSplit.odt", true);
    assertTrue(StringUtils.contains(resultPage.getContent(), "Introduction"));
    // See children
    testChild("First Part", "Hello, this is the first part of my story!");
    testChild("Second Part", "This is the second part of my story!");
    testChild("Last Part", "It's finished. Thanks you!");
    // Go back to the parent
    resultPage = getUtil().gotoPage(new DocumentReference("xwiki", getTestClassName(), getTestMethodName()));
    deletePageWithChildren(resultPage);
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 8 with ViewPage

use of org.xwiki.test.ui.po.ViewPage 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 9 with ViewPage

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

the class PanelTest method verifyApplicationsPanelEntry.

@Test
public void verifyApplicationsPanelEntry() {
    // Navigate to the Panels app by clicking in the Application Panel.
    // This verifies that the Panels application is registered in the Applications Panel.
    // It also verifies that the Translation is registered properly.
    ApplicationsPanel applicationPanel = ApplicationsPanel.gotoPage();
    ViewPage vp = applicationPanel.clickApplication("Panels");
    // Verify we're on the right page!
    assertEquals(PanelsHomePage.getSpace(), vp.getMetaDataValue("space"));
    assertEquals(PanelsHomePage.getPage(), vp.getMetaDataValue("page"));
    // Now log out to verify that the Panels entry is not displayed for non admin users
    getUtil().forceGuestUser();
    // Navigate again to the Application Panels page to perform the verification
    applicationPanel = ApplicationsPanel.gotoPage();
    assertFalse(applicationPanel.containsApplication("Panels"));
}
Also used : ApplicationsPanel(org.xwiki.panels.test.po.ApplicationsPanel) ViewPage(org.xwiki.test.ui.po.ViewPage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 10 with ViewPage

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

the class ApplicationsPanelAdministrationTest method createApplicationUIX.

private void createApplicationUIX(String applicationName) {
    getUtil().deletePage(new LocalDocumentReference(Arrays.asList("Apps", applicationName), "WebHome"));
    ViewPage page = getUtil().gotoPage("Apps", applicationName);
    ObjectEditPage editPage = page.editObjects();
    ObjectEditPane object = editPage.addObject("XWiki.UIExtensionClass");
    fillField(object, "extensionPointId", "org.xwiki.platform.panels.Applications");
    fillField(object, "name", applicationName);
    fillField(object, "parameters", String.format("label=%s\ntarget=Apps.%s\nicon=icon:home", applicationName, applicationName));
    editPage.clickSaveAndView();
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) ObjectEditPane(org.xwiki.test.ui.po.editor.ObjectEditPane) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage)

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