Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add register warning test (#74)
Leendert de Borstf5e02fb784ae
diff --git a/src/AliasVault.WebApp/Auth/Pages/Register.razor b/src/AliasVault.WebApp/Auth/Pages/Register.razorindex c6428b88d..be9a371bf 100644--- a/src/AliasVault.WebApp/Auth/Pages/Register.razor+++ b/src/AliasVault.WebApp/Auth/Pages/Register.razor@@ -77,7 +77,10 @@if (!result.IsSuccessStatusCode){- LoginBase.ParseResponse(responseContent);+ foreach (var error in LoginBase.ParseResponse(responseContent))+ {+ _serverValidationErrors.AddError(error);+ }StateHasChanged();return;}diff --git a/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs b/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.csindex 52417af2e..303796ad2 100644--- a/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs+++ b/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs@@ -241,7 +241,7 @@ public class PlaywrightTestawait registerButton.ClickAsync();await WaitForURLAsync("**/user/register");- // Try to login with test credentials.+ // Try to register an account with the generated test credentials.var emailField = Page.Locator("input[id='email']");var passwordField = Page.Locator("input[id='password']");var password2Field = Page.Locator("input[id='password2']");@@ -255,7 +255,6 @@ public class PlaywrightTest// Check if we get redirected when clicking on the register button.var submitButton = Page.Locator("button[type='submit']");- Console.WriteLine(submitButton);await submitButton.ClickAsync();// Check if we get redirected to the root URL after registration which means we are logged in.diff --git a/src/Tests/AliasVault.E2ETests/Tests/AuthTests.cs b/src/Tests/AliasVault.E2ETests/Tests/AuthTests.csindex 97968bdd6..8f5a3a267 100644--- a/src/Tests/AliasVault.E2ETests/Tests/AuthTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/AuthTests.cs@@ -31,6 +31,45 @@ public class AuthTests : PlaywrightTestawait Login();}+ /// <summary>+ /// Test if registering an account with the same email address as an existing account shows a warning.+ /// </summary>+ /// <returns>Async task.</returns>+ [Test]+ public async Task RegisterFormWarning()+ {+ // Logout.+ await NavigateUsingBlazorRouter("user/logout");+ await WaitForURLAsync("**/user/logout", "AliasVault");++ // Wait and check if we get redirected to /user/login.+ await WaitForURLAsync("**/user/login");++ // Try to register a new account.+ var registerButton = Page.Locator("a[href='/user/register']");+ await registerButton.ClickAsync();+ await WaitForURLAsync("**/user/register");++ // Register account with same test credentials as used in the initial registration bootstrap method.+ var emailField = Page.Locator("input[id='email']");+ var passwordField = Page.Locator("input[id='password']");+ var password2Field = Page.Locator("input[id='password2']");+ await emailField.FillAsync(TestUserEmail);+ await passwordField.FillAsync(TestUserPassword);+ await password2Field.FillAsync(TestUserPassword);++ // Check the terms of service checkbox+ var termsCheckbox = Page.Locator("input[id='terms']");+ await termsCheckbox.CheckAsync();++ // Check if we get a visible warning when trying to register.+ var submitButton = Page.Locator("button[type='submit']");+ await submitButton.ClickAsync();++ var warning = await Page.TextContentAsync("div[role='alert']");+ Assert.That(warning, Does.Contain("is already taken."), "No visible warning when registering with existing email address.");+ }+/// <summary>/// Test if logging in works./// </summary>