Skip to content

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

Add E2E test for client general settings page (#145)

Leendert de Borstcc64f5c8776c
diff --git a/src/AliasVault.Client/Services/Database/DbService.cs b/src/AliasVault.Client/Services/Database/DbService.cs
index 3c95ae5d2..8414f25cb 100644
--- a/src/AliasVault.Client/Services/Database/DbService.cs
+++ b/src/AliasVault.Client/Services/Database/DbService.cs
@@ -188,6 +188,7 @@ public class DbService : IDisposable
{
await _dbContext.Database.MigrateAsync();
_isSuccessfullyInitialized = true;
+ await _settingsService.InitializeAsync(this);
_state.UpdateState(DbServiceState.DatabaseStatus.Ready);
}
catch (Exception ex)
@@ -432,10 +433,7 @@ public class DbService : IDisposable
}
_isSuccessfullyInitialized = true;
-
- // Initialize child settings service if it's not already.
await _settingsService.InitializeAsync(this);
-
_state.UpdateState(DbServiceState.DatabaseStatus.Ready);
return true;
}
diff --git a/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs b/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs
index aa70caaf8..2408f4fa9 100644
--- a/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs
+++ b/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs
@@ -89,7 +89,7 @@ public class ClientPlaywrightTest : PlaywrightTest
await SetupPlaywrightBrowserAndContext();
// Intercept Blazor WASM app requests to override appsettings.json
- string[] privateEmailDomains = ["example.tld"];
+ string[] privateEmailDomains = ["example.tld", "example2.tld"];
await Context.RouteAsync(
"**/appsettings.json",
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/CredentialTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/CredentialTest.cs
similarity index 95%
rename from src/Tests/AliasVault.E2ETests/Tests/Client/CredentialTests.cs
rename to src/Tests/AliasVault.E2ETests/Tests/Client/CredentialTest.cs
index 2337b22f8..6a3f70285 100644
--- a/src/Tests/AliasVault.E2ETests/Tests/Client/CredentialTests.cs
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/CredentialTest.cs
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------
-// <copyright file="CredentialTests.cs" company="lanedirt">
+// <copyright file="CredentialTest.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>
@@ -13,10 +13,8 @@ namespace AliasVault.E2ETests.Tests.Client;
[TestFixture]
[Category("ClientTests")]
[Parallelizable(ParallelScope.Self)]
-public class CredentialTests : ClientPlaywrightTest
+public class CredentialTest : ClientPlaywrightTest
{
- private static readonly Random Random = new();
-
/// <summary>
/// Test if the credential listing index page works.
/// </summary>
diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/GeneralSettingsTest.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/GeneralSettingsTest.cs
new file mode 100644
index 000000000..fd6481396
--- /dev/null
+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/GeneralSettingsTest.cs
@@ -0,0 +1,43 @@
+//-----------------------------------------------------------------------
+// <copyright file="GeneralSettingsTest.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;
+
+/// <summary>
+/// End-to-end tests for general settings.
+/// </summary>
+[TestFixture]
+[Category("ClientTests")]
+[Parallelizable(ParallelScope.Self)]
+public class GeneralSettingsTest : ClientPlaywrightTest
+{
+ /// <summary>
+ /// Test if mutating the default email domain works.
+ /// </summary>
+ /// <returns>Async task.</returns>
+ [Test]
+ public async Task MutateDefaultEmailDomainTest()
+ {
+ await NavigateUsingBlazorRouter("settings/general");
+ await WaitForUrlAsync("settings/general", "General settings");
+
+ // Check if the expected content is present.
+ var pageContent = await Page.TextContentAsync("body");
+ Assert.That(pageContent, Does.Contain("Default Email Domain"), "No general settings option visible.");
+
+ // Set the default email domain to "example2.tld".
+ var defaultEmailDomainField = Page.Locator("select[id='defaultEmailDomain']");
+ await defaultEmailDomainField.SelectOptionAsync(new[] { "example2.tld" });
+
+ // Go to new credential create page and assert that the default email domain is visible on the page.
+ await NavigateUsingBlazorRouter("add-credentials");
+ await WaitForUrlAsync("add-credentials", "Add credentials");
+
+ var defaultEmailDomainText = await Page.TextContentAsync("body");
+ Assert.That(defaultEmailDomainText, Does.Contain("example2.tld"), "Default email domain not visible on add credentials page.");
+ }
+}