diff --git a/functional-test/src/main/java/org/zanata/page/BasePage.java b/functional-test/src/main/java/org/zanata/page/BasePage.java index 208b7f4dba..21f0cecfe5 100644 --- a/functional-test/src/main/java/org/zanata/page/BasePage.java +++ b/functional-test/src/main/java/org/zanata/page/BasePage.java @@ -37,6 +37,7 @@ import org.zanata.page.dashboard.DashboardBasePage; import org.zanata.page.glossary.GlossaryPage; import org.zanata.page.groups.VersionGroupsPage; +import org.zanata.page.languages.LanguagesPage; import org.zanata.page.projects.ProjectVersionsPage; import org.zanata.page.projects.ProjectsPage; import org.zanata.page.utility.HelpPage; @@ -120,6 +121,12 @@ public VersionGroupsPage goToGroups() { return new VersionGroupsPage(getDriver()); } + public LanguagesPage goToLanguages() { + log.info("Click Languages"); + clickNavMenuItem(getDriver().findElement(By.id("languages_link"))); + return new LanguagesPage(getDriver()); + } + public GlossaryPage goToGlossary() { log.info("Click Glossary"); // Dynamically find the link, as it is not present for every user diff --git a/functional-test/src/main/java/org/zanata/page/languages/ContactTeamPage.java b/functional-test/src/main/java/org/zanata/page/languages/ContactTeamPage.java new file mode 100644 index 0000000000..549ecab837 --- /dev/null +++ b/functional-test/src/main/java/org/zanata/page/languages/ContactTeamPage.java @@ -0,0 +1,67 @@ +/* + * 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.languages; + +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 Damian Jansen djansen@redhat.com + */ +@Slf4j +public class ContactTeamPage extends BasePage { + + @FindBy(id = "contactCoordinatorForm:messageField:message") + private WebElement messageField; + + @FindBy(id = "contactCoordinatorForm:send") + private WebElement sendButton; + + public ContactTeamPage(WebDriver driver) { + super(driver); + } + + public ContactTeamPage enterSubject(String subject) { + log.info("Enter subject {}", subject); + getDriver().findElement( + By.id("contactCoordinatorForm:subjectField:subject")) + .sendKeys(subject); + return new ContactTeamPage(getDriver()); + } + + public ContactTeamPage enterMessage(String message) { + log.info("Enter message {}", message); + WebElementUtil + .setRichTextEditorContent(getDriver(), messageField, message); + return new ContactTeamPage(getDriver()); + } + + public LanguagesPage clickSend() { + log.info("Click the Send Message button"); + sendButton.click(); + return new LanguagesPage(getDriver()); + } +} diff --git a/functional-test/src/main/java/org/zanata/page/languages/LanguagePage.java b/functional-test/src/main/java/org/zanata/page/languages/LanguagePage.java new file mode 100644 index 0000000000..7ec612033e --- /dev/null +++ b/functional-test/src/main/java/org/zanata/page/languages/LanguagePage.java @@ -0,0 +1,44 @@ +/* + * 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.languages; + +import lombok.extern.slf4j.Slf4j; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.zanata.page.BasePage; + +/** + * @author Damian Jansen djansen@redhat.com + */ +@Slf4j +public class LanguagePage extends BasePage { + + public LanguagePage(WebDriver driver) { + super(driver); + } + + public ContactTeamPage clickContactCoordinatorsButton() { + log.info("Click Contact Coordinators button"); + getDriver().findElement(By.linkText("Contact Team Coordinators")).click(); + return new ContactTeamPage(getDriver()); + } + +} diff --git a/functional-test/src/main/java/org/zanata/page/languages/LanguagesPage.java b/functional-test/src/main/java/org/zanata/page/languages/LanguagesPage.java new file mode 100644 index 0000000000..c184ab40b6 --- /dev/null +++ b/functional-test/src/main/java/org/zanata/page/languages/LanguagesPage.java @@ -0,0 +1,59 @@ +/* + * 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.languages; + +import lombok.extern.slf4j.Slf4j; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.zanata.page.BasePage; +import org.zanata.util.TableRow; +import org.zanata.util.WebElementUtil; + +import java.util.List; + +/** + * @author Damian Jansen djansen@redhat.com + */ +@Slf4j +public class LanguagesPage extends BasePage { + + public LanguagesPage(WebDriver driver) { + super(driver); + } + + public LanguagePage selectLanguage(String language) { + log.info("Select {} from the language list", language); + List tableRowList = WebElementUtil + .getTableRows(getDriver(), By.id("tribesForm:latestTribes")); + boolean clicked = false; + for (TableRow tableRow : tableRowList) { + if (tableRow.getCells().get(0).getText().equals(language)) { + tableRow.getCells().get(0).findElement(By.tagName("a")).click(); + clicked = true; + break; + } + } + if (!clicked) { + throw new RuntimeException(language + " not found"); + } + return new LanguagePage(getDriver()); + } +} diff --git a/functional-test/src/test/java/org/zanata/feature/language/ContactLanguageTeamTest.java b/functional-test/src/test/java/org/zanata/feature/language/ContactLanguageTeamTest.java new file mode 100644 index 0000000000..1df3ae5f69 --- /dev/null +++ b/functional-test/src/test/java/org/zanata/feature/language/ContactLanguageTeamTest.java @@ -0,0 +1,85 @@ +/* + * 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.language; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.subethamail.wiser.WiserMessage; +import org.zanata.feature.Feature; +import org.zanata.feature.testharness.TestPlan; +import org.zanata.feature.testharness.ZanataTestCase; +import org.zanata.page.languages.LanguagesPage; +import org.zanata.util.AddUsersRule; +import org.zanata.util.HasEmailRule; +import org.zanata.workflow.LoginWorkFlow; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * @author Damian Jansen djansen@redhat.com + */ +@Category(TestPlan.DetailedTest.class) +public class ContactLanguageTeamTest extends ZanataTestCase { + + @Rule + public AddUsersRule addUsersRule = new AddUsersRule(); + + @Rule + public HasEmailRule emailRule = new HasEmailRule(); + + @Feature(summary = "The user can contact a language team coordinator", + tcmsTestPlanIds = 5316, tcmsTestCaseIds = 0) + @Test(timeout = ZanataTestCase.MAX_SHORT_TEST_DURATION) + public void translatorContactsLanguageTeamCoordinator() throws Exception { + LanguagesPage languagesPage = new LoginWorkFlow() + .signIn("translator", "translator") + .goToLanguages() + .selectLanguage("fr") + .clickContactCoordinatorsButton() + .enterSubject("contact test") + .enterMessage("I love Zanata") + .clickSend(); + + List messages = emailRule.getMessages(); + + assertThat(messages.size()) + .isEqualTo(1) + .as("One email was sent"); + + WiserMessage wiserMessage = messages.get(0); + + assertThat(wiserMessage.getEnvelopeReceiver()) + .isEqualTo("admin@example.com") + .as("The email recipient is the administrator"); + + String content = HasEmailRule.getEmailContent(wiserMessage); + + assertThat(content) + .contains("Dear Language Team Coordinator") + .as("The email is to the language team coordinator"); + assertThat(languagesPage.getNotificationMessage()) + .contains("Your message has been sent to the administrator") + .as("The user is informed the message was sent"); + } +} diff --git a/zanata-war/src/main/webapp/language/contact_coordinator.xhtml b/zanata-war/src/main/webapp/language/contact_coordinator.xhtml index 8da749ea55..3d6e363c21 100644 --- a/zanata-war/src/main/webapp/language/contact_coordinator.xhtml +++ b/zanata-war/src/main/webapp/language/contact_coordinator.xhtml @@ -15,7 +15,7 @@ - + diff --git a/zanata-war/src/main/webapp/language/home.xhtml b/zanata-war/src/main/webapp/language/home.xhtml index b8fe62e040..48bdca718e 100644 --- a/zanata-war/src/main/webapp/language/home.xhtml +++ b/zanata-war/src/main/webapp/language/home.xhtml @@ -20,7 +20,7 @@ - +