mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-03-03 14:28:14 -05:00
Add register warning test (#74)
This commit is contained in:
@@ -77,7 +77,10 @@
|
||||
|
||||
if (!result.IsSuccessStatusCode)
|
||||
{
|
||||
LoginBase.ParseResponse(responseContent);
|
||||
foreach (var error in LoginBase.ParseResponse(responseContent))
|
||||
{
|
||||
_serverValidationErrors.AddError(error);
|
||||
}
|
||||
StateHasChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ public class PlaywrightTest
|
||||
await 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.
|
||||
|
||||
@@ -31,6 +31,45 @@ public class AuthTests : PlaywrightTest
|
||||
await 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>
|
||||
|
||||
Reference in New Issue
Block a user