1
0

test(BRIDGE-136): Download Bridge

This commit is contained in:
Gjorgji Slamkov
2025-08-15 09:25:10 +02:00
committed by Gordana Zafirova
parent cf9b35163a
commit fd709b0d08
21 changed files with 697 additions and 130 deletions

View File

@ -32,7 +32,7 @@ namespace ProtonMailBridge.UI.Tests.Windows
private Button LogsButton => HomeButtons[9].AsButton();
private Button ReportProblemButton => HomeButtons[10].AsButton();
private Button ICannotFindEmailInClient => HomeButtons[7].AsButton();
private TextBox DescriptionOnWhatHappened => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Edit)).AsTextBox();
private TextBox DescriptionOnWhatHappened => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Pane)).FindFirstDescendant(cf => cf.ByControlType(ControlType.Pane)).FindFirstDescendant(cf => cf.ByControlType(ControlType.Edit)).AsTextBox();
private RadioButton MissingEmails => ReportProblemPane[0].FindFirstDescendant(cf => cf.ByControlType(ControlType.RadioButton).And(cf.ByName("Old emails are missing"))).AsRadioButton();
private RadioButton FindEmails => ReportProblemPane[0].FindFirstDescendant(cf => cf.ByControlType(ControlType.RadioButton).And(cf.ByName("Yes"))).AsRadioButton();
private CheckBox VPNSoftware => ReportProblemPane[0].FindFirstDescendant(cf => cf.ByControlType(ControlType.CheckBox).And(cf.ByName("VPN"))).AsCheckBox();

View File

@ -11,6 +11,7 @@ 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();
@ -21,14 +22,14 @@ namespace ProtonMailBridge.UI.Tests.Windows
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 RemoveAccountTestCleanup()
{
try
{
RemoveAccountButton.Click();
ConfirmRemoveAccountButton.Click();
}
catch (System.NullReferenceException)
catch (System.IndexOutOfRangeException)
{
ClientCleanup();
}

View File

@ -4,6 +4,7 @@ using FlaUI.Core.Definitions;
using ProtonMailBridge.UI.Tests.TestsHelper;
using ProtonMailBridge.UI.Tests.Results;
using System.Diagnostics;
using System.ComponentModel.DataAnnotations;
namespace ProtonMailBridge.UI.Tests.Windows
{
@ -11,7 +12,8 @@ namespace ProtonMailBridge.UI.Tests.Windows
{
private AutomationElement[] InputFields => Window.FindAllDescendants(cf => cf.ByControlType(ControlType.Edit));
private TextBox UsernameInput => InputFields[0].AsTextBox();
private TextBox PasswordInput => InputFields[1].AsTextBox();
private AutomationElement PasswordGroup => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Group).And(cf.ByName("Password")));
private TextBox PasswordInput => PasswordGroup.FindFirstDescendant(cf => cf.ByControlType(ControlType.Edit)).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();
@ -20,11 +22,17 @@ namespace ProtonMailBridge.UI.Tests.Windows
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();
private Button UnlockingButton => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Unlocking"))).AsButton();
private static readonly int loginTimeout = 500;
public LoginWindow SignIn(TestUserData user)
{
ClickStartSetupButton();
TestContext.Out.WriteLine($"Trying to login with '{user.Username}':'{user.Password}'. Attempt {i}.");
EnterCredentials(user);
WaitForAuthorizationToComplete(60);
WaitForAuthorizationToComplete(loginTimeout);
SetUpLater?.Click();
@ -33,11 +41,9 @@ namespace ProtonMailBridge.UI.Tests.Windows
public LoginWindow SignInMailbox(TestUserData user)
{
ClickStartSetupButton();
EnterCredentials(user);
Wait.UntilInputIsProcessed(TestData.TenSecondsTimeout);
SignIn(user);
EnterMailboxPassword(user);
Wait.UntilInputIsProcessed(TestData.TenSecondsTimeout);
WaitForUnlockToComplete(loginTimeout);
SetUpLater?.Click();
@ -59,8 +65,14 @@ namespace ProtonMailBridge.UI.Tests.Windows
public LoginWindow EnterCredentials(TestUserData user)
{
for (int i = 0; i < InputFields.Length; i++)
{
Console.WriteLine($"---------- {InputFields[i].Name} ----------");
}
UsernameInput.Text = user.Username;
PasswordInput.Text = user.Password;
TestContext.Out.WriteLine($"Trying to sign in with username '{user.Username}' and password '{user.Password}'");
SignInButton.Click();
return this;
}
@ -68,6 +80,7 @@ namespace ProtonMailBridge.UI.Tests.Windows
public LoginWindow EnterMailboxPassword(TestUserData user)
{
MailboxPasswordInput.Text = user.MailboxPassword;
TestContext.Out.WriteLine($"Entering mailbox password '{user.MailboxPassword}'");
UnlockButton.Click();
return this;
}
@ -97,5 +110,25 @@ namespace ProtonMailBridge.UI.Tests.Windows
}
}
private void WaitForUnlockToComplete(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 (UnlockingButton == null)
{
return;
}
Wait.UntilInputIsProcessed();
Thread.Sleep(500);
}
}
}
}

View File

@ -19,7 +19,6 @@ using ProtonMailBridge.UI.Tests.TestsHelper;
using Keyboard = FlaUI.Core.Input.Keyboard;
using Mouse = FlaUI.Core.Input.Mouse;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Window;
//using System.Windows.Forms;
using CheckBox = FlaUI.Core.AutomationElements.CheckBox;
using FlaUI.Core.Tools;
using System.Diagnostics;
@ -87,125 +86,127 @@ namespace ProtonMailBridge.UI.Tests.Windows
private Button ResetButton => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Reset Bridge button"))).AsButton();
private Button ResetAndRestartButtonInPopUp => NotificationWindow.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Reset and restart"))).AsButton();
private Button StartSetUpButton => Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Button).And(cf.ByName("Start setup"))).AsButton();
public SettingsMenuWindow ClickSettingsButton()
{
SettingsButton.Click();
RetryHelper.EventuallyAction(() => SettingsButton.Click());
return this;
}
public SettingsMenuWindow ClickBackFromSettingsMenu()
{
BackToAccountViewButton.Click();
RetryHelper.EventuallyAction(() => BackToAccountViewButton.Click());
return this;
}
public SettingsMenuWindow DisableAndEnableAutomaticUpdates()
{
AutomaticUpdates.Click();
Assert.That(AutomaticUpdates.IsToggled, Is.False);
RetryHelper.EventuallyAction(() => AutomaticUpdates.Click());
RetryHelper.EventuallyAction(() => Assert.That(AutomaticUpdates.IsToggled, Is.False));
Thread.Sleep(1000);
AutomaticUpdates.Click();
Assert.That(AutomaticUpdates.IsToggled, Is.True);
RetryHelper.EventuallyAction(() => AutomaticUpdates.Click());
RetryHelper.EventuallyAction(() => Assert.That(AutomaticUpdates.IsToggled, Is.True));
return this;
}
public SettingsMenuWindow DisableAndEnableOpenOnStartUp()
{
OpenOnStartUp.Click();
Assert.That(OpenOnStartUp.IsToggled, Is.False);
RetryHelper.EventuallyAction(() => OpenOnStartUp.Click());
RetryHelper.EventuallyAction(() => Assert.That(OpenOnStartUp.IsToggled, Is.False));
Thread.Sleep(1000);
OpenOnStartUp.Click();
Assert.That(OpenOnStartUp.IsToggled, Is.True);
RetryHelper.EventuallyAction(() => OpenOnStartUp.Click());
RetryHelper.EventuallyAction(() => Assert.That(OpenOnStartUp.IsToggled, Is.True));
return this;
}
public SettingsMenuWindow EnableAndDisableBetaAccess()
{
BetaAccess.Click();
EnableBetaAccessButtonInPopUp.Click();
RetryHelper.EventuallyAction(() => BetaAccess.Click());
RetryHelper.EventuallyAction(() => EnableBetaAccessButtonInPopUp.Click());
Thread.Sleep(1000);
Assert.That(BetaAccess.IsToggled, Is.True);
BetaAccess.Click();
Assert.That(BetaAccess.IsToggled, Is.False);
RetryHelper.EventuallyAction(() => Assert.That(BetaAccess.IsToggled, Is.True));
RetryHelper.EventuallyAction(() => BetaAccess.Click());
RetryHelper.EventuallyAction(() => Assert.That(BetaAccess.IsToggled, Is.False));
return this;
}
public SettingsMenuWindow ExpandAdvancedSettings()
{
AdvancedSettings.Click();
RetryHelper.EventuallyAction(() => AdvancedSettings.Click());
Thread.Sleep(1000);
Assert.That(AlternativeRouting != null && AlternativeRouting.IsAvailable, Is.True);
RetryHelper.EventuallyAction(() => Assert.That(AlternativeRouting != null && AlternativeRouting.IsAvailable, Is.True));
return this;
}
public SettingsMenuWindow CollapseAdvancedSettings()
{
AdvancedSettings.Click();
RetryHelper.EventuallyAction(() => AdvancedSettings.Click());
return this;
}
public SettingsMenuWindow EnableAndDisableAlternativeRouting()
{
AlternativeRouting.Click();
Assert.That(AlternativeRouting.IsToggled, Is.True);
RetryHelper.EventuallyAction(() => AlternativeRouting.Click());
RetryHelper.EventuallyAction(() => Assert.That(AlternativeRouting.IsToggled, Is.True));
Thread.Sleep(1000);
AlternativeRouting.Click();
Assert.That(AlternativeRouting?.IsToggled, Is.False);
RetryHelper.EventuallyAction(() => AlternativeRouting.Click());
RetryHelper.EventuallyAction(() => Assert.That(AlternativeRouting?.IsToggled, Is.False));
return this;
}
public SettingsMenuWindow CheckEnableAndDisableDarkMode()
{
DarkMode.Click();
Assert.That(DarkMode.IsToggled, Is.True);
RetryHelper.EventuallyAction(() => DarkMode.Click());
RetryHelper.EventuallyAction(() => Assert.That(DarkMode.IsToggled, Is.True));
Thread.Sleep(1000);
DarkMode.Click();
Assert.That(DarkMode.IsToggled, Is.False);
RetryHelper.EventuallyAction(() => DarkMode.Click());
RetryHelper.EventuallyAction(() => Assert.That(DarkMode.IsToggled, Is.False));
return this;
}
public SettingsMenuWindow DisableAndEnableShowAllMail()
{
ShowAllMail.Click();
HideAllMailFolderInPopUp.Click();
Assert.That(ShowAllMail.IsToggled, Is.False);
RetryHelper.EventuallyAction(() => ShowAllMail.Click());
RetryHelper.EventuallyAction(() => HideAllMailFolderInPopUp.Click());
RetryHelper.EventuallyAction(() => Assert.That(ShowAllMail.IsToggled, Is.False));
Thread.Sleep(1000);
ShowAllMail.Click();
RetryHelper.EventuallyAction(() => ShowAllMail.Click());
Thread.Sleep(1000);
ShowAllMailFolderInPopUp.Click();
Assert.That(ShowAllMail?.IsToggled, Is.True);
RetryHelper.EventuallyAction(() => ShowAllMailFolderInPopUp.Click());
RetryHelper.EventuallyAction(() => Assert.That(ShowAllMail?.IsToggled, Is.True));
return this;
}
public SettingsMenuWindow DisableAndEnableCollectUsageDiagnostics()
{
CollectUsageDiagnostics.Click();
RetryHelper.EventuallyAction(() => CollectUsageDiagnostics.Click());
Thread.Sleep(3000);
Assert.That(CollectUsageDiagnostics.IsToggled, Is.False);
RetryHelper.EventuallyAction(() => Assert.That(CollectUsageDiagnostics.IsToggled, Is.False));
Thread.Sleep(1000);
CollectUsageDiagnostics.Click();
RetryHelper.EventuallyAction(() => CollectUsageDiagnostics.Click());
Thread.Sleep(1000);
Assert.That(CollectUsageDiagnostics?.IsToggled, Is.True);
RetryHelper.EventuallyAction(() => Assert.That(CollectUsageDiagnostics?.IsToggled, Is.True));
return this;
}
public SettingsMenuWindow OpenChangeDefaultPorts()
{
ChangeDefaultPortsButton.Click();
RetryHelper.EventuallyAction(() => ChangeDefaultPortsButton.Click());
return this;
}
public SettingsMenuWindow CancelChangingDefaultPorts()
{
CancelDefaultPorts.Click();
RetryHelper.EventuallyAction(() => CancelDefaultPorts.Click());
return this;
}
private int GenerateUniqueRandomPort()
{
return random.Next(MinPort, MaxPort +1);
return random.Next(MinPort, MaxPort + 1);
}
public SettingsMenuWindow ChangeDefaultPorts()
{
ChangeDefaultPortsButton.Click();
RetryHelper.EventuallyAction(() => ChangeDefaultPortsButton.Click());
Thread.Sleep(2000);
ImapPort.Click();
RetryHelper.EventuallyAction(() => ImapPort.Click());
int imapPort = GenerateUniqueRandomPort();
int smtpPort;
@ -226,7 +227,8 @@ namespace ProtonMailBridge.UI.Tests.Windows
public SettingsMenuWindow SwitchBackToDefaultPorts()
{
ChangeDefaultPortsButton.Click();
RetryHelper.EventuallyAction(() => ChangeDefaultPortsButton.Click());
Thread.Sleep(2000);
ImapPort.Click();
ImapPort.Patterns.Value.Pattern.SetValue("");
@ -241,17 +243,18 @@ namespace ProtonMailBridge.UI.Tests.Windows
public SettingsMenuWindow OpenChangeConnectionMode()
{
ChangeConnectionModeButton.Click();
RetryHelper.EventuallyAction(() => ChangeConnectionModeButton.Click());
return this;
}
public SettingsMenuWindow CancelChangeConnectionMode()
{
CancelChangeConnectionModeButton.Click();
RetryHelper.EventuallyAction(() => CancelChangeConnectionModeButton.Click());
return this;
}
public SettingsMenuWindow ChangeConnectionMode()
{
ImapSslMode.Click();
RetryHelper.EventuallyAction(() => ImapSslMode.Click());
SmtpSslMode.Click();
Thread.Sleep(2000);
SaveChangedConnectionMode.Click();
@ -259,7 +262,8 @@ namespace ProtonMailBridge.UI.Tests.Windows
}
public SettingsMenuWindow SwitchBackToDefaultConnectionMode()
{
ImapStarttlsMode.Click();
RetryHelper.EventuallyAction(() => ImapStarttlsMode.Click());
SmtpStarttlsMode.Click();
Thread.Sleep(2000);
SaveChangedConnectionMode.Click();
@ -268,7 +272,7 @@ namespace ProtonMailBridge.UI.Tests.Windows
public SettingsMenuWindow ConfigureLocalCache()
{
ConfigureLocalCacheButton.Click();
RetryHelper.EventuallyAction(() => ConfigureLocalCacheButton.Click());
return this;
}
public SettingsMenuWindow CancelToConfigureLocalCache()
@ -319,14 +323,15 @@ namespace ProtonMailBridge.UI.Tests.Windows
public SettingsMenuWindow ChangeAndSwitchBackLocalCacheLocation()
{
string? userProfilePath = Environment.GetEnvironmentVariable("USERPROFILE");
ChangeLocalCacheLocationButton.Click();
RetryHelper.EventuallyAction(() => ChangeLocalCacheLocationButton.Click());
Thread.Sleep(2000);
FocusOnSelectCacheLocationWindow();
ClickNewFolder.Click();
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(2000));
Keyboard.TypeVirtualKeyCode(0x0D);
AutomationElement pane = Window.FindFirstDescendant(cf => cf.ByControlType(ControlType.Pane));
AutomationElement pane2 = pane.FindFirstDescendant(cf => cf.ByControlType(ControlType.Pane).And(cf.ByName("Shell Folder View")));
AutomationElement pane2 = pane.FindFirstDescendant(cf => cf.ByControlType(ControlType.Pane).And(cf.ByName("Shell Folder View")));
AutomationElement list = pane2.FindFirstDescendant(cf => cf.ByControlType(ControlType.List).And(cf.ByName("Items View")));
AutomationElement listItem = list.FindFirstDescendant(cf => cf.ByControlType(ControlType.ListItem).And(cf.ByName("New folder")));
TextBox folderName = listItem.FindFirstDescendant(cf => cf.ByControlType(ControlType.Edit)).AsTextBox();
@ -409,7 +414,8 @@ namespace ProtonMailBridge.UI.Tests.Windows
}
public SettingsMenuWindow ExportAssertDeleteTLSCertificates()
{
ExportTLSCertificatesButton.Click();
RetryHelper.EventuallyAction(() => ExportTLSCertificatesButton.Click());
Thread.Sleep(2000);
ClickNewFolder.Click();
Wait.UntilInputIsProcessed(TimeSpan.FromMilliseconds(2000));
@ -472,7 +478,8 @@ namespace ProtonMailBridge.UI.Tests.Windows
}
public SettingsMenuWindow VerifyRepairRestartsSync()
{
RepairBridgeButton.Click();
RetryHelper.EventuallyAction(() => RepairBridgeButton.Click());
RepairButtonInPopUp.Click();
bool syncRestarted = WaitForCondition(() =>
{
@ -509,7 +516,7 @@ namespace ProtonMailBridge.UI.Tests.Windows
public SettingsMenuWindow VerifyResetAndRestartBridge()
{
ResetButton.Click();
RetryHelper.EventuallyAction(() => ResetButton.Click());
ResetAndRestartButtonInPopUp.Click();
Thread.Sleep(5000);
LaunchApp();