This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #355 from zanata/glossary-admin-test
Add automated test for glossary page.
- Loading branch information
Showing
5 changed files
with
167 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
functional-test/src/main/java/org/zanata/page/glossary/GlossaryPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright 2014, Red Hat, Inc. and individual contributors as indicated by the | ||
* @author tags. See the copyright.txt file in the distribution for a full | ||
* listing of individual contributors. | ||
* | ||
* 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.zanata.page.glossary; | ||
|
||
import java.util.List; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.FindBy; | ||
import org.zanata.page.BasePage; | ||
import org.zanata.util.WebElementUtil; | ||
|
||
/** | ||
* @author Carlos Munoz <a | ||
* href="mailto:camunoz@redhat.com">camunoz@redhat.com</a> | ||
*/ | ||
@Slf4j | ||
public class GlossaryPage extends BasePage { | ||
|
||
@FindBy(id = "glossary_form:data_table") | ||
private WebElement glossaryTable; | ||
|
||
public GlossaryPage(WebDriver driver) { | ||
super(driver); | ||
} | ||
|
||
public List<String> getAvailableGlossaryLanguages() { | ||
return WebElementUtil.getColumnContents(getDriver(), | ||
By.id("glossary_form:data_table"), 0); | ||
} | ||
|
||
public int getGlossaryEntryCount(String lang) { | ||
List<String> langs = getAvailableGlossaryLanguages(); | ||
int row = langs.indexOf(lang); | ||
if (row >= 0) { | ||
return Integer | ||
.parseInt(WebElementUtil.getColumnContents(getDriver(), | ||
By.id("glossary_form:data_table"), 2).get(row)); | ||
} | ||
return -1; | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
functional-test/src/test/java/org/zanata/feature/glossary/GlossaryAdminTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright 2014, Red Hat, Inc. and individual contributors as indicated by the | ||
* @author tags. See the copyright.txt file in the distribution for a full | ||
* listing of individual contributors. | ||
* | ||
* 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.zanata.feature.glossary; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import org.hamcrest.Matchers; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
import org.junit.rules.TestRule; | ||
import org.zanata.feature.DetailedTest; | ||
import org.zanata.page.glossary.GlossaryPage; | ||
import org.zanata.util.SampleProjectRule; | ||
import org.zanata.workflow.ClientPushWorkFlow; | ||
import org.zanata.workflow.LoginWorkFlow; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.contains; | ||
import static org.hamcrest.Matchers.containsInAnyOrder; | ||
import static org.hamcrest.Matchers.greaterThan; | ||
|
||
/** | ||
* @author Carlos Munoz <a | ||
* href="mailto:camunoz@redhat.com">camunoz@redhat.com</a> | ||
*/ | ||
@Category(DetailedTest.class) | ||
@Slf4j | ||
public class GlossaryAdminTest { | ||
|
||
@Rule | ||
public TestRule sampleProjectRule = new SampleProjectRule(); | ||
|
||
private ClientPushWorkFlow clientPushWorkFlow = new ClientPushWorkFlow(); | ||
|
||
/** | ||
* Validates that a pushed glossary appears in the Glossary table. | ||
* After pushing, a table with Glossary statistics should be shown. | ||
* Validate that the the number of glossary entries per language matches | ||
* the number of entries pushed from each of the test cases metnioned in the | ||
* Setup. | ||
* @see TCMS Test Case 181711 | ||
*/ | ||
@Test | ||
public void testGlossaryView() { | ||
// Push a glossary | ||
File projectRootPath = | ||
clientPushWorkFlow.getProjectRootPath("glossary"); | ||
String userConfigPath = | ||
ClientPushWorkFlow.getUserConfigPath("glossaryadmin"); | ||
|
||
List<String> result = | ||
clientPushWorkFlow | ||
.callWithTimeout( | ||
projectRootPath, | ||
"mvn --batch-mode zanata:glossary-push -Dglossary.lang=hi -Dzanata.glossaryFile=compendium.csv -Dzanata.userConfig=" | ||
+ userConfigPath); | ||
|
||
assertThat(clientPushWorkFlow.isPushSuccessful(result), | ||
Matchers.is(true)); | ||
|
||
// Make sure glossary shows up on the page | ||
GlossaryPage glossaryPage = | ||
new LoginWorkFlow().signIn("admin", "admin").goToGlossary(); | ||
List<String> langs = glossaryPage.getAvailableGlossaryLanguages(); | ||
|
||
assertThat(langs.size(), greaterThan(0)); | ||
assertThat(langs, containsInAnyOrder("pl", "hi", "en-US")); | ||
assertThat(glossaryPage.getGlossaryEntryCount("pl"), greaterThan(1)); | ||
assertThat(glossaryPage.getGlossaryEntryCount("hi"), greaterThan(1)); | ||
assertThat(glossaryPage.getGlossaryEntryCount("en-US"), greaterThan(1)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters