test(BRIDGE-248): Additional Bridge UI e2e automation tests

This commit is contained in:
Gordana Zafirova
2024-12-30 14:17:10 +00:00
parent 28b0dbd051
commit 16245a372e
3 changed files with 79 additions and 23 deletions

View File

@ -22,6 +22,7 @@ namespace ProtonMailBridge.UI.Tests.Results
private TextBox EnterEmailOrUsernameErrorText => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text).And(cf.ByName("Enter email or username"))).AsTextBox(); private TextBox EnterEmailOrUsernameErrorText => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text).And(cf.ByName("Enter email or username"))).AsTextBox();
private TextBox EnterPasswordErrorText => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text).And(cf.ByName("Enter password"))).AsTextBox(); private TextBox EnterPasswordErrorText => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text).And(cf.ByName("Enter password"))).AsTextBox();
private TextBox ConnectedStateText => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text).And(cf.ByName("Connected"))).AsTextBox(); private TextBox ConnectedStateText => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Text).And(cf.ByName("Connected"))).AsTextBox();
private CheckBox SplitAddressesToggle => AccountView.FindFirstDescendant(cf => cf.ByControlType(ControlType.CheckBox).And(cf.ByName("Split addresses toggle"))).AsCheckBox();
public HomeResult CheckConnectedState() public HomeResult CheckConnectedState()
{ {
@ -81,7 +82,6 @@ namespace ProtonMailBridge.UI.Tests.Results
{ {
Assert.That(AccountDelinquentErrorText.IsAvailable, Is.True); Assert.That(AccountDelinquentErrorText.IsAvailable, Is.True);
return this; return this;
} }
public HomeResult CheckIfNotificationTextIsShown() public HomeResult CheckIfNotificationTextIsShown()
@ -89,5 +89,11 @@ namespace ProtonMailBridge.UI.Tests.Results
Assert.That(AlreadySignedInText.IsAvailable, Is.True); Assert.That(AlreadySignedInText.IsAvailable, Is.True);
return this; return this;
} }
public HomeResult CheckIfSplitAddressesIsDisabledByDefault()
{
Assert.That(SplitAddressesToggle.IsToggled, Is.False);
return this;
}
} }
} }

View File

@ -108,18 +108,6 @@ namespace ProtonMailBridge.UI.Tests.Tests
_mainWindow.SignOutAccount(); _mainWindow.SignOutAccount();
} }
/*
[Test]
public void AddSecondAccount()
{
_loginWindow.SignIn(TestUserData.GetPaidUser());
_homeResult.CheckIfLoggedIn();
_mainWindow.AddNewAccount();
_loginWindow.SignInMailbox(TestUserData.GetMailboxUser());
_homeResult.CheckIfLoggedIn();
}
*/
[Test] [Test]
public void AddDisabledAccount() public void AddDisabledAccount()
{ {
@ -136,13 +124,22 @@ namespace ProtonMailBridge.UI.Tests.Tests
_loginWindow.ClickCancelToSignIn(); _loginWindow.ClickCancelToSignIn();
} }
//[Test] [Test]
//public void SuccessfullLogout() public void VerifySplitAddressesIsDisabledByDefault()
//{ {
// _loginWindow.SignIn(TestUserData.GetPaidUser()); _loginWindow.SignIn(TestUserData.GetPaidUser());
// _mainWindow.SignOutAccount(); _homeResult.CheckIfSplitAddressesIsDisabledByDefault();
// _homeResult.CheckIfAccountIsSignedOut(); Thread.Sleep(1000);
//} }
[Test]
public void EnableAndDisableSplitAddressMode()
{
_loginWindow.SignIn(TestUserData.GetPaidUser());
_mainWindow.EnableSplitAddress();
Thread.Sleep(5000);
_mainWindow.DisableSplitAddress();
}
[SetUp] [SetUp]
public void TestInitialize() public void TestInitialize()

View File

@ -18,6 +18,8 @@ namespace ProtonMailBridge.UI.Tests.Windows
private Button ConfirmRemoveAccountButton => RemoveAccountConfirmModal.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Remove this account"))).AsButton(); 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 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(); private Button SignInButton => AccountView.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Sign in"))).AsButton();
private CheckBox SplitAddressesToggle => AccountView.FindFirstDescendant(cf => cf.ByControlType(ControlType.CheckBox).And(cf.ByName("Split addresses toggle"))).AsCheckBox();
private Button EnableSplitAddressButton => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Enable split mode"))).AsButton();
public HomeWindow RemoveAccount() public HomeWindow RemoveAccount()
{ {
@ -33,7 +35,7 @@ namespace ProtonMailBridge.UI.Tests.Windows
return this; return this;
} }
public HomeWindow AddNewAccount () public HomeWindow AddNewAccount()
{ {
AddNewAccountButton.Click(); AddNewAccountButton.Click();
return this; return this;
@ -49,6 +51,57 @@ namespace ProtonMailBridge.UI.Tests.Windows
SignInButton.Click(); SignInButton.Click();
return this; return this;
} }
public HomeWindow EnableSplitAddress()
{
SplitAddressesToggle.Click();
EnableSplitAddressButton.Click();
Thread.Sleep(5000);
bool syncRestarted = WaitForCondition(() =>
{
return IsStatusLabelSyncing(Window);
}, TimeSpan.FromSeconds(30));
Assert.That(syncRestarted, Is.True, "Sync did not restart after Split Address mode was enabled.");
Assert.That(SplitAddressesToggle.IsToggled, Is.True);
return this;
}
public HomeWindow DisableSplitAddress()
{
SplitAddressesToggle.Click();
Thread.Sleep(5000);
bool syncRestarted = WaitForCondition(() =>
{
return IsStatusLabelSyncing(Window);
}, TimeSpan.FromSeconds(30));
Assert.That(syncRestarted, Is.True, "Sync did not restart after Split Address mode was disabled.");
Assert.That(SplitAddressesToggle.IsToggled, Is.False);
return this;
}
private bool IsStatusLabelSyncing(AutomationElement window)
{
var syncStatusElement = window.FindAllDescendants(cf => cf.ByControlType(ControlType.Text)).FirstOrDefault(el =>
{
string name = el.Name;
return !string.IsNullOrEmpty(name) &&
name.StartsWith("Synchronizing (") &&
name.EndsWith("%)");
});
return syncStatusElement != null && syncStatusElement.Name.Contains("Synchronizing");
}
private bool WaitForCondition(Func<bool> condition, TimeSpan timeout, int pollingIntervalMs = 500)
{
var endTime = DateTime.Now + timeout;
while (DateTime.Now < endTime)
{
if (condition())
return true;
Thread.Sleep(pollingIntervalMs);
}
return false;
}
} }
} }