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

Commit

Permalink
Add 'contact language team coordinator' test
Browse files Browse the repository at this point in the history
  • Loading branch information
djansen-redhat committed Oct 10, 2014
1 parent e3a9f8e commit 26a8eab
Show file tree
Hide file tree
Showing 7 changed files with 264 additions and 2 deletions.
7 changes: 7 additions & 0 deletions functional-test/src/main/java/org/zanata/page/BasePage.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
@@ -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 <a href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
@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());
}
}
@@ -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 <a href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
@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());
}

}
@@ -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 <a href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
@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<TableRow> 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());
}
}
@@ -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 <a href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
@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<WiserMessage> 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");
}
}
Expand Up @@ -15,7 +15,7 @@
<ui:param name="showGlobalMessages" value="true"/>

<ui:define name="center_content">
<h:form>
<h:form id="contactCoordinatorForm">
<s:token allowMultiplePosts="true"/>
<rich:panel>

Expand Down
2 changes: 1 addition & 1 deletion zanata-war/src/main/webapp/language/home.xhtml
Expand Up @@ -20,7 +20,7 @@
</ui:define>

<ui:define name="center_content">
<h:form>
<h:form id="tribesForm">
<rich:dataTable id="latestTribes"
value="#{supportedLanguageAction.supportedLanguages}" var="language">
<rich:column sortBy="#{language.localeId.id}">
Expand Down

0 comments on commit 26a8eab

Please sign in to comment.