Search in sources :

Example 1 with SimpleSearchPane

use of org.xwiki.extension.test.po.SimpleSearchPane in project xwiki-platform by xwiki.

the class ExtensionIT method testAdvancedSearch.

/**
 * Tests the advanced search form.
 */
@Test
public void testAdvancedSearch() {
    ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoCoreExtensions();
    SearchResultsPane searchResults = adminPage.getSearchBar().search("restlet");
    String version = searchResults.getExtension(0).getVersion();
    searchResults = new SimpleSearchPane().clickAdvancedSearch().search("org.restlet.jse:org.restlet", version);
    assertEquals(1, searchResults.getDisplayedResultsCount());
    assertNull(searchResults.getNoResultsMessage());
    ExtensionPane extension = searchResults.getExtension(0);
    assertEquals("core", extension.getStatus());
    assertTrue(extension.getName().toLowerCase().contains("restlet"));
    assertEquals(version, extension.getVersion());
    searchResults = new SimpleSearchPane().clickAdvancedSearch().search("foo", "bar");
    assertEquals(0, searchResults.getDisplayedResultsCount());
    assertNull(searchResults.getPagination());
    assertEquals("We couldn't find any extension with id 'foo' and version 'bar'. " + "Make sure you have the right extension repositories configured.", searchResults.getNoResultsMessage());
    // Test cancel advanced search.
    AdvancedSearchPane advancedSearchPane = new SimpleSearchPane().clickAdvancedSearch();
    advancedSearchPane.getIdInput().sendKeys("id");
    assertTrue(advancedSearchPane.getVersionInput().isDisplayed());
    advancedSearchPane.getCancelButton().click();
    assertFalse(advancedSearchPane.getVersionInput().isDisplayed());
}
Also used : ExtensionAdministrationPage(org.xwiki.extension.test.po.ExtensionAdministrationPage) SearchResultsPane(org.xwiki.extension.test.po.SearchResultsPane) SimpleSearchPane(org.xwiki.extension.test.po.SimpleSearchPane) ExtensionPane(org.xwiki.extension.test.po.ExtensionPane) AdvancedSearchPane(org.xwiki.extension.test.po.AdvancedSearchPane) Test(org.junit.Test)

Example 2 with SimpleSearchPane

use of org.xwiki.extension.test.po.SimpleSearchPane in project xwiki-platform by xwiki.

the class ExtensionIT method testCoreExtensions.

/**
 * Tests how core extensions are displayed.
 */
@Test
public void testCoreExtensions() {
    ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoCoreExtensions();
    // Assert that the core extension repository is selected.
    SimpleSearchPane searchBar = adminPage.getSearchBar();
    assertEquals("Core extensions", searchBar.getRepositorySelect().getFirstSelectedOption().getText());
    ExtensionPane extension = adminPage.getSearchResults().getExtension(RandomUtils.nextInt(0, 20));
    assertEquals("core", extension.getStatus());
    assertEquals("Provided", extension.getStatusMessage());
    assertNull(extension.getInstallButton());
    assertNull(extension.getUninstallButton());
    assertNull(extension.getUpgradeButton());
    assertNull(extension.getDowngradeButton());
    // Just test that the button to show the extension details is present.
    assertEquals("core", extension.showDetails().getStatus());
}
Also used : ExtensionAdministrationPage(org.xwiki.extension.test.po.ExtensionAdministrationPage) SimpleSearchPane(org.xwiki.extension.test.po.SimpleSearchPane) ExtensionPane(org.xwiki.extension.test.po.ExtensionPane) Test(org.junit.Test)

Example 3 with SimpleSearchPane

use of org.xwiki.extension.test.po.SimpleSearchPane 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());
}
Also used : ExtensionAdministrationPage(org.xwiki.extension.test.po.ExtensionAdministrationPage) DependencyPane(org.xwiki.extension.test.po.DependencyPane) ExtensionId(org.xwiki.extension.ExtensionId) TestExtension(org.xwiki.repository.test.TestExtension) ViewPage(org.xwiki.test.ui.po.ViewPage) ExtensionPane(org.xwiki.extension.test.po.ExtensionPane) SimpleSearchPane(org.xwiki.extension.test.po.SimpleSearchPane) DefaultVersionConstraint(org.xwiki.extension.version.internal.DefaultVersionConstraint) LogItemPane(org.xwiki.extension.test.po.LogItemPane) DefaultVersionConstraint(org.xwiki.extension.version.internal.DefaultVersionConstraint) SearchResultsPane(org.xwiki.extension.test.po.SearchResultsPane) DefaultExtensionDependency(org.xwiki.extension.DefaultExtensionDependency) Test(org.junit.Test)

Example 4 with SimpleSearchPane

use of org.xwiki.extension.test.po.SimpleSearchPane in project xwiki-platform by xwiki.

the class ExtensionIT method testFilterRecommended.

/**
 * Make sure recommended extension are properly filtered.
 */
@Test
public void testFilterRecommended() throws Exception {
    // Add recommended extension
    ExtensionId recommendedExtensionId = new ExtensionId("alice-xar-extension", "1.3");
    TestExtension recommendedExtension = getRepositoryTestUtils().getTestExtension(recommendedExtensionId, "xar");
    recommendedExtension.setRecommended(true);
    getRepositoryTestUtils().addExtension(recommendedExtension);
    // Add not recommended extension
    ExtensionId notRecommendedExtensionId = new ExtensionId("bob-xar-extension", "2.5-milestone-2");
    TestExtension notRecommendedExtension = getRepositoryTestUtils().getTestExtension(notRecommendedExtensionId, "xar");
    getRepositoryTestUtils().addExtension(notRecommendedExtension);
    // Make sure everything is ready
    getRepositoryTestUtils().waitUntilReady();
    ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
    // Empty search
    SearchResultsPane searchResults = adminPage.getSearchResults();
    assertNotNull(searchResults.getExtension(recommendedExtensionId));
    assertNull(searchResults.getExtension(notRecommendedExtensionId));
    // Search among recommended extensions
    SimpleSearchPane searchBar = adminPage.getSearchBar();
    searchResults = searchBar.search("alice-xar-extension");
    assertNotNull(searchResults.getExtension(recommendedExtensionId));
    assertNull(searchResults.getExtension(notRecommendedExtensionId));
    // Fallback on all extensions
    searchResults = searchBar.search("bob-xar-extension");
    assertNull(searchResults.getExtension(recommendedExtensionId));
    assertNotNull(searchResults.getExtension(notRecommendedExtensionId));
}
Also used : ExtensionAdministrationPage(org.xwiki.extension.test.po.ExtensionAdministrationPage) ExtensionId(org.xwiki.extension.ExtensionId) TestExtension(org.xwiki.repository.test.TestExtension) SearchResultsPane(org.xwiki.extension.test.po.SearchResultsPane) SimpleSearchPane(org.xwiki.extension.test.po.SimpleSearchPane) Test(org.junit.Test)

Example 5 with SimpleSearchPane

use of org.xwiki.extension.test.po.SimpleSearchPane in project xwiki-platform by xwiki.

the class ExtensionIT method testRepositorySelector.

/**
 * Tests the extension repository selector (all, core, installed, local).
 */
@Test
public void testRepositorySelector() throws Exception {
    // Setup the extension.
    ExtensionId extensionId = new ExtensionId("alice-xar-extension", "1.3");
    TestExtension extension = getRepositoryTestUtils().getTestExtension(extensionId, "xar");
    getRepositoryTestUtils().addExtension(extension);
    getRepositoryTestUtils().waitUntilReady();
    // Check that the Recommended Extensions are displayed by default.
    ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
    Select repositorySelect = adminPage.getSearchBar().getRepositorySelect();
    assertEquals("Recommended Extensions", repositorySelect.getFirstSelectedOption().getText());
    // Check that a remote extension appears only in the list of "All Extensions".
    adminPage.getSearchBar().selectRepository("installed");
    SearchResultsPane searchResults = adminPage.getSearchBar().search("alice");
    assertNull(searchResults.getExtension(extensionId));
    adminPage.getSearchBar().getRepositorySelect().selectByVisibleText("All Extensions");
    adminPage = new ExtensionAdministrationPage();
    adminPage.waitUntilPageIsLoaded();
    // The value of the search input must be preserved when we switch the repository.
    assertEquals("alice", adminPage.getSearchBar().getSearchInput().getAttribute("value"));
    assertNotNull(adminPage.getSearchResults().getExtension(extensionId));
    assertNull(new SimpleSearchPane().selectRepository("local").getExtension(extensionId));
    // Check that an installed extension appears also in "Installed Extensions" and "Local Extensions".
    getExtensionTestUtils().install(extensionId);
    adminPage = ExtensionAdministrationPage.gotoPage();
    adminPage.getSearchBar().selectRepository("installed");
    searchResults = adminPage.getSearchBar().search("alice");
    assertNotNull(searchResults.getExtension(extensionId));
    assertNotNull(new SimpleSearchPane().selectRepository("local").getExtension(extensionId));
    assertNotNull(new SimpleSearchPane().selectRepository("").getExtension(extensionId));
    // Check local extension.
    getExtensionTestUtils().uninstall(extensionId.getId(), true);
    adminPage = ExtensionAdministrationPage.gotoPage();
    adminPage.getSearchBar().selectRepository("installed");
    searchResults = adminPage.getSearchBar().search("alice");
    assertNull(searchResults.getExtension(extensionId));
    assertNotNull(new SimpleSearchPane().selectRepository("local").getExtension(extensionId));
    assertNotNull(new SimpleSearchPane().selectRepository("").getExtension(extensionId));
}
Also used : ExtensionAdministrationPage(org.xwiki.extension.test.po.ExtensionAdministrationPage) Select(org.openqa.selenium.support.ui.Select) ExtensionId(org.xwiki.extension.ExtensionId) TestExtension(org.xwiki.repository.test.TestExtension) SearchResultsPane(org.xwiki.extension.test.po.SearchResultsPane) SimpleSearchPane(org.xwiki.extension.test.po.SimpleSearchPane) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 ExtensionAdministrationPage (org.xwiki.extension.test.po.ExtensionAdministrationPage)7 SimpleSearchPane (org.xwiki.extension.test.po.SimpleSearchPane)7 SearchResultsPane (org.xwiki.extension.test.po.SearchResultsPane)6 ExtensionPane (org.xwiki.extension.test.po.ExtensionPane)5 ExtensionId (org.xwiki.extension.ExtensionId)4 TestExtension (org.xwiki.repository.test.TestExtension)4 DefaultVersionConstraint (org.xwiki.extension.version.internal.DefaultVersionConstraint)3 DefaultExtensionDependency (org.xwiki.extension.DefaultExtensionDependency)2 DependencyPane (org.xwiki.extension.test.po.DependencyPane)2 LogItemPane (org.xwiki.extension.test.po.LogItemPane)2 Select (org.openqa.selenium.support.ui.Select)1 AdvancedSearchPane (org.xwiki.extension.test.po.AdvancedSearchPane)1 UnusedPagesPane (org.xwiki.extension.test.po.UnusedPagesPane)1 ViewPage (org.xwiki.test.ui.po.ViewPage)1