Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Fix flaky tests (#269)

Leendert de Borsta267d94b3ec8
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/CodeLockoutTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/CodeLockoutTests.cs
index ffd3a6dbc..971739b27 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/CodeLockoutTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/CodeLockoutTests.cs
@@ -28,13 +28,18 @@ public class CodeLockoutTests : TwoFactorAuthBase
await EnableTwoFactor();
await Logout();
- // Attempt to log in with test credentials.
- var emailField = Page.Locator("input[id='email']");
- var passwordField = Page.Locator("input[id='password']");
+ // Attempt to log in again with test credentials.
+ await WaitForUrlAsync("user/login", "Your username");
+
+ // Wait for the page to fully load.
+ await Task.Delay(100);
+
+ var emailField = await WaitForAndGetElement("input[id='email']");
+ var passwordField = await WaitForAndGetElement("input[id='password']");
await emailField.FillAsync(TestUserUsername);
await passwordField.FillAsync(TestUserPassword);
- var loginButton = Page.Locator("button[type='submit']");
+ var loginButton = await WaitForAndGetElement("button[type='submit']");
await loginButton.ClickAsync();
// Check if we get a 2FA code prompt by checking for text "Authenticator code".
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/RecoveryLockoutTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/RecoveryLockoutTests.cs
index 3e16197ad..03effef0a 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/RecoveryLockoutTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/RecoveryLockoutTests.cs
@@ -29,13 +29,18 @@ public class RecoveryLockoutTests : TwoFactorAuthBase
await Logout();
- // Attempt to log in with test credentials.
- var emailField = Page.Locator("input[id='email']");
- var passwordField = Page.Locator("input[id='password']");
+ // Attempt to log in again with test credentials.
+ await WaitForUrlAsync("user/login", "Your username");
+
+ // Wait for the page to fully load.
+ await Task.Delay(100);
+
+ var emailField = await WaitForAndGetElement("input[id='email']");
+ var passwordField = await WaitForAndGetElement("input[id='password']");
await emailField.FillAsync(TestUserUsername);
await passwordField.FillAsync(TestUserPassword);
- var loginButton = Page.Locator("button[type='submit']");
+ var loginButton = await WaitForAndGetElement("button[type='submit']");
await loginButton.ClickAsync();
// Check if we get a 2FA code prompt by checking for text "Authenticator code".
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/TwoFactorAuthTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/TwoFactorAuthTests.cs
index 4a49727ba..d08f09448 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/TwoFactorAuthTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/TwoFactorAuthTests.cs
@@ -39,13 +39,19 @@ public class TwoFactorAuthTests : TwoFactorAuthBase
await Logout();
- // Attempt to login again with test credentials.
- var emailField = Page.Locator("input[id='email']");
- var passwordField = Page.Locator("input[id='password']");
+ // Attempt to log in again with test credentials.
+ await WaitForUrlAsync("user/login", "Your username");
+
+ // Wait for the page to fully load.
+ await Task.Delay(100);
+
+ var emailField = await WaitForAndGetElement("input[id='email']");
+ var passwordField = await WaitForAndGetElement("input[id='password']");
+
await emailField.FillAsync(TestUserUsername);
await passwordField.FillAsync(TestUserPassword);
- var loginButton = Page.Locator("button[type='submit']");
+ var loginButton = await WaitForAndGetElement("button[type='submit']");
await loginButton.ClickAsync();
// Check if we get a 2FA code prompt by checking for text "Authenticator code".
@@ -53,7 +59,7 @@ public class TwoFactorAuthTests : TwoFactorAuthBase
Assert.That(prompt, Does.Contain("Authenticator code"), "No 2FA code prompt displayed.");
// Fill in the 2FA code and submit the form.
- var totpField = Page.Locator("input[id='two-factor-code']");
+ var totpField = await WaitForAndGetElement("input[id='two-factor-code']");
await totpField.FillAsync(totpCode);
var submitButton = Page.Locator("button[type='submit']");
@@ -75,13 +81,18 @@ public class TwoFactorAuthTests : TwoFactorAuthBase
await Logout();
- // Attempt to log in with test credentials.
- var emailField = Page.Locator("input[id='email']");
- var passwordField = Page.Locator("input[id='password']");
+ // Attempt to log in again with test credentials.
+ await WaitForUrlAsync("user/login", "Your username");
+
+ // Wait for the page to fully load.
+ await Task.Delay(100);
+
+ var emailField = await WaitForAndGetElement("input[id='email']");
+ var passwordField = await WaitForAndGetElement("input[id='password']");
await emailField.FillAsync(TestUserUsername);
await passwordField.FillAsync(TestUserPassword);
- var loginButton = Page.Locator("button[type='submit']");
+ var loginButton = await WaitForAndGetElement("button[type='submit']");
await loginButton.ClickAsync();
// Check if we get a 2FA code prompt by checking for text "Authenticator code".