EnVisageOnline/Main/TestSystem/Prevu/Tests/Users.cs

142 lines
8.9 KiB
C#

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace Prevu
{
[TestClass]
public class Users : BaseTest
{
#region Initialization & CleanUp
[ClassInitialize]
public static void ClassInitialize(TestContext TestContext)
{
BaseTest.ClassInitialize(TestContext);
}
[ClassCleanup]
public static void ClassCleanup()
{
BaseTest.ClassCleanup();
}
#endregion Initialization & CleanUp
[TestMethod, TestCategory("Smoke Test"), TestCategory("Users"), Timeout(testTimeout * 5)]
[TestProperty("Create User", "1. Open the Users page<br>2. Click 'Add User' button<br>3. Fill the following fields:<br> User Name<br> First Name<br> Last Name<br> Email Address<br> Phone Number<br>4. Select Roles:<br> Delivery Admin<br> Product Owner<br> QA Engineer<br><br>5. Click Save<br>6.Find created user and check stored data")]
public void CreateUser()
{
Assert.IsTrue(loginPage.SignInAdmin());
Assert.IsTrue(usersPage.OpenUsers());
string id = "";
string userName = string.Format("u{0}", tempId);
string firstName = "User";
string email = string.Format("e{0}@gmail.com", tempId);
string phone = "+1 (900) 768-9056";
string[] roles = new string[3] { "Delivery Admin", "Product Owner", "QA Engineer" };
Assert.IsTrue(usersPage.CreateUser(userName, firstName, tempId, email, phone, roles, out id));
Assert.IsFalse(string.IsNullOrEmpty(id));
Assert.IsTrue(usersPage.CheckUser(id, userName, firstName, tempId, email, phone, roles));
}
[TestMethod, TestCategory("Smoke Test"), TestCategory("Users"), Timeout(testTimeout * 5)]
[TestProperty("Activate User Account", "1. Open the Users page<br>2. Click 'Add User' button<br>3. Fill the following fields:<br> User Name<br> First Name<br> Last Name<br> Email Address<br> Phone Number<br>4. Select Roles:<br> Development Manager<br> Infrastructure Manager<br>5. Click Save<br>6. Log off<br>7. Check the user mailbox and receive letter<br>8. Open the Users account activation URL<br>9. Set up new password<br>10. Log in as new created user")]
public void ActivateUserAccount()
{
IgnoreExistingEmailMessages("iniphiqa", "iniphiqa753");
Assert.IsTrue(loginPage.SignInAdmin());
Assert.IsTrue(usersPage.OpenUsers());
string id = "";
string userName = string.Format("u{0}", tempId);
string firstName = "User";
string email = string.Format("iniphiqa+{0}@gmail.com", tempId);
string phone = "+1 (961) 5368-7542";
string[] roles = new string[2] { "Development Manager", "Infrastructure Manager" };
Assert.IsTrue(usersPage.CreateUser(userName, firstName, tempId, email, phone, roles, out id));
Assert.IsFalse(string.IsNullOrEmpty(id));
Assert.IsTrue(loginPage.SignOut());
string mailBody = "";
Assert.IsTrue(CheckEmailMessage("iniphiqa", "iniphiqa753",
"support@prevuplan.com", email, "Activate your Prevu account", new string[4] {
string.Format("Hello, {0}.", userName),
"Please activate your Prevu account by clicking the following link:",
string.Format("{0}Account/Activate/?userId", driver.Domain),
"Thank you!" },
out mailBody));
Assert.IsNotNull(mailBody);
mailBody = mailBody.Replace("userId", "userId=");
string userId = driver.Subs(mailBody, "Account/Activate/?userId=", ".");
Assert.IsFalse(string.IsNullOrEmpty(userId));
Assert.IsTrue(activateUserAccountPage.ActivateUserAccount(userId, userName, email, string.Format("qa{0}", tempId)));
Assert.IsTrue(loginPage.CheckLoggedInUser(userName));
}
[TestMethod, TestCategory("Smoke Test"), TestCategory("Users"), Timeout(testTimeout)]
[TestProperty("Delete User", "1. Find a user<br>2. Click Delete button<br>3. Check warning message:<br> You are about to delete the User Name.Are you sure you want to delete it?<br>4. Click Delete button<br>5. Make sure that user is deleted")]
public void DeleteUser()
{
Assert.IsTrue(loginPage.SignInAdmin());
Assert.IsTrue(usersPage.OpenUsers());
string id = "";
string userName = string.Format("d{0}", tempId);
string firstName = "User";
string email = string.Format("d{0}@gmail.com", tempId);
string phone = "+1 (902) 657-9312";
string[] roles = new string[1] { "Director" };
Assert.IsTrue(usersPage.CreateUser(userName, firstName, tempId, email, phone, roles, out id));
Assert.IsFalse(string.IsNullOrEmpty(id));
Assert.IsTrue(usersPage.DeleteUser(id, userName));
}
[TestMethod, TestCategory("Smoke Test"), TestCategory("Users"), Timeout(testTimeout)]
[TestProperty("Edit User", "1. Find a user<br>2. Click Edit button<br>3. Change the following fields:<br> User Name<br> First Name<br> Last Name<br> Email Address<br> Phone Number<br> Add new roles<br>4. Click Save<br>5. Open the Users details<br>6. Check edited field values")]
public void EditUser()
{
Assert.IsTrue(loginPage.SignInAdmin());
Assert.IsTrue(usersPage.OpenUsers());
string id = "";
string userName = string.Format("d{0}", tempId);
string firstName = "User";
string email = string.Format("u{0}@gmail.com", tempId);
string phone = "+1 (902) 657-9312";
string[] roles = new string[1] { "Director" };
Assert.IsTrue(usersPage.CreateUser(userName, firstName, tempId, email, phone, roles, out id));
Assert.IsFalse(string.IsNullOrEmpty(id));
userName = string.Format("d{0}E", tempId);
firstName = "UserE";
string lastName = string.Format("{0}E", tempId);
email = string.Format("u{0}E@gmail.com", tempId);
phone = "+1 (999) 009-0021";
roles = new string[3] { "Delivery Admin", "Product Owner", "QA Engineer" };
Assert.IsTrue(usersPage.EditUser(id, userName, firstName, lastName, email, phone, roles));
}
[TestMethod, TestCategory("Smoke Test"), TestCategory("Users"), Timeout(testTimeout)]
[TestProperty("Reset User Password", "1. Find a user<br>2. Click 'Reset Password' button<br>3. Check the notification message:<br> Email with reset password link has been sent to user's email.<br>4. Log off<br>5. Check mailbox and receive mail message<br>6. Check mail message:<br> Hello, < username ><br> You can restore your Prevu account by clicking the following link: Account / RestorePassword /? token = < token >.<br> Thank you!<br>7. Open the password restore URL<br>8. Check the Restore Password form:<br> Enter new password<br>9. Input new password to Password field<br>10. Input new password to Password Confirmation field<br>11. Click Submit<br>12. Check the notification message:<br> Password has been successfully changed.<br>13. Click 'Back to login page'<br>14. Input username to Username<br>15. Input new password to Passwors<br>16. Click Sign In")]
public void ResetUserPassword()
{
Assert.IsTrue(loginPage.SignInAdmin());
Assert.IsTrue(usersPage.OpenUsers());
Assert.IsTrue(usersPage.ResetUserPassword("iniphiqa@gmail.com"));
Assert.IsTrue(usersPage.OpenUsers());
Assert.IsTrue(loginPage.SignOut());
string mailBody = "";
Assert.IsTrue(CheckEmailMessage("iniphiqa", "iniphiqa753",
"support@prevuplan.com", "iniphiqa@gmail.com", "Restore password", new string[5] {
"Hello, gdonavan.",
"You can restore your Prevu account by clicking the following link:",
string.Format("{0}Account/RestorePassword/?token", driver.Domain),
"The link can only be used for 24 hours.",
"Thank you!" },
out mailBody));
Assert.IsNotNull(mailBody);
mailBody = mailBody.Replace("token", "token=");
string token = driver.Subs(mailBody, "Account/RestorePassword/?token=", ".");
Assert.IsFalse(string.IsNullOrEmpty(token));
Assert.IsTrue(forgotPasswordPage.OpenResetPassword(token, "Enter new password"));
string newPassword = string.Format("qa{0}", tempId);
Assert.IsTrue(forgotPasswordPage.ResetPassword(newPassword));
Assert.IsTrue(loginPage.SignIn("gdonavan", newPassword));
}
}
}