Search in sources :

Example 6 with SearchResultsPane

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

the class ExtensionIT method testPagination.

/**
 * The extension search results pagination.
 */
@Test
public void testPagination() {
    ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoCoreExtensions();
    SearchResultsPane searchResults = adminPage.getSearchResults();
    assertNull(searchResults.getNoResultsMessage());
    assertEquals(20, searchResults.getDisplayedResultsCount());
    PaginationFilterPane pagination = searchResults.getPagination();
    assertEquals((pagination.getResultsCount() + 20 - 1) / 20, pagination.getPageCount());
    assertEquals("1 - 20", pagination.getCurrentRange());
    assertEquals(1, pagination.getCurrentPageIndex());
    assertFalse(pagination.hasPreviousPage());
    assertTrue(pagination.hasNextPage());
    assertTrue(pagination.getPageCount() > 5);
    assertTrue(pagination.getResultsCount() > 100);
    String firstExtensionName = searchResults.getExtension(0).getName();
    pagination = pagination.gotoPage(4);
    searchResults = new SearchResultsPane();
    assertEquals(20, searchResults.getDisplayedResultsCount());
    assertEquals("61 - 80", pagination.getCurrentRange());
    assertEquals(4, pagination.getCurrentPageIndex());
    assertTrue(pagination.hasNextPage());
    String secondExtensionName = searchResults.getExtension(0).getName();
    assertFalse(firstExtensionName.equals(secondExtensionName));
    pagination = pagination.previousPage();
    searchResults = new SearchResultsPane();
    assertEquals(20, searchResults.getDisplayedResultsCount());
    assertEquals("41 - 60", pagination.getCurrentRange());
    assertEquals(3, pagination.getCurrentPageIndex());
    String thirdExtensionName = searchResults.getExtension(0).getName();
    assertFalse(firstExtensionName.equals(thirdExtensionName));
    assertFalse(secondExtensionName.equals(thirdExtensionName));
    pagination = pagination.nextPage();
    searchResults = new SearchResultsPane();
    assertEquals(20, searchResults.getDisplayedResultsCount());
    assertEquals("61 - 80", pagination.getCurrentRange());
    assertEquals(4, pagination.getCurrentPageIndex());
    assertEquals(secondExtensionName, searchResults.getExtension(0).getName());
    pagination = pagination.gotoPage(pagination.getPageCount());
    searchResults = new SearchResultsPane();
    assertEquals(((pagination.getResultsCount() - 1) % 20) + 1, searchResults.getDisplayedResultsCount());
    assertEquals(pagination.getPageCount(), pagination.getCurrentPageIndex());
    assertFalse(pagination.hasNextPage());
    assertTrue(pagination.hasPreviousPage());
}
Also used : ExtensionAdministrationPage(org.xwiki.extension.test.po.ExtensionAdministrationPage) SearchResultsPane(org.xwiki.extension.test.po.SearchResultsPane) PaginationFilterPane(org.xwiki.extension.test.po.PaginationFilterPane) Test(org.junit.Test)

Example 7 with SearchResultsPane

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

the class ExtensionIT method testSimpleSearch.

/**
 * Tests the simple search form.
 */
@Test
public void testSimpleSearch() {
    ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoCoreExtensions();
    int coreExtensionCount = adminPage.getSearchResults().getPagination().getResultsCount();
    SimpleSearchPane searchBar = adminPage.getSearchBar();
    // Check if the tip is displayed.
    assertEquals("search extension...", searchBar.getSearchInput().getAttribute("placeholder"));
    // Check that the input is empty
    assertEquals("", searchBar.getSearchInput().getAttribute("value"));
    SearchResultsPane searchResults = searchBar.search("XWiki Commons");
    assertTrue(searchResults.getPagination().getResultsCount() < coreExtensionCount);
    // Make sure the search input is not cleared.
    searchBar = new SimpleSearchPane();
    assertEquals("XWiki Commons", searchBar.getSearchInput().getAttribute("value"));
    assertNull(searchResults.getNoResultsMessage());
    // Check that the results match the search query.
    for (int i = 0; i < searchResults.getPagination().getPageCount(); i++) {
        ExtensionPane extension = searchResults.getExtension(i);
        assertTrue("Can't find [commons] in the summary/id/name parts of extension [" + extension.getId() + "] (" + extension.getSummary() + ")", extension.getSummary().toLowerCase().contains("commons") || extension.getId().getId().toLowerCase().contains("commons") || extension.getName().toLowerCase().contains("commons"));
        assertEquals("core", extension.getStatus());
    }
    // Test search query with no results.
    searchResults = new SimpleSearchPane().search("blahblah");
    assertEquals(0, searchResults.getDisplayedResultsCount());
    assertNull(searchResults.getPagination());
    assertEquals("There were no extensions found matching 'blahblah'. Try different keywords. " + "Alternatively, if you know the identifier and the version of the extension you're " + "looking for, you can use the Advanced Search form above.", searchResults.getNoResultsMessage());
    // Test a search query with only a few results (only one page).
    searchResults = searchBar.search("restlet");
    assertNull(searchResults.getNoResultsMessage());
    assertNull(searchResults.getPagination());
    assertTrue(searchResults.getDisplayedResultsCount() > 1);
    ExtensionPane extension = searchResults.getExtension(0);
    assertEquals("core", extension.getStatus());
    assertTrue("Can't find [restlet] in the name of the extension [" + extension.getId() + "] (" + extension.getName() + ")", extension.getName().toLowerCase().contains("restlet"));
}
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) DefaultVersionConstraint(org.xwiki.extension.version.internal.DefaultVersionConstraint) Test(org.junit.Test)

Example 8 with SearchResultsPane

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

the class ExtensionIT method testUninstall.

/**
 * Tests how an extension is uninstalled.
 */
@Test
public void testUninstall() throws Exception {
    // Setup the extension and its dependencies.
    ExtensionId dependencyId = new ExtensionId("bob-xar-extension", "2.5-milestone-2");
    getRepositoryTestUtils().addExtension(getRepositoryTestUtils().getTestExtension(dependencyId, "xar"));
    ExtensionId extensionId = new ExtensionId("alice-xar-extension", "1.3");
    TestExtension extension = getRepositoryTestUtils().getTestExtension(extensionId, "xar");
    extension.addDependency(new DefaultExtensionDependency(dependencyId.getId(), new DefaultVersionConstraint(dependencyId.getVersion().getValue())));
    getRepositoryTestUtils().addExtension(extension);
    // Install the extensions.
    getExtensionTestUtils().install(extensionId);
    // Check if the installed pages are present.
    assertTrue(getUtil().pageExists("ExtensionTest", "Alice"));
    assertTrue(getUtil().pageExists("ExtensionTest", "Bob"));
    // Uninstall the dependency.
    ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoInstalledExtensions();
    ExtensionPane extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(dependencyId).getExtension(0);
    extensionPane = extensionPane.uninstall();
    // Check the uninstall plan. Both extensions should be included.
    List<DependencyPane> uninstallPlan = extensionPane.openProgressSection().getJobPlan();
    assertEquals(2, uninstallPlan.size());
    assertEquals(extensionId, uninstallPlan.get(0).getId());
    assertEquals("installed", uninstallPlan.get(0).getStatus());
    assertEquals("Installed", uninstallPlan.get(0).getStatusMessage());
    assertEquals(dependencyId, uninstallPlan.get(1).getId());
    assertEquals("installed-dependency", uninstallPlan.get(1).getStatus());
    assertEquals("Installed as dependency", uninstallPlan.get(1).getStatusMessage());
    // Check the confirmation to delete the unused wiki pages.
    extensionPane = extensionPane.confirm();
    UnusedPagesPane unusedPages = extensionPane.openProgressSection().getUnusedPages();
    assertTrue(unusedPages.contains("ExtensionTest", "Alice"));
    assertTrue(unusedPages.contains("ExtensionTest", "Bob"));
    // Finish the uninstall and check the log.
    extensionPane = extensionPane.confirm();
    List<LogItemPane> log = extensionPane.openProgressSection().getJobLog();
    assertTrue(log.size() > 2);
    assertEquals("info", log.get(2).getLevel());
    assertEquals("Resolving extension [bob-xar-extension 2.5-milestone-2] from namespace [Home]", log.get(2).getMessage());
    assertEquals("info", log.get(log.size() - 1).getLevel());
    assertEquals("Finished job of type [uninstall] with identifier " + "[extension/action/bob-xar-extension/wiki:xwiki]", log.get(log.size() - 1).getMessage());
    // Check if the uninstalled pages have been deleted.
    assertFalse(getUtil().pageExists("ExtensionTest", "Alice"));
    assertFalse(getUtil().pageExists("ExtensionTest", "Bob"));
    // Install both extension again and uninstall only the one with the dependency.
    getExtensionTestUtils().install(extensionId);
    adminPage = ExtensionAdministrationPage.gotoInstalledExtensions();
    extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId).getExtension(0);
    extensionPane = extensionPane.uninstall();
    // Check the uninstall plan. Only one extension should be included.
    uninstallPlan = extensionPane.openProgressSection().getJobPlan();
    assertEquals(1, uninstallPlan.size());
    assertEquals(extensionId, uninstallPlan.get(0).getId());
    // Check the confirmation to delete the unused wiki pages.
    extensionPane = extensionPane.confirm();
    unusedPages = extensionPane.openProgressSection().getUnusedPages();
    assertTrue(unusedPages.contains("ExtensionTest", "Alice"));
    assertFalse(unusedPages.contains("ExtensionTest", "Bob"));
    // Finish the uninstall and check the log.
    log = extensionPane.confirm().openProgressSection().getJobLog();
    assertTrue(log.size() > 2);
    assertEquals("info", log.get(2).getLevel());
    assertEquals("Resolving extension [alice-xar-extension 1.3] from namespace [Home]", log.get(2).getMessage());
    assertEquals("info", log.get(log.size() - 1).getLevel());
    assertEquals("Finished job of type [uninstall] with identifier " + "[extension/action/alice-xar-extension/wiki:xwiki]", log.get(log.size() - 1).getMessage());
    // Check if the uninstalled pages have been deleted.
    assertFalse(getUtil().pageExists("ExtensionTest", "Alice"));
    assertTrue(getUtil().pageExists("ExtensionTest", "Bob"));
    // Check the list of installed extensions. It should contain only the second extension.
    adminPage = ExtensionAdministrationPage.gotoInstalledExtensions();
    SearchResultsPane searchResults = adminPage.getSearchBar().search("alice");
    assertEquals(0, searchResults.getDisplayedResultsCount());
    assertNotNull(searchResults.getNoResultsMessage());
    searchResults = new SimpleSearchPane().search("bob");
    assertEquals(1, searchResults.getDisplayedResultsCount());
    extensionPane = searchResults.getExtension(0);
    assertEquals("installed-dependency", extensionPane.getStatus());
    assertEquals(dependencyId, extensionPane.getId());
}
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) ExtensionPane(org.xwiki.extension.test.po.ExtensionPane) SimpleSearchPane(org.xwiki.extension.test.po.SimpleSearchPane) 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) UnusedPagesPane(org.xwiki.extension.test.po.UnusedPagesPane) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)8 ExtensionAdministrationPage (org.xwiki.extension.test.po.ExtensionAdministrationPage)8 SearchResultsPane (org.xwiki.extension.test.po.SearchResultsPane)8 SimpleSearchPane (org.xwiki.extension.test.po.SimpleSearchPane)6 ExtensionId (org.xwiki.extension.ExtensionId)5 ExtensionPane (org.xwiki.extension.test.po.ExtensionPane)5 TestExtension (org.xwiki.repository.test.TestExtension)5 LogItemPane (org.xwiki.extension.test.po.LogItemPane)3 DefaultVersionConstraint (org.xwiki.extension.version.internal.DefaultVersionConstraint)3 DefaultExtensionDependency (org.xwiki.extension.DefaultExtensionDependency)2 DependencyPane (org.xwiki.extension.test.po.DependencyPane)2 ViewPage (org.xwiki.test.ui.po.ViewPage)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 WebElement (org.openqa.selenium.WebElement)1 Select (org.openqa.selenium.support.ui.Select)1 AdvancedSearchPane (org.xwiki.extension.test.po.AdvancedSearchPane)1 ExtensionProgressPane (org.xwiki.extension.test.po.ExtensionProgressPane)1 MergeConflictPane (org.xwiki.extension.test.po.MergeConflictPane)1 PaginationFilterPane (org.xwiki.extension.test.po.PaginationFilterPane)1