Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add E2E test for new user setup account creation flow (#306)
Leendert de Borstd0b680c20ce1
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/CodeLockoutTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/CodeLockoutTests.csindex 035680f25..1d9d309fe 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/CodeLockoutTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard3/CodeLockoutTests.cs@@ -27,6 +27,7 @@ public class CodeLockoutTests : TwoFactorAuthBaseawait DisableTwoFactorIfEnabled();await EnableTwoFactor();await Logout();+ await NavigateToLogin();// Attempt to log in again with test credentials.await NavigateUsingBlazorRouter("user/login");diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard4/AuthTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard4/AuthTests.csindex 37743ce03..2b0bc15a8 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard4/AuthTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard4/AuthTests.cs@@ -15,7 +15,6 @@ using Microsoft.EntityFrameworkCore;/// </summary>[Parallelizable(ParallelScope.Self)][Category("ClientTests")]-[TestFixture]public class AuthTests : ClientPlaywrightTest{diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard4/UserSetupTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard4/UserSetupTests.csnew file mode 100644index 000000000..8929ed838--- /dev/null+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard4/UserSetupTests.cs@@ -0,0 +1,133 @@+//-----------------------------------------------------------------------+// <copyright file="UserSetupTests.cs" company="lanedirt">+// Copyright (c) lanedirt. All rights reserved.+// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.+// </copyright>+//-----------------------------------------------------------------------++namespace AliasVault.E2ETests.Tests.Client.Shard4;++/// <summary>+/// End-to-end tests for the registration process via the wizard / tutorial interface (/user/setup).+/// </summary>+[Parallelizable(ParallelScope.Self)]+[Category("ClientTests")]+[TestFixture]+public class UserSetupTests : ClientPlaywrightTest+{+ /// <summary>+ /// Test if registering an account through the tutorial interface works.+ /// </summary>+ /// <returns>Async task.</returns>+ [Test]+ [Order(1)]+ public async Task UserSetupProcessTest()+ {+ // Logout.+ await Logout();+ await Page.GotoAsync(AppBaseUrl);+ await WaitForUrlAsync("user/start", "Create new vault");++ // Click the "Create new vault" anchor tag.+ var createVaultButton = await WaitForAndGetElement("a:has-text('Create new vault')");+ await createVaultButton.ClickAsync();++ // Wait for the setup page to load.+ await WaitForUrlAsync("user/setup", "Welcome to AliasVault");++ // Press the continue button.+ var continueButton = await WaitForAndGetElement("button:has-text('Continue')");+ await continueButton.ClickAsync();++ // Wait for the terms and conditions to load.+ await WaitForUrlAsync("user/setup", "Terms and Conditions");++ // Accept the terms and conditions.+ var acceptTermsCheckbox = await WaitForAndGetElement("input[id='agreeTerms']");+ await acceptTermsCheckbox.CheckAsync();++ // Wait for the continue button to be enabled.+ await Task.Delay(100);++ // Press the continue button.+ continueButton = await WaitForAndGetElement("button:has-text('Continue')");+ await continueButton.ClickAsync();++ // Wait for the username step to load.+ await WaitForUrlAsync("user/setup", "Username");+ var usernameField = await WaitForAndGetElement("input[id='username']");+ await usernameField.FillAsync(TestUserUsername + "1"); // Add a suffix to the username to make it unique.++ // Wait for the continue button to be enabled.+ await Task.Delay(100);++ // Press the continue button.+ continueButton = await WaitForAndGetElement("button:has-text('Continue')");+ await continueButton.ClickAsync();++ // Wait for the password step to load.+ await WaitForUrlAsync("user/setup", "Set Password");+ var passwordField = await WaitForAndGetElement("input[id='password']");+ await passwordField.FillAsync(TestUserPassword);+ var confirmPasswordField = await WaitForAndGetElement("input[id='confirmPassword']");+ await confirmPasswordField.FillAsync(TestUserPassword);++ // Wait for the create account button to show up and be enabled.+ await Task.Delay(100);++ // Press the create account button.+ continueButton = await WaitForAndGetElement("button:has-text('Create Account')");+ await continueButton.ClickAsync();++ // Verify that we end up on the welcome page which confirms the account has been successfully created.+ await WaitForUrlAsync("welcome**", "Getting Started");+ }++ /// <summary>+ /// Test if the "Username is already in use" error appears when trying to register with an existing username.+ /// </summary>+ /// <returns>Async task.</returns>+ [Test]+ [Order(2)]+ public async Task UserSetupUsernameExistsTest()+ {+ // Logout.+ await Logout();+ await Page.GotoAsync(AppBaseUrl);+ await WaitForUrlAsync("user/start", "Create new vault");++ // Click the "Create new vault" anchor tag.+ var createVaultButton = await WaitForAndGetElement("a:has-text('Create new vault')");+ await createVaultButton.ClickAsync();++ // Wait for the setup page to load.+ await WaitForUrlAsync("user/setup", "Welcome to AliasVault");++ // Press the continue button.+ var continueButton = await WaitForAndGetElement("button:has-text('Continue')");+ await continueButton.ClickAsync();++ // Wait for the terms and conditions to load.+ await WaitForUrlAsync("user/setup", "Terms and Conditions");++ // Accept the terms and conditions.+ var acceptTermsCheckbox = await WaitForAndGetElement("input[id='agreeTerms']");+ await acceptTermsCheckbox.CheckAsync();++ // Wait for the continue button to be enabled.+ await Task.Delay(100);++ // Press the continue button.+ continueButton = await WaitForAndGetElement("button:has-text('Continue')");+ await continueButton.ClickAsync();++ // Wait for the username step to load.+ await WaitForUrlAsync("user/setup", "Username");+ var usernameField = await WaitForAndGetElement("input[id='username']");+ await usernameField.FillAsync(TestUserUsername); // Use the existing username without appending "1"++ // Check if the "Username is already in use" error message appears+ var errorMessage = await WaitForAndGetElement("text='Username is already in use.'");+ Assert.That(errorMessage, Is.Not.Null, "The 'Username is already in use' error message should appear.");+ }+}