Commits

Vineet Reynolds committed c1a9ded

Added Selenium test for deletion of accounts.

Comments (0)

Files changed (4)

galleria-jsf/src/test/java/info/galleria/view/user/AccountPreferencesPage.java

 		return new AccountPreferencesPage(driver, contextPath);
 	}
 
+	public IndexPage deleteAcccount()
+	{
+		driver.findElement(By.id("deleteAccountForm:deleteAccount")).click();
+		return new IndexPage(driver, contextPath);
+	}
+
 	public String[] fetchErrorMessages()
 	{
 		List<String> errorMessages = new ArrayList<String>();

galleria-jsf/src/test/java/info/galleria/view/user/AllPagesIntegrationTest.java

 		IndexPage indexPage = new IndexPage(driver, contextPath);
 		SignupPage signupPage = indexPage.chooseToSignup();
 		indexPage = signupPage.signupAs("User#1", "password");
-		String message = "The new user account has been created. You may now login.";
-		assertEquals(message, indexPage.fetchSignupSuccessMessage());
+		String[] message = {"The new user account has been created. You may now login."};
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
 	}
 
 	@Test
 		IndexPage indexPage = new IndexPage(driver, contextPath);
 		SignupPage signupPage = indexPage.chooseToSignup();
 		indexPage = signupPage.signupAs("User#1", "password");
-		String message = "The new user account has been created. You may now login.";
-		assertEquals(message, indexPage.fetchSignupSuccessMessage());
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
 		signupPage = indexPage.chooseToSignup();
 		signupPage = signupPage.signupAsExpectingError("User#1", "password", "password");
 		String[] errorMessages = { "The user account Id is already taken. Please choose another." };
 		assertArrayEquals(errorMessages, signupPage.fetchSignupErrorMessages());
 	}
-	
+
 	@Test
 	public void testLoginUserInvalidCredentials() throws Exception
 	{
 		IndexPage indexPage = new IndexPage(driver, contextPath);
 		SignupPage signupPage = indexPage.chooseToSignup();
 		indexPage = signupPage.signupAs("User#1", "password");
-		String message = "The new user account has been created. You may now login.";
-		assertEquals(message, indexPage.fetchSignupSuccessMessage());
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
 
 		LoginPage loginPage = indexPage.chooseToLogin();
 		loginPage.loginAsExpectingError("User#2", "password");
 		IndexPage indexPage = new IndexPage(driver, contextPath);
 		SignupPage signupPage = indexPage.chooseToSignup();
 		indexPage = signupPage.signupAs("User#1", "password");
-		String message = "The new user account has been created. You may now login.";
-		assertEquals(message, indexPage.fetchSignupSuccessMessage());
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
 
 		LoginPage loginPage = indexPage.chooseToLogin();
 		loginPage.loginAs("User#1", "password");
 		IndexPage indexPage = new IndexPage(driver, contextPath);
 		SignupPage signupPage = indexPage.chooseToSignup();
 		indexPage = signupPage.signupAs("User#1", "password");
-		String message = "The new user account has been created. You may now login.";
-		assertEquals(message, indexPage.fetchSignupSuccessMessage());
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
 
 		LoginPage loginPage = indexPage.chooseToLogin();
 		HomePage homePage = loginPage.loginAs("User#1", "password");
 		homePage.logout();
 	}
-	
+
 	@Test
 	public void testModifyPassword() throws Exception
 	{
 		IndexPage indexPage = new IndexPage(driver, contextPath);
 		SignupPage signupPage = indexPage.chooseToSignup();
 		indexPage = signupPage.signupAs("User#1", "password");
-		String message = "The new user account has been created. You may now login.";
-		assertEquals(message, indexPage.fetchSignupSuccessMessage());
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
 
 		LoginPage loginPage = indexPage.chooseToLogin();
 		HomePage homePage = loginPage.loginAs("User#1", "password");
 		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
 		homePage = accountPreferencesPage.modifyPasswordAs("password", "password1", "password1");
-		message = "The password has been modified.";
-		assertEquals(message, homePage.fetchSuccessMessage());
+		String[] successMessage = { "The password has been modified." };
+		assertArrayEquals(successMessage, homePage.fetchSuccessMessages());
 	}
-	
+
 	@Test
 	public void testModifyPasswordWithIncorrectOld() throws Exception
 	{
 		IndexPage indexPage = new IndexPage(driver, contextPath);
 		SignupPage signupPage = indexPage.chooseToSignup();
 		indexPage = signupPage.signupAs("User#1", "password");
-		String message = "The new user account has been created. You may now login.";
-		assertEquals(message, indexPage.fetchSignupSuccessMessage());
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
 
 		LoginPage loginPage = indexPage.chooseToLogin();
 		HomePage homePage = loginPage.loginAs("User#1", "password");
 		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
 		accountPreferencesPage.modifyPasswordAsExpectingError("password1", "password2", "password2");
-		String[] errorMessages = {"The old password entered does not match your current password."};
+		String[] errorMessages = { "The old password entered does not match your current password." };
 		assertArrayEquals(errorMessages, accountPreferencesPage.fetchErrorMessages());
 	}
-	
+
 	@Test
 	public void testModifyPasswordWithMismatchingNew() throws Exception
 	{
 		IndexPage indexPage = new IndexPage(driver, contextPath);
 		SignupPage signupPage = indexPage.chooseToSignup();
 		indexPage = signupPage.signupAs("User#1", "password");
-		String message = "The new user account has been created. You may now login.";
-		assertEquals(message, indexPage.fetchSignupSuccessMessage());
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
 
 		LoginPage loginPage = indexPage.chooseToLogin();
 		HomePage homePage = loginPage.loginAs("User#1", "password");
 		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
 		accountPreferencesPage.modifyPasswordAsExpectingError("password", "password1", "password2");
-		String[] errorMessages = {"The new password and the confirm password values do not match."};
+		String[] errorMessages = { "The new password and the confirm password values do not match." };
 		assertArrayEquals(errorMessages, accountPreferencesPage.fetchErrorMessages());
 	}
-	
+
 	@Test
 	public void testModifyPasswordWithSameOldAndNew() throws Exception
 	{
 		IndexPage indexPage = new IndexPage(driver, contextPath);
 		SignupPage signupPage = indexPage.chooseToSignup();
 		indexPage = signupPage.signupAs("User#1", "password");
-		String message = "The new user account has been created. You may now login.";
-		assertEquals(message, indexPage.fetchSignupSuccessMessage());
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
 
 		LoginPage loginPage = indexPage.chooseToLogin();
 		HomePage homePage = loginPage.loginAs("User#1", "password");
 		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
 		accountPreferencesPage.modifyPasswordAsExpectingError("password", "password", "password");
-		String[] errorMessages = {"Your new password cannot be the same as the old password."};
+		String[] errorMessages = { "Your new password cannot be the same as the old password." };
 		assertArrayEquals(errorMessages, accountPreferencesPage.fetchErrorMessages());
 	}
 
+	@Test
+	public void testDeleteAccount() throws Exception
+	{
+		driver.get(contextPath.toString());
+		IndexPage indexPage = new IndexPage(driver, contextPath);
+		SignupPage signupPage = indexPage.chooseToSignup();
+		indexPage = signupPage.signupAs("User#1", "password");
+		String[] message = { "The new user account has been created. You may now login." };
+		assertArrayEquals(message, indexPage.fetchSuccessMessages());
+
+		LoginPage loginPage = indexPage.chooseToLogin();
+		HomePage homePage = loginPage.loginAs("User#1", "password");
+		AccountPreferencesPage accountPreferencesPage = homePage.goToAccountPreferences();
+		indexPage = accountPreferencesPage.deleteAcccount();
+		String[] messages = { "The account was deleted successfully." };
+		assertArrayEquals(messages, indexPage.fetchSuccessMessages());
+	}
+
 }

galleria-jsf/src/test/java/info/galleria/view/user/HomePage.java

 package info.galleria.view.user;
 
 import java.net.URI;
+import java.util.*;
 
 import org.openqa.selenium.*;
 import org.openqa.selenium.support.ui.*;
 		return new AccountPreferencesPage(driver, contextPath);
 	}
 
-	public String fetchSuccessMessage()
+	public String[] fetchSuccessMessages()
 	{
-		return driver.findElement(By.xpath("//ul[@id='messages']/li[1]")).getText();
+		List<String> errorMessages = new ArrayList<String>();
+		for (WebElement element : driver.findElements(By.xpath("//ul[@id='messages']/li[@class='errorStyle']")))
+		{
+			errorMessages.add(element.getText());
+		}
+		return errorMessages.toArray(new String[0]);
 	}
 
 }

galleria-jsf/src/test/java/info/galleria/view/user/IndexPage.java

 package info.galleria.view.user;
 
 import java.net.URI;
+import java.util.*;
 
 import org.openqa.selenium.*;
 import org.openqa.selenium.support.ui.*;
 		return new LoginPage(driver, contextPath);
 	}
 
-	public String fetchSignupSuccessMessage()
+	public String[] fetchSuccessMessages()
 	{
-		return driver.findElement(By.xpath("//ul[@id='messages']/li[1]")).getText();
+		List<String> errorMessages = new ArrayList<String>();
+		for (WebElement element : driver.findElements(By.xpath("//ul[@id='messages']/li[@class='infoStyle']")))
+		{
+			errorMessages.add(element.getText());
+		}
+		return errorMessages.toArray(new String[0]);
 	}
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.