Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Code style refactor (#11)
Leendert de Borst9c8fd9e498be
diff --git a/src/Tests/AliasVault.E2ETests/AliasTests.cs b/src/Tests/AliasVault.E2ETests/AliasTests.csindex 233ea7439..a911a953c 100644--- a/src/Tests/AliasVault.E2ETests/AliasTests.cs+++ b/src/Tests/AliasVault.E2ETests/AliasTests.cs@@ -56,7 +56,7 @@ public class AliasTests : PlaywrightTestpublic async Task AliasListingCorrect(){await Page.GotoAsync(AppBaseUrl + "aliases");- await Page.WaitForURLAsync("**/aliases", new PageWaitForURLOptions() { Timeout = 2000 });+ await WaitForURLAsync("**/aliases");// Wait for the content to load.await Page.WaitForSelectorAsync("text=AliasVault");@@ -74,7 +74,7 @@ public class AliasTests : PlaywrightTestpublic async Task CreateAlias(){await Page.GotoAsync(AppBaseUrl + "add-alias");- await Page.WaitForURLAsync("**/add-alias", new PageWaitForURLOptions() { Timeout = 2000 });+ await WaitForURLAsync("**/add-alias");// Wait for the content to load.await Page.WaitForSelectorAsync("text=AliasVault");@@ -89,11 +89,7 @@ public class AliasTests : PlaywrightTest// Press submit button with text "Create Alias"var submitButton = Page.Locator("text=Save Alias").First;await submitButton.ClickAsync();- await Page.WaitForURLAsync("**/alias/**", new PageWaitForURLOptions() { Timeout = 2000 });-- // Check if the redirection occurred- var currentUrl = Page.Url;- Assert.That(currentUrl, Does.Contain(AppBaseUrl + "alias/"));+ await WaitForURLAsync("**/alias/**");// Wait for the content to load.await Page.WaitForSelectorAsync("text=Login credentials");diff --git a/src/Tests/AliasVault.E2ETests/AuthTests.cs b/src/Tests/AliasVault.E2ETests/AuthTests.csindex 2957a2c5f..240d8c3de 100644--- a/src/Tests/AliasVault.E2ETests/AuthTests.cs+++ b/src/Tests/AliasVault.E2ETests/AuthTests.cs@@ -46,7 +46,7 @@ public class AuthTests : PlaywrightTest// Check that we are on the login page after navigating to the base URL.// We are expecting to not be authenticated and thus to be redirected to the login page.- await Page.WaitForURLAsync("**/user/login", new PageWaitForURLOptions() { Timeout = 2000 });+ await WaitForURLAsync("**/user/login");// Try to login with test credentials.var emailField = Page.Locator("input[id='email']");@@ -57,7 +57,7 @@ public class AuthTests : PlaywrightTest// Check if we get redirected when clicking on the login button.var loginButton = Page.Locator("button[type='submit']");await loginButton.ClickAsync();- await Page.WaitForURLAsync(AppBaseUrl, new PageWaitForURLOptions() { Timeout = 2000 });+ await WaitForURLAsync(AppBaseUrl);// Check if the login was successful by verifying content.var pageContent = await Page.TextContentAsync("body");diff --git a/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs b/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.csindex 781ab7378..37fc2bdb4 100644--- a/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs+++ b/src/Tests/AliasVault.E2ETests/Common/PlaywrightTest.cs@@ -117,6 +117,16 @@ public class PlaywrightTest_blazorWasmAppManager.StopBlazorWasm();}+ /// <summary>+ /// Wait for the specified URL to be loaded with a default timeout.+ /// </summary>+ /// <param name="url">The URL to wait for. This may also contains wildcard such as "**/user/login".</param>+ /// <returns>Async task.</returns>+ protected async Task WaitForURLAsync(string url)+ {+ await Page.WaitForURLAsync(url, new PageWaitForURLOptions() { Timeout = TestDefaults.DefaultTimeout });+ }+/// <summary>/// Register a new random account./// </summary>@@ -129,12 +139,12 @@ public class PlaywrightTest// Check that we get redirected to /user/login when accessing the root URL and not authenticated.await Page.GotoAsync(AppBaseUrl);- await Page.WaitForURLAsync("**/user/login", new PageWaitForURLOptions() { Timeout = 2000 });+ await WaitForURLAsync("**/user/login");// Try to register a new account.var registerButton = Page.Locator("a[href='/user/register']");await registerButton.ClickAsync();- await Page.WaitForURLAsync("**/user/register", new PageWaitForURLOptions() { Timeout = 2000 });+ await WaitForURLAsync("**/user/register");// Try to login with test credentials.var emailField = Page.Locator("input[id='email']");@@ -153,6 +163,6 @@ public class PlaywrightTestawait submitButton.ClickAsync();// Check if we get redirected to the root URL after registration which means we are logged in.- await Page.WaitForURLAsync(AppBaseUrl, new PageWaitForURLOptions() { Timeout = 5000 });+ await WaitForURLAsync(AppBaseUrl);}}diff --git a/src/Tests/AliasVault.E2ETests/Common/TestDefaults.cs b/src/Tests/AliasVault.E2ETests/Common/TestDefaults.csnew file mode 100644index 000000000..5bf285373--- /dev/null+++ b/src/Tests/AliasVault.E2ETests/Common/TestDefaults.cs@@ -0,0 +1,19 @@+//-----------------------------------------------------------------------+// <copyright file="TestDefaults.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.Common;++/// <summary>+/// Default values for tests.+/// </summary>+public static class TestDefaults+{+ /// <summary>+ /// Gets or sets default timeout while waiting for pages to load in milliseconds.+ /// </summary>+ public static int DefaultTimeout { get; set; } = 5000;+}