Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
add manage search page and use it in one of the test
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Huang committed Dec 20, 2013
1 parent 7765397 commit 952fb6d
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
@@ -0,0 +1,51 @@
package org.zanata.page.administration;

import com.google.common.base.Predicate;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.zanata.page.BasePage;
import org.zanata.util.Checkbox;
import org.zanata.util.TableRow;
import org.zanata.util.WebElementUtil;

/**
* @author Patrick Huang
* <a href="mailto:pahuang@redhat.com">pahuang@redhat.com</a>
*/
public class ManageSearchPage extends BasePage {
private By classesTableBy = By.id("form:classList");

public ManageSearchPage(WebDriver driver) {
super(driver);
}


public ManageSearchPage selectAllActionsFor(String clazz) {
List<TableRow> tableRows =
WebElementUtil.getTableRows(getDriver(), classesTableBy);
for (TableRow tableRow : tableRows) {
if (tableRow.getCellContents().contains(clazz)) {
WebElement allActionsChkBox =
tableRow.getCells().get(0).findElement(By.tagName("input"));
Checkbox.of(allActionsChkBox).check();
}
}

return this;
}

public ManageSearchPage performSelectedActions() {
getDriver().findElement(By.id("form:reindex")).click();
waitForTenSec().until(new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
// once the button re-appears, it means the reindex is done.
input.findElement(By.id("form:reindex"));
return true;
}
});
return this;
}
}
Expand Up @@ -31,6 +31,7 @@
import org.junit.experimental.categories.Category;
import org.junit.rules.TestRule;
import org.zanata.feature.ConcordionTest;
import org.zanata.page.administration.ManageSearchPage;
import org.zanata.page.webtrans.EditorPage;
import org.zanata.util.RetryRule;
import org.zanata.util.SampleProjectRule;
Expand Down Expand Up @@ -80,6 +81,14 @@ public void testGlossaryDelete() {
assertThat(clientPushWorkFlow.isPushSuccessful(result),
Matchers.is(true));

new LoginWorkFlow().signIn("admin", "admin");
// for some reason on jenkins sometimes the index is out of sync.
ManageSearchPage manageSearchPage =
new BasicWorkFlow().goToPage("admin/search", ManageSearchPage.class);
manageSearchPage.selectAllActionsFor("HGlossaryEntry");
manageSearchPage.selectAllActionsFor("HGlossaryTerm");
manageSearchPage.performSelectedActions();

List<List<String>> hiGlossaryResult =
translate("hi").searchGlossary("hello")
.getGlossaryResultTable();
Expand All @@ -93,8 +102,6 @@ public void testGlossaryDelete() {
}

public EditorPage translate(String locale) {

new LoginWorkFlow().signIn("admin", "admin");
return new BasicWorkFlow().goToPage(
"webtrans/translate?project=about-fedora&iteration=master&localeId="
+ locale + "&locale=en#view:doc;doc:About_Fedora",
Expand Down
6 changes: 3 additions & 3 deletions zanata-war/src/main/webapp/admin/search.xhtml
Expand Up @@ -12,7 +12,7 @@

<ui:define name="page_title">#{messages['jsf.ManageSearch']}</ui:define>
<ui:define name="center_content">
<h:form>
<h:form id="form">
<s:token allowMultiplePosts="true"/>
<a4j:region>

Expand All @@ -22,7 +22,7 @@
<rich:dataTable id="classList" rows="#{reindexAction.classes.size}"
value="#{reindexAction.classes.toArray()}" var="clazz"
render="actions">
<rich:column width="auto" styleClass="centered">
<rich:column width="auto" styleClass="centered" id="col">
<f:facet
name="header">#{messages['jsf.manageSearch.AllActions']}</f:facet>
<h:selectBooleanCheckbox value="#{clazz.selectAll}">
Expand Down Expand Up @@ -61,7 +61,7 @@
<f:facet
name="header">#{messages['jsf.manageSearch.reindex']}</f:facet>
<f:facet name="footer">
<h:selectBooleanCheckbox value="#{reindexAction.reindexAll}">
<h:selectBooleanCheckbox value="#{reindexAction.reindexAll}" id="reindexAllChk">
<a4j:ajax event="click" render="actions" execute="@this"/>
</h:selectBooleanCheckbox>
</f:facet>
Expand Down

0 comments on commit 952fb6d

Please sign in to comment.