use of org.xwiki.extension.test.po.ExtensionPane in project xwiki-platform by xwiki.
the class ExtensionIT method testInstall.
/**
* Tests how an extension is installed.
*/
@Test
public void testInstall() throws Exception {
// Setup the extension and its dependencies.
ExtensionId extensionId = new ExtensionId("alice-xar-extension", "1.3");
TestExtension extension = getRepositoryTestUtils().getTestExtension(extensionId, "xar");
ExtensionId dependencyId = new ExtensionId("bob-xar-extension", "2.5-milestone-2");
getRepositoryTestUtils().addExtension(getRepositoryTestUtils().getTestExtension(dependencyId, "xar"));
extension.addDependency(new DefaultExtensionDependency(dependencyId.getId(), new DefaultVersionConstraint(dependencyId.getVersion().getValue())));
extension.addDependency(new DefaultExtensionDependency("org.xwiki.platform:xwiki-platform-sheet-api", new DefaultVersionConstraint("[3.2,)")));
getRepositoryTestUtils().addExtension(extension);
// Search the extension and install it.
ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
ExtensionPane extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId).getExtension(0);
extensionPane = extensionPane.install();
// Assert the install plan.
List<DependencyPane> installPlan = extensionPane.openProgressSection().getJobPlan();
assertEquals(2, installPlan.size());
assertEquals(dependencyId, installPlan.get(0).getId());
assertEquals(extensionId, installPlan.get(1).getId());
// Finish the install and assert the install log.
List<LogItemPane> log = extensionPane.confirm().openProgressSection().getJobLog();
int logSize = log.size();
assertTrue(logSize > 1);
assertEquals("info", log.get(0).getLevel());
assertEquals("Starting job of type [install] with identifier " + "[extension/action/alice-xar-extension/wiki:xwiki]", log.get(0).getMessage());
assertEquals("info", log.get(logSize - 1).getLevel());
assertEquals("Finished job of type [install] with identifier " + "[extension/action/alice-xar-extension/wiki:xwiki]", log.get(logSize - 1).getMessage());
// Test that both extensions are usable.
ViewPage viewPage = getUtil().createPage(getTestClassName(), getTestMethodName(), "{{alice/}}\n\n{{bob/}}", "");
String content = viewPage.getContent();
assertTrue(content.contains("Alice says hello!"));
assertTrue(content.contains("Bob says hi!"));
// Check the list of installed extensions.
adminPage = ExtensionAdministrationPage.gotoInstalledExtensions();
SearchResultsPane searchResults = adminPage.getSearchBar().search("bob");
assertEquals(1, searchResults.getDisplayedResultsCount());
extensionPane = searchResults.getExtension(0);
assertEquals("installed-dependency", extensionPane.getStatus());
assertEquals("Installed as dependency", extensionPane.getStatusMessage());
assertEquals(dependencyId, extensionPane.getId());
assertNotNull(extensionPane.getUninstallButton());
searchResults = new SimpleSearchPane().search("alice");
assertEquals(1, searchResults.getDisplayedResultsCount());
extensionPane = searchResults.getExtension(0);
assertEquals("installed", extensionPane.getStatus());
assertEquals("Installed", extensionPane.getStatusMessage());
assertEquals(extensionId, extensionPane.getId());
assertNotNull(extensionPane.getUninstallButton());
// Check if the progress log is persisted.
extensionPane = extensionPane.showDetails();
log = extensionPane.openProgressSection().getJobLog();
assertEquals(logSize, log.size());
assertEquals("info", log.get(0).getLevel());
assertEquals("Starting job of type [install] with identifier " + "[extension/action/alice-xar-extension/wiki:xwiki]", log.get(0).getMessage());
assertEquals("info", log.get(logSize - 1).getLevel());
assertEquals("Finished job of type [install] with identifier " + "[extension/action/alice-xar-extension/wiki:xwiki]", log.get(logSize - 1).getMessage());
// Check if the dependency is properly listed as installed.
List<DependencyPane> dependencies = extensionPane.openDependenciesSection().getDirectDependencies();
assertEquals(2, dependencies.size());
assertEquals(dependencyId, dependencies.get(0).getId());
assertEquals("installed-dependency", dependencies.get(0).getStatus());
assertEquals("Installed as dependency", dependencies.get(0).getStatusMessage());
// Check the backward dependency.
dependencies.get(0).getLink().click();
extensionPane = new ExtensionAdministrationPage().getSearchResults().getExtension(0);
dependencies = extensionPane.openDependenciesSection().getBackwardDependencies();
assertEquals(1, dependencies.size());
assertEquals(extensionId, dependencies.get(0).getId());
assertEquals("installed", dependencies.get(0).getStatus());
assertEquals("Installed", dependencies.get(0).getStatusMessage());
}
use of org.xwiki.extension.test.po.ExtensionPane in project xwiki-platform by xwiki.
the class ExtensionIT method testShowDetails.
/**
* Tests the extension details (license, web site).
*/
@Test
public void testShowDetails() throws Exception {
// Setup the extension.
ExtensionId extensionId = new ExtensionId("alice-xar-extension", "1.3");
TestExtension extension = getRepositoryTestUtils().getTestExtension(extensionId, "xar");
extension.setName("Alice Wiki Macro");
extension.setSummary("A **useless** macro");
extension.addAuthor(new DefaultExtensionAuthor("Thomas", (String) null));
extension.addAuthor(new DefaultExtensionAuthor("Marius", (String) null));
extension.addFeature("alice-extension");
extension.addLicense(new ExtensionLicense("My own license", null));
extension.setWebsite("http://www.alice.com");
extension.setScm(new DefaultExtensionScm("https://github.com/xwiki-contrib/alice-xar-extension", new DefaultExtensionScmConnection("git", "git://github.com/xwiki-contrib/alice-xar-extension.git"), new DefaultExtensionScmConnection("git", "git:git@github.com:xwiki-contrib/alice-xar-extension.git")));
extension.setIssueManagement(new DefaultExtensionIssueManagement("jira", "https://jira.xwiki.org/browse/ALICE"));
getRepositoryTestUtils().addExtension(extension);
// Search the extension and assert the displayed information.
ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
ExtensionPane extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId).getExtension(0);
assertEquals("remote", extensionPane.getStatus());
assertNull(extensionPane.getStatusMessage());
assertEquals(extension.getName(), extensionPane.getName());
assertEquals(extensionId.getVersion().getValue(), extensionPane.getVersion());
List<WebElement> authors = extensionPane.getAuthors();
assertEquals(2, authors.size());
assertEquals("Thomas", authors.get(0).getText());
assertEquals("Marius", authors.get(1).getText());
assertEquals(extension.getSummary(), extensionPane.getSummary());
// Check the extension details.
ExtensionDescriptionPane descriptionPane = extensionPane.openDescriptionSection();
assertEquals(extension.getLicenses().iterator().next().getName(), descriptionPane.getLicense());
assertEquals(extension.getId().getId(), descriptionPane.getId());
assertEquals(extension.getFeatures().iterator().next(), descriptionPane.getFeatures().get(0));
assertEquals(extension.getType(), descriptionPane.getType());
WebElement webSiteLink = descriptionPane.getWebSite();
assertEquals(extension.getWebSite().substring("http://".length()), webSiteLink.getText());
assertEquals(extension.getWebSite() + '/', webSiteLink.getAttribute("href"));
// Install the extension to check the details that are specific to installed extensions.
Date beforeInstall = new Date();
descriptionPane = extensionPane.install().confirm().openDescriptionSection();
Date afterInstall = new Date();
List<String> namespaces = descriptionPane.getNamespaces();
assertEquals(1, namespaces.size());
String prefix = "Home, by superadmin on ";
assertTrue(namespaces.get(0).startsWith(prefix));
Date installDate = new SimpleDateFormat("yyyy/MM/dd HH:mm").parse(namespaces.get(0).substring(prefix.length()));
// Ignore the seconds as they are not displayed.
assertTrue(String.format("Install date [%s] should be after [%s].", installDate, beforeInstall), installDate.getTime() / 60000 >= beforeInstall.getTime() / 60000);
assertTrue(String.format("Install date [%s] should be before [%s].", installDate, afterInstall), installDate.before(afterInstall));
}
use of org.xwiki.extension.test.po.ExtensionPane in project xwiki-platform by xwiki.
the class ExtensionIT method testUpgrade.
/**
* Tests how an extension is upgraded.
*/
@Test
public void testUpgrade() 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));
// Upgrade the extension.
ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
ExtensionPane extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId, newVersion).getExtension(0);
assertEquals("remote-installed", extensionPane.getStatus());
assertEquals("Version 1.3 is installed", extensionPane.getStatusMessage());
extensionPane = extensionPane.upgrade();
// Check the upgrade plan.
List<DependencyPane> upgradePlan = extensionPane.openProgressSection().getJobPlan();
assertEquals(1, upgradePlan.size());
assertEquals(extensionId, upgradePlan.get(0).getName());
assertEquals(newVersion, upgradePlan.get(0).getVersion());
assertEquals("remote-installed", upgradePlan.get(0).getStatus());
assertEquals("Version 1.3 is installed", upgradePlan.get(0).getStatusMessage());
// Finish the upgrade and check the upgrade log.
extensionPane = extensionPane.confirm();
assertEquals("installed", extensionPane.getStatus());
assertEquals("Installed", extensionPane.getStatusMessage());
List<LogItemPane> log = extensionPane.openProgressSection().getJobLog();
assertTrue(log.size() > 2);
assertEquals("info", log.get(2).getLevel());
assertEquals("Resolving extension [alice-xar-extension 2.1.4] on namespace [Home]", log.get(2).getMessage());
assertEquals("info", log.get(log.size() - 1).getLevel());
assertEquals("Finished job of type [install] with identifier " + "[extension/action/alice-xar-extension/wiki:xwiki]", log.get(log.size() - 1).getMessage());
// Assert the changes.
ViewPage viewPage = getUtil().gotoPage("ExtensionTest", "Alice");
assertEquals("Alice Wiki Macro (upgraded)", viewPage.getDocumentTitle());
assertTrue(viewPage.getContent().contains("Alice says hi guys!"));
}
use of org.xwiki.extension.test.po.ExtensionPane 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());
}
use of org.xwiki.extension.test.po.ExtensionPane in project xwiki-platform by xwiki.
the class ExtensionIT method testInstallAndUninstallWithoutReload.
/**
* Tests that an extension can be installed and uninstalled without reloading the extension manager UI.
*/
@Test
public void testInstallAndUninstallWithoutReload() throws Exception {
// Setup the extension.
ExtensionId extensionId = new ExtensionId("alice-xar-extension", "1.3");
getRepositoryTestUtils().addExtension(getRepositoryTestUtils().getTestExtension(extensionId, "xar"));
// Search the extension to install.
ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
ExtensionPane extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId).getExtension(0);
// Install and uninstall.
extensionPane = extensionPane.install().confirm().uninstall().confirm().confirm().install();
assertEquals("remote", extensionPane.getStatus());
}
Aggregations