Skip to content
Snippets Groups Projects
Commit ddb51dd4 authored by Pierre Jeanjean's avatar Pierre Jeanjean Committed by Thomas Mortagne
Browse files

XWIKI-22185: Solr suggest does not work, no suggestions result (#3134)

* Fix JSON serialization
* Add UI test
* Document page objects
* Put all Solr related tests together

(cherry picked from commit 265003d1)
parent e7fdd649
No related branches found
No related tags found
No related merge requests found
Showing
with 211 additions and 101 deletions
......@@ -67,7 +67,7 @@
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-solr-test-utils</artifactId>
<artifactId>xwiki-platform-search-test-utils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
......
......@@ -33,8 +33,6 @@
import org.xwiki.test.docker.junit5.TestConfiguration;
import org.xwiki.test.docker.junit5.TestReference;
import org.xwiki.test.docker.junit5.UITest;
import org.xwiki.test.docker.junit5.servletengine.ServletEngine;
import org.xwiki.test.integration.XWikiExecutor;
import org.xwiki.test.ui.TestUtils;
import static org.hamcrest.MatcherAssert.assertThat;
......@@ -85,7 +83,7 @@ void attachmentGalleryPickerMacro(TestUtils setup, TestReference testReference,
attachmentsPane.waitForUploadToFinish("textcontent.txt");
// Waits for the uploaded files to be indexed before continuing.
new SolrTestUtils(setup, computedHostURL(testConfiguration)).waitEmptyQueue();
new SolrTestUtils(setup, testConfiguration.getServletEngine()).waitEmptyQueue();
// Reload the page to see the file after the uploads and solr indexing.
setup.getDriver().navigate().refresh();
......@@ -154,11 +152,4 @@ void attachmentGalleryPickerMacro(TestUtils setup, TestReference testReference,
testPicker3.setSearch("textcontent").waitUntilAttachmentsCount(count -> count == 0);
testPicker3.waitNoResultMessageDisplayed();
}
private String computedHostURL(TestConfiguration testConfiguration)
{
ServletEngine servletEngine = testConfiguration.getServletEngine();
return String.format("http://%s:%d%s", servletEngine.getIP(), servletEngine.getPort(),
XWikiExecutor.DEFAULT_CONTEXT);
}
}
......@@ -50,7 +50,7 @@
<dependency>
<!-- Required for tests involving solr indexation (e.g., page/attachment search in link insertions). -->
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-solr-test-utils</artifactId>
<artifactId>xwiki-platform-search-test-utils</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
......
......@@ -28,8 +28,6 @@
import org.xwiki.repository.test.SolrTestUtils;
import org.xwiki.test.docker.junit5.TestConfiguration;
import org.xwiki.test.docker.junit5.TestReference;
import org.xwiki.test.docker.junit5.servletengine.ServletEngine;
import org.xwiki.test.integration.XWikiExecutor;
import org.xwiki.test.ui.TestUtils;
import org.xwiki.test.ui.po.ViewPage;
import org.xwiki.test.ui.po.editor.WYSIWYGEditPage;
......@@ -131,13 +129,6 @@ protected void maybeLeaveEditMode(TestUtils setup, TestReference testReference)
protected void waitForSolrIndexing(TestUtils setup, TestConfiguration testConfiguration) throws Exception
{
new SolrTestUtils(setup, computedHostURL(testConfiguration)).waitEmptyQueue();
}
protected String computedHostURL(TestConfiguration testConfiguration)
{
ServletEngine servletEngine = testConfiguration.getServletEngine();
return String.format("http://%s:%d%s", servletEngine.getIP(), servletEngine.getPort(),
XWikiExecutor.DEFAULT_CONTEXT);
new SolrTestUtils(setup, testConfiguration.getServletEngine()).waitEmptyQueue();
}
}
......@@ -178,7 +178,7 @@
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-solr-test-utils</artifactId>
<artifactId>xwiki-platform-search-test-utils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
......
......@@ -25,8 +25,6 @@
import org.xwiki.test.docker.junit5.TestConfiguration;
import org.xwiki.test.docker.junit5.TestReference;
import org.xwiki.test.docker.junit5.UITest;
import org.xwiki.test.docker.junit5.servletengine.ServletEngine;
import org.xwiki.test.integration.XWikiExecutor;
import org.xwiki.test.ui.TestUtils;
import org.xwiki.test.ui.po.ViewPage;
......@@ -74,17 +72,10 @@ void backlinks(TestUtils setup, TestReference reference, TestConfiguration testC
null);
// Wait for the solr indexing to be completed before checking the backlinks of the target.
new SolrTestUtils(setup, computedHostURL(testConfiguration)).waitEmptyQueue();
new SolrTestUtils(setup, testConfiguration.getServletEngine()).waitEmptyQueue();
vp = setup.gotoPage(targetDocumentReference);
assertEquals(setup.serializeReference(sourceDocumentReference1.getLocalDocumentReference()), vp.getContent());
}
private String computedHostURL(TestConfiguration testConfiguration)
{
ServletEngine servletEngine = testConfiguration.getServletEngine();
return String.format("http://%s:%d%s", servletEngine.getIP(), servletEngine.getPort(),
XWikiExecutor.DEFAULT_CONTEXT);
}
}
......@@ -44,8 +44,6 @@
import org.xwiki.test.docker.junit5.TestConfiguration;
import org.xwiki.test.docker.junit5.TestReference;
import org.xwiki.test.docker.junit5.UITest;
import org.xwiki.test.docker.junit5.servletengine.ServletEngine;
import org.xwiki.test.integration.XWikiExecutor;
import org.xwiki.test.ui.TestUtils;
import org.xwiki.test.ui.XWikiWebDriver;
import org.xwiki.test.ui.po.ConfirmationPage;
......@@ -759,7 +757,7 @@ void deleteWithUpdateLinksAndAutoRedirect(TestUtils testUtils, TestReference ref
testUtils.createPage(newTargetReference, "", "New target");
// Wait for Solr indexing to complete as backlink information from Solr is needed
new SolrTestUtils(testUtils, computedHostURL(testConfiguration)).waitEmptyQueue();
new SolrTestUtils(testUtils, testConfiguration.getServletEngine()).waitEmptyQueue();
// Delete page and provide a new target, with updateLinks and autoRedirect enabled.
ViewPage viewPage = testUtils.gotoPage(reference);
......@@ -798,7 +796,7 @@ void deleteWithoutNewTarget(TestUtils testUtils, TestReference reference, TestCo
testUtils.createPage(backlinkDocReference, backlinkDocContent, "Backlink document");
// Wait for Solr indexing to complete as backlink information from Solr is needed
new SolrTestUtils(testUtils, computedHostURL(testConfiguration)).waitEmptyQueue();
new SolrTestUtils(testUtils, testConfiguration.getServletEngine()).waitEmptyQueue();
// Delete page without specifying a new target.
ViewPage viewPage = testUtils.gotoPage(reference);
......@@ -841,7 +839,7 @@ void deleteWithAffectChildrenAndNewTarget(TestUtils testUtils, TestReference par
String.format(format, testUtils.serializeReference(parentReference), childFullName), "Backlink document");
// Wait for Solr indexing to complete as backlink information from Solr is needed
new SolrTestUtils(testUtils, computedHostURL(testConfiguration)).waitEmptyQueue();
new SolrTestUtils(testUtils, testConfiguration.getServletEngine()).waitEmptyQueue();
// Delete parent page with affectChildren and newTarget (updateLinks and autoRedirect enabled).
ViewPage parentPage = testUtils.gotoPage(parentReference);
......@@ -864,11 +862,4 @@ void deleteWithAffectChildrenAndNewTarget(TestUtils testUtils, TestReference par
ViewPage childPage = testUtils.gotoPage(childReference);
assertEquals("Child", childPage.getDocumentTitle());
}
private String computedHostURL(TestConfiguration testConfiguration)
{
ServletEngine servletEngine = testConfiguration.getServletEngine();
return String.format("http://%s:%d%s", servletEngine.getIP(), servletEngine.getPort(),
XWikiExecutor.DEFAULT_CONTEXT);
}
}
......@@ -43,8 +43,6 @@
import org.xwiki.test.docker.junit5.TestConfiguration;
import org.xwiki.test.docker.junit5.TestReference;
import org.xwiki.test.docker.junit5.UITest;
import org.xwiki.test.docker.junit5.servletengine.ServletEngine;
import org.xwiki.test.integration.XWikiExecutor;
import org.xwiki.test.ui.TestUtils;
import org.xwiki.test.ui.po.CopyOrRenameOrDeleteStatusPage;
import org.xwiki.test.ui.po.DocumentPicker;
......@@ -68,13 +66,6 @@ public void setup(TestUtils setup)
setup.loginAsSuperAdmin();
}
private String computedHostURL(TestConfiguration testConfiguration)
{
ServletEngine servletEngine = testConfiguration.getServletEngine();
return String.format("http://%s:%d%s", servletEngine.getIP(), servletEngine.getPort(),
XWikiExecutor.DEFAULT_CONTEXT);
}
@Order(1)
@Test
void convertNestedPageToTerminalPage(TestUtils setup, TestConfiguration testConfiguration) throws Exception
......@@ -91,7 +82,7 @@ void convertNestedPageToTerminalPage(TestUtils setup, TestConfiguration testConf
ViewPage vp = setup.createPage(reference, "", "");
// Wait for the solr indexing to be completed before doing any rename
new SolrTestUtils(setup, computedHostURL(testConfiguration)).waitEmptyQueue();
new SolrTestUtils(setup, testConfiguration.getServletEngine()).waitEmptyQueue();
// Go to the Rename page view for 1.2.3.WebHome and check the Terminal checkbox. We also need to uncheck the
// Auto Redirect checkbox so the page 1.2.3.WebHome will not appear as existing after the Rename operation.
......@@ -129,7 +120,7 @@ void renamePageCheckConfirmationPreserveChildrenUpdateLinksSetAutoRedirect(TestU
ViewPage vp = new ViewPage();
// Wait for the solr indexing to be completed before doing any rename
new SolrTestUtils(setup, computedHostURL(testConfiguration)).waitEmptyQueue();
new SolrTestUtils(setup, testConfiguration.getServletEngine()).waitEmptyQueue();
// Go to the Rename page view for 1.2.WebHome.
RenamePage renamePage = vp.rename();
......@@ -400,7 +391,7 @@ void renamePageUsedInMacroContentAndParameters(TestUtils setup, TestReference te
String.format(testPageContent, sourcePage1, sourcePage2, sourcePage3, sourcePage4, sourcePage5));
// Wait for the solr indexing to be completed before doing any rename
new SolrTestUtils(setup, computedHostURL(testConfiguration)).waitEmptyQueue();
new SolrTestUtils(setup, testConfiguration.getServletEngine()).waitEmptyQueue();
// rename link 1
ViewPage viewPage = setup.gotoPage(sourcePageReference1);
......@@ -417,7 +408,7 @@ void renamePageUsedInMacroContentAndParameters(TestUtils setup, TestReference te
wikiEditPage.getContent());
// Wait for the solr indexing to be completed before doing any rename
new SolrTestUtils(setup, computedHostURL(testConfiguration)).waitEmptyQueue();
new SolrTestUtils(setup, testConfiguration.getServletEngine()).waitEmptyQueue();
// rename link 2
viewPage = setup.gotoPage(sourcePageReference2);
......@@ -434,7 +425,7 @@ void renamePageUsedInMacroContentAndParameters(TestUtils setup, TestReference te
wikiEditPage.getContent());
// Wait for the solr indexing to be completed before doing any rename
new SolrTestUtils(setup, computedHostURL(testConfiguration)).waitEmptyQueue();
new SolrTestUtils(setup, testConfiguration.getServletEngine()).waitEmptyQueue();
// rename link 3
viewPage = setup.gotoPage(sourcePageReference3);
......@@ -451,7 +442,7 @@ void renamePageUsedInMacroContentAndParameters(TestUtils setup, TestReference te
wikiEditPage.getContent());
// Wait for the solr indexing to be completed before doing any rename
new SolrTestUtils(setup, computedHostURL(testConfiguration)).waitEmptyQueue();
new SolrTestUtils(setup, testConfiguration.getServletEngine()).waitEmptyQueue();
// rename link 4
viewPage = setup.gotoPage(sourcePageReference4);
......@@ -468,7 +459,7 @@ void renamePageUsedInMacroContentAndParameters(TestUtils setup, TestReference te
wikiEditPage.getContent());
// Wait for the solr indexing to be completed before doing any rename
new SolrTestUtils(setup, computedHostURL(testConfiguration)).waitEmptyQueue();
new SolrTestUtils(setup, testConfiguration.getServletEngine()).waitEmptyQueue();
// rename link 5
viewPage = setup.gotoPage(sourcePageReference5);
......@@ -504,7 +495,7 @@ void renamePageRelativeLinkPageAndTranslation(TestUtils setup, TestReference tes
assertEquals("[[OtherPage]]", setup.rest().<Page>get(reference).getContent());
// Wait for the solr indexing to be completed before doing any rename
new SolrTestUtils(setup, computedHostURL(testConfiguration)).waitEmptyQueue();
new SolrTestUtils(setup, testConfiguration.getServletEngine()).waitEmptyQueue();
// Rename the page
ViewPage vp = setup.gotoPage(reference);
......
......@@ -49,7 +49,7 @@
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-solr-test-utils</artifactId>
<artifactId>xwiki-platform-search-test-utils</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
......
......@@ -83,7 +83,7 @@
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-solr-test-utils</artifactId>
<artifactId>xwiki-platform-search-test-utils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
......
......@@ -37,4 +37,12 @@
<module>xwiki-platform-search-ui</module>
<module>xwiki-platform-search-webjar</module>
</modules>
<profiles>
<profile>
<id>integration-tests</id>
<modules>
<module>xwiki-platform-search-test</module>
</modules>
</profile>
</profiles>
</project>
......@@ -22,13 +22,13 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-solr</artifactId>
<artifactId>xwiki-platform-search</artifactId>
<version>16.4.0-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-search-solr-test</artifactId>
<name>XWiki Platform - Search - Solr - Tests - Parent POM</name>
<artifactId>xwiki-platform-search-test</artifactId>
<name>XWiki Platform - Search - Tests - Parent POM</name>
<packaging>pom</packaging>
<description>XWiki Platform - Search - Solr - Tests - Parent POM</description>
<description>XWiki Platform - Search - Tests - Parent POM</description>
<properties>
<!-- Don't run backward-compatibility checks in test modules since we don't consider them as public APIs -->
<xwiki.revapi.skip>true</xwiki.revapi.skip>
......@@ -36,14 +36,14 @@
<xwiki.checkstyle.skip>true</xwiki.checkstyle.skip>
</properties>
<modules>
<module>xwiki-platform-search-solr-test-pageobjects</module>
<module>xwiki-platform-search-solr-test-utils</module>
<module>xwiki-platform-search-test-pageobjects</module>
<module>xwiki-platform-search-test-utils</module>
</modules>
<profiles>
<profile>
<id>docker</id>
<modules>
<module>xwiki-platform-search-solr-test-docker</module>
<module>xwiki-platform-search-test-docker</module>
</modules>
</profile>
</profiles>
......
......@@ -22,13 +22,13 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-solr-test</artifactId>
<artifactId>xwiki-platform-search-test</artifactId>
<version>16.4.0-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-search-solr-test-docker</artifactId>
<name>XWiki Platform - Search - Solr - Tests - Functional Docker Tests</name>
<artifactId>xwiki-platform-search-test-docker</artifactId>
<name>XWiki Platform - Search - Tests - Functional Docker Tests</name>
<packaging>jar</packaging>
<description>XWiki Platform - Search - Solr - Tests - Functional Tests in Docker</description>
<description>XWiki Platform - Search - Tests - Functional Tests in Docker</description>
<properties>
<!-- Functional tests are allowed to output content to the console -->
<xwiki.surefire.captureconsole.skip>true</xwiki.surefire.captureconsole.skip>
......@@ -36,10 +36,16 @@
<dependencies>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-solr-ui</artifactId>
<artifactId>xwiki-platform-search-ui</artifactId>
<version>${project.version}</version>
<type>xar</type>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-webjar</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-test-docker</artifactId>
......@@ -48,16 +54,23 @@
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-solr-test-utils</artifactId>
<artifactId>xwiki-platform-search-test-pageobjects</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-solr-test-pageobjects</artifactId>
<artifactId>xwiki-platform-search-test-utils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<!-- We need some search suggest sources, so we use Solr -->
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-solr-ui</artifactId>
<version>${project.version}</version>
<type>xar</type>
</dependency>
</dependencies>
<build>
<testSourceDirectory>src/test/it</testSourceDirectory>
......
......@@ -17,13 +17,13 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.search.solr.test.ui;
package org.xwiki.search.test.ui;
import org.junit.jupiter.api.Nested;
import org.xwiki.test.docker.junit5.UITest;
/**
* All UI tests for the Solr Search feature.
* All UI tests for the Search feature.
*
* @version $Id$
*/
......@@ -34,4 +34,9 @@ class AllIT
class NestedSolrSearchIT extends SolrSearchIT
{
}
@Nested
class NestedSearchSuggestIT extends SearchSuggestIT
{
}
}
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.search.test.ui;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebElement;
import org.xwiki.repository.test.SolrTestUtils;
import org.xwiki.search.test.po.QuickSearchElement;
import org.xwiki.test.docker.junit5.TestConfiguration;
import org.xwiki.test.docker.junit5.TestReference;
import org.xwiki.test.docker.junit5.UITest;
import org.xwiki.test.ui.TestUtils;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* UI tests for Search Suggest features.
*
* @version $Id$
*/
@UITest
class SearchSuggestIT
{
@Test
void verifySearchSuggestTitles(TestUtils setup, TestReference testReference, TestConfiguration testConfiguration)
throws Exception
{
setup.loginAsSuperAdmin();
String testDocumentTitle = "Main";
setup.rest().savePage(testReference, "Hello World!", testDocumentTitle);
setup.gotoPage(testReference);
new SolrTestUtils(setup, testConfiguration.getServletEngine()).waitEmptyQueue();
QuickSearchElement quickSearchElement = new QuickSearchElement();
quickSearchElement.search(testDocumentTitle);
WebElement firstSuggestElement = quickSearchElement.getSuggestItemTitles(0);
assertEquals(testDocumentTitle, firstSuggestElement.getText());
}
}
......@@ -17,15 +17,13 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.search.solr.test.ui;
package org.xwiki.search.test.ui;
import org.junit.jupiter.api.Test;
import org.xwiki.repository.test.SolrTestUtils;
import org.xwiki.search.solr.test.po.SolrSearchPage;
import org.xwiki.search.test.po.SolrSearchPage;
import org.xwiki.test.docker.junit5.TestConfiguration;
import org.xwiki.test.docker.junit5.UITest;
import org.xwiki.test.docker.junit5.servletengine.ServletEngine;
import org.xwiki.test.integration.XWikiExecutor;
import org.xwiki.test.ui.TestUtils;
import static org.junit.jupiter.api.Assertions.assertEquals;
......@@ -45,18 +43,11 @@ void verifySpaceFaucetEscaping(TestUtils setup, TestConfiguration testConfigurat
String testDocumentLocation = "{{/html}}";
setup.createPage(testDocumentLocation, "WebHome", "Test Document", testDocumentLocation);
new SolrTestUtils(setup, computedHostURL(testConfiguration)).waitEmptyQueue();
new SolrTestUtils(setup, testConfiguration.getServletEngine()).waitEmptyQueue();
SolrSearchPage searchPage = SolrSearchPage.gotoPage();
searchPage.search("\"Test Document\"");
searchPage.toggleSpaceFaucet();
assertEquals(testDocumentLocation + "\n1", searchPage.getSpaceFaucetContent());
}
private String computedHostURL(TestConfiguration testConfiguration)
{
ServletEngine servletEngine = testConfiguration.getServletEngine();
return String.format("http://%s:%d%s", servletEngine.getIP(), servletEngine.getPort(),
XWikiExecutor.DEFAULT_CONTEXT);
}
}
......@@ -22,13 +22,13 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-solr-test</artifactId>
<artifactId>xwiki-platform-search-test</artifactId>
<version>16.4.0-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-search-solr-test-pageobjects</artifactId>
<name>XWiki Platform - Search - Solr - Tests - Page Objects</name>
<artifactId>xwiki-platform-search-test-pageobjects</artifactId>
<name>XWiki Platform - Search - Tests - Page Objects</name>
<packaging>jar</packaging>
<description>XWiki Platform - Search - Solr - Tests - Page Objects</description>
<description>XWiki Platform - Search - Tests - Page Objects</description>
<properties>
<!-- None of the classes is valid -->
<xwiki.checkstyle.skip>true</xwiki.checkstyle.skip>
......
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.search.test.po;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.xwiki.test.ui.po.BaseElement;
public class QuickSearchElement extends BaseElement
{
@FindBy(id = "headerglobalsearchinput")
private WebElement searchInput;
@FindBy(css = "#globalsearch button")
private WebElement searchButton;
/**
* Enter text in the quick search box.
* @param terms text to search
*/
public void search(String terms)
{
this.searchButton.click();
this.searchInput.clear();
this.searchInput.sendKeys(terms);
getDriver().waitUntilElementIsVisible(By.cssSelector(".searchSuggest li.showAllResults.loading"));
}
/**
* Get a suggest item from the "Page Titles" category.
* @param index the index of the item to get
* @return the title of the item, or null if it could not be found
*/
public WebElement getSuggestItemTitles(int index)
{
getDriver().waitUntilElementIsVisible(By.cssSelector(".searchSuggest .results0:not(.loading)"));
WebElement suggestItemsListTitles = getDriver().findElement(By.cssSelector(".results0 .suggestList"));
if (suggestItemsListTitles == null) {
return null;
}
List<WebElement> titles = suggestItemsListTitles.findElements(By.xpath("//div[@class = 'value']"));
if (index < titles.size()) {
return titles.get(index);
} else {
return null;
}
}
}
......@@ -17,7 +17,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.xwiki.search.solr.test.po;
package org.xwiki.search.test.po;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
......
......@@ -24,18 +24,28 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-search-solr-test</artifactId>
<artifactId>xwiki-platform-search-test</artifactId>
<version>16.4.0-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-search-solr-test-utils</artifactId>
<name>XWiki Platform - Search - Solr - Tests - Utils</name>
<artifactId>xwiki-platform-search-test-utils</artifactId>
<name>XWiki Platform - Search - Tests - Utils</name>
<packaging>jar</packaging>
<description>XWiki Platform - Search - Solr - Tests - Utils</description>
<description>XWiki Platform - Search - Tests - Utils</description>
<properties>
<!-- None of the classes is valid -->
<xwiki.checkstyle.skip>true</xwiki.checkstyle.skip>
</properties>
<dependencies>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-test-docker</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-test-integration</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-test-ui</artifactId>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment