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

Commit

Permalink
Merge branch 'integration/master' into dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Jul 29, 2013
2 parents c3f5059 + 408c41c commit cbdddcd
Show file tree
Hide file tree
Showing 12 changed files with 409 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -7,7 +7,7 @@
* Allow adapter parameters to be set on source document upload
* Add attention key shortcut: Alt+X
* Add attention shortcut to copy from source: Alt+X,G

* Move raw document storage to file system

## zanata-2.3.1
* Bug fixes:
Expand Down
8 changes: 8 additions & 0 deletions functional-test/src/main/java/org/zanata/page/BasePage.java
Expand Up @@ -33,6 +33,7 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.zanata.page.account.MyAccountPage;
import org.zanata.page.account.RegisterPage;
import org.zanata.page.account.SignInPage;
import org.zanata.page.administration.AdministrationPage;
Expand Down Expand Up @@ -80,6 +81,13 @@ public BasePage(final WebDriver driver)
navMenuItems = navBar.findElements(By.tagName("a"));
}

public MyAccountPage goToMyProfile()
{
userColumn.click();
getDriver().findElement(By.id("MyProfile")).click();
return new MyAccountPage(getDriver());
}

public ProjectsPage goToProjects()
{
projectsLink.click();
Expand Down
@@ -0,0 +1,91 @@
/*
* Copyright 2013, 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.account;


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

/**
* @author Damian Jansen <a href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
public class ChangePasswordPage extends BasePage
{

@FindBy(id = "passwordChangeForm:passwordOldField:passwordOld")
private WebElement oldPasswordField;

@FindBy(id = "passwordChangeForm:passwordNewField:passwordNew")
private WebElement newPasswordField;

@FindBy(id = "passwordChangeForm:passwordConfirmField:passwordConfirm")
private WebElement confirmPasswordField;

@FindBy(id = "passwordChangeForm:changePasswordButton")
private WebElement changePasswordButton;

@FindBy(id = "passwordChangeForm:cancelChangePasswordButton")
private WebElement cancelChangePasswordButton;

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

public ChangePasswordPage enterOldPassword(String password)
{
oldPasswordField.sendKeys(password);
return new ChangePasswordPage(getDriver());
}

public ChangePasswordPage enterNewPassword(String password)
{
newPasswordField.sendKeys(password);
return new ChangePasswordPage(getDriver());
}

public ChangePasswordPage enterConfirmNewPassword(String password)
{
confirmPasswordField.sendKeys(password);
return new ChangePasswordPage(getDriver());
}

public MyAccountPage changePassword()
{
changePasswordButton.click();
return new MyAccountPage(getDriver());
}

public MyAccountPage cancelChangePassword()
{
cancelChangePasswordButton.click();
return new MyAccountPage(getDriver());
}

public ChangePasswordPage changePasswordExpectingFailure()
{
changePasswordButton.click();
return new ChangePasswordPage(getDriver());
}

}
@@ -0,0 +1,51 @@
/*
* Copyright 2013, 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.account;


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

/**
* @author Damian Jansen <a href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
public class MyAccountPage extends BasePage
{

@FindBy(linkText = "Edit Profile")
private WebElement editProfileButton;

@FindBy(linkText = "Change Password")
private WebElement changePasswordButton;

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

public ChangePasswordPage goToChangePassword()
{
changePasswordButton.click();
return new ChangePasswordPage(getDriver());
}
}
Expand Up @@ -22,7 +22,7 @@

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.zanata.feature.account.RegisterTestSuite;
import org.zanata.feature.account.AccountTestSuite;
import org.zanata.feature.administration.AdministrationTestSuite;
import org.zanata.feature.glossary.GlossaryTestSuite;
import org.zanata.feature.security.SecurityTestSuite;
Expand All @@ -31,7 +31,7 @@

@RunWith(Suite.class)
@Suite.SuiteClasses({
RegisterTestSuite.class,
AccountTestSuite.class,
AdministrationTestSuite.class,
GlossaryTestSuite.class,
SecurityTestSuite.class,
Expand Down
Expand Up @@ -28,11 +28,12 @@
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
RegisterFullTest.class,
ChangePasswordTest.class,
RegisterTest.class,
UsernameValidationTest.class,
ValidEmailAddressTest.class,
InvalidEmailAddressTest.class
})
public class RegisterTestSuite
public class AccountTestSuite
{
}
@@ -0,0 +1,149 @@
/*
* Copyright 2013, 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.account;

import org.hamcrest.Matchers;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.zanata.feature.BasicAcceptanceTest;
import org.zanata.feature.DetailedTest;
import org.zanata.page.account.ChangePasswordPage;
import org.zanata.page.account.MyAccountPage;
import org.zanata.page.utility.HomePage;
import org.zanata.util.ResetDatabaseRule;
import org.zanata.workflow.LoginWorkFlow;

import static org.hamcrest.MatcherAssert.assertThat;

/**
* @author Damian Jansen <a href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
@Category(DetailedTest.class)
public class ChangePasswordTest
{
@Rule
public ResetDatabaseRule resetDatabaseRule = new ResetDatabaseRule();

@Test
@Category(BasicAcceptanceTest.class)
public void changePasswordSuccessful()
{
MyAccountPage myAccountPage = new LoginWorkFlow().signIn("translator", "translator")
.goToMyProfile()
.goToChangePassword()
.enterOldPassword("translator")
.enterNewPassword("newpassword")
.enterConfirmNewPassword("newpassword")
.changePassword();

assertThat("Confirmation message is displayed", myAccountPage.getNotificationMessage(),
Matchers.equalTo("Your password has been successfully changed."));

HomePage homePage = myAccountPage.signOut();
assertThat("User is logged out", !homePage.hasLoggedIn());
homePage = new LoginWorkFlow().signIn("translator", "newpassword");
assertThat("User has logged in with the new password", homePage.hasLoggedIn());
}

@Test
public void changePasswordCurrentPasswordFailure()
{
String incorrectPassword = "Old password is incorrect, please check and try again.";
ChangePasswordPage changePasswordPage = new LoginWorkFlow().signIn("translator", "translator")
.goToMyProfile()
.goToChangePassword()
.enterOldPassword("nottherightpassword")
.enterNewPassword("somenewpassword")
.enterConfirmNewPassword("somenewpassword")
.changePasswordExpectingFailure();

assertThat("Incorrect password message displayed", changePasswordPage.getErrors(),
Matchers.contains(incorrectPassword));
}

@Test
public void changePasswordConfirmationMismatch()
{
String incorrectPassword = "Passwords do not match";
ChangePasswordPage changePasswordPage = new LoginWorkFlow().signIn("translator", "translator")
.goToMyProfile()
.goToChangePassword()
.enterOldPassword("translator")
.enterNewPassword("somenewpassword")
.enterConfirmNewPassword("differentpassword")
.changePasswordExpectingFailure();

assertThat("Incorrect password message displayed", changePasswordPage.getErrors(),
Matchers.contains(incorrectPassword));
}

@Test
public void changePasswordCancel()
{
MyAccountPage myAccountPage = new LoginWorkFlow().signIn("translator", "translator")
.goToMyProfile()
.goToChangePassword()
.enterOldPassword("translator")
.enterNewPassword("notnewpassword")
.enterConfirmNewPassword("notnewpassword")
.cancelChangePassword();

HomePage homePage = myAccountPage.signOut();
assertThat("User is logged out", !homePage.hasLoggedIn());
homePage = new LoginWorkFlow().signIn("translator", "translator");
assertThat("User has logged in with the original password", homePage.hasLoggedIn());
}

@Test
public void changePasswordRequiredFieldsAreNotEmpty()
{
String emptyPassword = "value is required";
ChangePasswordPage changePasswordPage = new LoginWorkFlow().signIn("translator", "translator")
.goToMyProfile()
.goToChangePassword()
.changePasswordExpectingFailure();

assertThat("Incorrect password message displayed", changePasswordPage.getErrors(),
Matchers.contains(emptyPassword, emptyPassword, emptyPassword));
}

@Test
public void changePasswordAreOfRequiredLength()
{
String passwordSizeError = "size must be between 6 and 20";
String tooShort = "test5";
String tooLong = "t12345678901234567890";
ChangePasswordPage changePasswordPage = new LoginWorkFlow().signIn("translator", "translator")
.goToMyProfile()
.goToChangePassword()
.enterNewPassword("test5")
.enterConfirmNewPassword(tooShort);

assertThat("Incorrect password message displayed", changePasswordPage.waitForErrors(),
Matchers.hasItem(passwordSizeError));

changePasswordPage = changePasswordPage.enterNewPassword(tooLong).enterConfirmNewPassword(tooLong);

assertThat("Incorrect password message displayed", changePasswordPage.waitForErrors(),
Matchers.hasItem(passwordSizeError));
}
}
Expand Up @@ -43,7 +43,7 @@
* @author Damian Jansen <a href="mailto:djansen@redhat.com">djansen@redhat.com</a>
*/
@Category(DetailedTest.class)
public class RegisterFullTest
public class RegisterTest
{
@ClassRule
public static ResetDatabaseRule resetDatabaseRule = new ResetDatabaseRule();
Expand Down

0 comments on commit cbdddcd

Please sign in to comment.