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

Commit

Permalink
Merge pull request #353 from zanata/gettext-plural-ft
Browse files Browse the repository at this point in the history
Automate TCMS test cases as functional test
  • Loading branch information
davidmason committed Feb 11, 2014
2 parents 70c25df + e02ecdb commit 14576f5
Show file tree
Hide file tree
Showing 38 changed files with 968 additions and 253 deletions.
40 changes: 35 additions & 5 deletions functional-test/pom.xml
Expand Up @@ -12,7 +12,7 @@
<name>functional-test</name>

<properties>
<selenium.version>2.26.0</selenium.version>
<selenium.version>2.39.0</selenium.version>

<!--Cargo Settings -->
<cargo.wait>false</cargo.wait>
Expand Down Expand Up @@ -62,6 +62,7 @@
<!-- this property can be used to control what test needs to be run by failsafe -->
<include.test.patterns>**/AggregateTestSuite.java</include.test.patterns>
<hibernate.search.default.indexBase>${project.build.directory}/zanataindex</hibernate.search.default.indexBase>
<smtp.port>2552</smtp.port>
</properties>

<dependencies>
Expand Down Expand Up @@ -128,6 +129,24 @@
<artifactId>slf4j-api</artifactId>
</dependency>

<dependency>
<groupId>org.subethamail</groupId>
<artifactId>subethasmtp-wiser</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
Expand Down Expand Up @@ -194,6 +213,21 @@
<artifactId>resteasy-jaxb-provider</artifactId>
</dependency>

<dependency>
<groupId>org.zanata</groupId>
<artifactId>zanata-adapter-po</artifactId>
</dependency>

<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>

<dependency>
<groupId>org.fedorahosted.openprops</groupId>
<artifactId>openprops</artifactId>
</dependency>

<!-- to be able to create entities in functional test -->
<dependency>
<groupId>org.zanata</groupId>
Expand All @@ -204,10 +238,6 @@
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.seam</groupId>
<artifactId>jboss-seam</artifactId>
Expand Down
41 changes: 33 additions & 8 deletions functional-test/sample-projects/plural/pl/test.po
Expand Up @@ -15,39 +15,64 @@ msgid "One file removed"
msgid_plural "%d files removed"
msgstr[0] "1 aoeuaouaou"
msgstr[1] "%d aoeuaouao"
msgstr[2] ""

#, c-format
msgid "One other file removed"
msgid_plural "%d files removed"
msgstr[0] ""
msgstr[1] "%d aoeuaouao"
msgstr[2] ""

#, c-format
msgid "One file removed_"
msgid_plural "%d more files removed"
msgstr[0] "1 tnhdaoeuaoue"
msgstr[1] ""
msgstr[2] ""

#, c-format
msgid "File removed"
msgid_plural "%d files removed"
msgstr[0] "1 tnhdnthdntioei"
msgstr[1] ""
msgstr[2] ""

#, c-format, fuzzy
#, fuzzy, c-format
msgid "Yet Another File removed"
msgid_plural "%d files removed"
msgstr[0] "%d aoenuthaosneuh"
msgstr[1] ""
msgstr[2] ""

#, c-format, fuzzy
#, c-format
msgid "2 Another File removed"
msgid_plural "%d files removed"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""

#, c-format
msgid "msgid"
msgstr ""

#, c-format
msgid "%d files removed"
msgid_plural "One file removed"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""

# not legal because it has multiple msgstr but no msgid_plural:
#, c-format
#msgid "File removed."
#msgstr[0] ""
#msgstr[1] ""
msgid "aaaaaaaaaaaa"
msgid_plural "bbbbbbbbbbb"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""

msgid "pl msgid"
msgstr "pl msgstr"
#, c-format
msgid "bbbbbbbbbbb"
msgid_plural "aaaaaaaaaaaa"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""
8 changes: 6 additions & 2 deletions functional-test/sample-projects/plural/pom.xml
Expand Up @@ -4,15 +4,19 @@
<artifactId>null</artifactId>
<version>0</version>

<properties>
<zanata.srcDir>pot</zanata.srcDir>
<zanata.transDir>.</zanata.transDir>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.zanata</groupId>
<artifactId>zanata-maven-plugin</artifactId>
<version>${zanata.client.version}</version>
<configuration>
<srcDir>pot</srcDir>
<transDir>.</transDir>
<srcDir>${zanata.srcDir}</srcDir>
<transDir>${zanata.transDir}</transDir>
</configuration>
</plugin>
</plugins>
Expand Down
6 changes: 6 additions & 0 deletions functional-test/src/main/java/org/zanata/page/BasePage.java
Expand Up @@ -35,6 +35,7 @@
import org.zanata.page.glossary.GlossaryPage;
import org.zanata.page.groups.VersionGroupsPage;
import org.zanata.page.projects.ProjectsPage;
import org.zanata.page.utility.HelpPage;
import org.zanata.page.utility.HomePage;
import org.zanata.util.WebElementUtil;
import com.google.common.base.Optional;
Expand Down Expand Up @@ -207,4 +208,9 @@ public void clickLinkAfterAnimation(By locator) {
executor.executeScript("arguments[0].click();", getDriver()
.findElement(locator));
}

public HelpPage goToHelp() {
getDriver().findElement(By.id("help_link")).click();
return new HelpPage(getDriver());
}
}
Expand Up @@ -60,9 +60,7 @@ public WebDriver getDriver() {
}

public WebDriver createDriver() {
WebDriver driver =
new EventFiringWebDriver(
new Augmenter().augment(createPlainDriver()));
WebDriver driver = createPlainDriver();
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);

Runtime.getRuntime().addShutdownHook(new ShutdownHook());
Expand Down Expand Up @@ -131,7 +129,10 @@ private WebDriver configureChromeDriver() {
} catch (IOException e) {
throw new RuntimeException("fail to start chrome driver service");
}
return new RemoteWebDriver(driverService.getUrl(), capabilities);
return new EventFiringWebDriver(
new Augmenter().augment(new RemoteWebDriver(driverService
.getUrl(),
capabilities)));
}

private WebDriver configureFirefoxDriver() {
Expand Down
Expand Up @@ -21,7 +21,9 @@
package org.zanata.page.projects;

import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;

import lombok.extern.slf4j.Slf4j;
Expand All @@ -37,6 +39,8 @@

@Slf4j
public class ProjectVersionPage extends BasePage {
public static final String STATS_TEMPLATE =
"iterationLanguageForm:data_table:%d:statistics";
@FindBy(id = "iterationLanguageForm:data_table:tb")
private WebElement localeTableTBody;

Expand Down Expand Up @@ -121,4 +125,13 @@ public CreateVersionPage clickEditVersion() {
editVersionButton.click();
return new CreateVersionPage(getDriver());
}

public String getStatisticsForLocale(String locale) {
int rowIndex = getTranslatableLocales().indexOf(locale);
Preconditions.checkState(rowIndex >= 0, "can not find statistics for locale: %s", locale);
WebElement stats =
getDriver().findElement(
By.id(String.format(STATS_TEMPLATE, rowIndex)));
return stats.getText();
}
}
@@ -0,0 +1,43 @@
package org.zanata.page.utility;

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 Patrick Huang <a
* href="mailto:pahuang@redhat.com">pahuang@redhat.com</a>
*/
public class ContactAdminFormPage extends BasePage {
@FindBy(id = "contactAdminForm:subjectField:subject")
private WebElement subjectField;

@FindBy(id = "contactAdminForm:messageField:message")
private WebElement messageField;

@FindBy(id = "contactAdminForm:send")
private WebElement sendButton;

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

public ContactAdminFormPage inputSubject(String subject) {
subjectField.clear();
subjectField.sendKeys(subject);
return new ContactAdminFormPage(getDriver());
}

public ContactAdminFormPage inputMessage(String message) {
WebElementUtil
.setRichTextEditorContent(getDriver(), messageField, message);
return new ContactAdminFormPage(getDriver());
}

public HelpPage send() {
sendButton.click();
return new HelpPage(getDriver());
}
}
@@ -0,0 +1,24 @@
package org.zanata.page.utility;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.zanata.page.BasePage;

/**
* @author Patrick Huang
* <a href="mailto:pahuang@redhat.com">pahuang@redhat.com</a>
*/
public class HelpPage extends BasePage {
@FindBy(linkText = "Contact Admin")
private WebElement contactAdminLink;

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

public ContactAdminFormPage clickContactAdmin() {
contactAdminLink.click();
return new ContactAdminFormPage(getDriver());
}
}

0 comments on commit 14576f5

Please sign in to comment.