mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-24 19:06:44 +00:00
test(BRIDGE-220): Add Bridge E2E UI login/logout tests for Windows
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
using FlaUI.Core.AutomationElements;
|
||||
using FlaUI.Core.Definitions;
|
||||
using FlaUI.Core.Conditions;
|
||||
using FlaUI.Core.Input;
|
||||
using ProtonMailBridge.UI.Tests.TestsHelper;
|
||||
using System;
|
||||
|
||||
|
||||
@ -8,10 +11,14 @@ namespace ProtonMailBridge.UI.Tests.Windows
|
||||
public class HomeWindow : UIActions
|
||||
{
|
||||
private AutomationElement[] AccountViewButtons => AccountView.FindAllChildren(cf => cf.ByControlType(ControlType.Button));
|
||||
private AutomationElement[] HomeButtons => Window.FindAllDescendants(cf => cf.ByControlType(ControlType.Button));
|
||||
private Button AddNewAccountButton => HomeButtons[6].AsButton();
|
||||
private Button RemoveAccountButton => AccountViewButtons[1].AsButton();
|
||||
private AutomationElement RemoveAccountConfirmModal => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Window));
|
||||
private Button ConfirmRemoveAccountButton => RemoveAccountConfirmModal.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Remove this account"))).AsButton();
|
||||
private Button SignOutButton => AccountView.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Sign out"))).AsButton();
|
||||
private Button SignInButton => AccountView.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Sign in"))).AsButton();
|
||||
|
||||
public HomeWindow RemoveAccount()
|
||||
{
|
||||
try
|
||||
@ -25,10 +32,23 @@ namespace ProtonMailBridge.UI.Tests.Windows
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public HomeWindow AddNewAccount ()
|
||||
{
|
||||
AddNewAccountButton.Click();
|
||||
return this;
|
||||
}
|
||||
|
||||
public HomeWindow SignOutAccount()
|
||||
{
|
||||
SignOutButton.Click();
|
||||
return this;
|
||||
}
|
||||
public HomeWindow ClickSignInMainWindow()
|
||||
{
|
||||
SignInButton.Click();
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
using FlaUI.Core.Input;
|
||||
using FlaUI.Core.Definitions;
|
||||
using ProtonMailBridge.UI.Tests.TestsHelper;
|
||||
using ProtonMailBridge.UI.Tests.Results;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace ProtonMailBridge.UI.Tests.Windows
|
||||
{
|
||||
@ -11,14 +13,32 @@ namespace ProtonMailBridge.UI.Tests.Windows
|
||||
private TextBox UsernameInput => InputFields[0].AsTextBox();
|
||||
private TextBox PasswordInput => InputFields[1].AsTextBox();
|
||||
private Button SignInButton => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Sign in"))).AsButton();
|
||||
private Button SigningInButton => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Signing in"))).AsButton();
|
||||
private Button StartSetupButton => Window.FindFirstDescendant(cf => cf.ByName("Start setup")).AsButton();
|
||||
private Button SetUpLater => Window.FindFirstDescendant(cf => cf.ByName("Setup later")).AsButton();
|
||||
private TextBox MailboxPasswordInput => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Edit)).AsTextBox();
|
||||
private Button UnlockButton => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Unlock"))).AsButton();
|
||||
private Button CancelSignIn => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Cancel"))).AsButton();
|
||||
|
||||
public LoginWindow SignIn(TestUserData user)
|
||||
{
|
||||
ClickStartSetupButton();
|
||||
EnterCredentials(user);
|
||||
WaitForAuthorizationToComplete(60);
|
||||
|
||||
SetUpLater?.Click();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoginWindow SignInMailbox(TestUserData user)
|
||||
{
|
||||
ClickStartSetupButton();
|
||||
EnterCredentials(user);
|
||||
Wait.UntilInputIsProcessed(TestData.TenSecondsTimeout);
|
||||
EnterMailboxPassword(user);
|
||||
Wait.UntilInputIsProcessed(TestData.TenSecondsTimeout);
|
||||
|
||||
SetUpLater?.Click();
|
||||
|
||||
return this;
|
||||
@ -30,7 +50,6 @@ namespace ProtonMailBridge.UI.Tests.Windows
|
||||
SignIn(user);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoginWindow ClickStartSetupButton()
|
||||
{
|
||||
StartSetupButton?.Click();
|
||||
@ -45,5 +64,38 @@ namespace ProtonMailBridge.UI.Tests.Windows
|
||||
SignInButton.Click();
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoginWindow EnterMailboxPassword(TestUserData user)
|
||||
{
|
||||
MailboxPasswordInput.Text = user.MailboxPassword;
|
||||
UnlockButton.Click();
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoginWindow ClickCancelToSignIn ()
|
||||
{
|
||||
CancelSignIn.Click();
|
||||
return this;
|
||||
}
|
||||
|
||||
private void WaitForAuthorizationToComplete(int numOfSeconds)
|
||||
{
|
||||
TimeSpan timeout = TimeSpan.FromSeconds(numOfSeconds);
|
||||
Stopwatch stopwatch = Stopwatch.StartNew();
|
||||
|
||||
|
||||
while (stopwatch.Elapsed < timeout)
|
||||
{
|
||||
//if Signing in button is not visible authorization process is finished
|
||||
if (SigningInButton == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Wait.UntilInputIsProcessed();
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user