Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Update DbUpgradeTest after unlock page change (#200)
Leendert de Borst3e7826607f36
diff --git a/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs b/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.csindex afe8488d8..3dd27bec7 100644--- a/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs+++ b/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs@@ -190,6 +190,28 @@ public class ClientPlaywrightTest : PlaywrightTestAssert.That(pageContent, Does.Contain("View credentials entry"), "Credential not created.");}+ /// <summary>+ /// Login (again) as current user.+ /// </summary>+ /// <returns>Async task.</returns>+ protected async Task Login()+ {+ await NavigateUsingBlazorRouter("/");++ // 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 WaitForUrlAsync("user/login");++ // Try to log in with test credentials.+ var emailField = Page.Locator("input[id='email']");+ var passwordField = Page.Locator("input[id='password']");+ await emailField.FillAsync(TestUserUsername);+ await passwordField.FillAsync(TestUserPassword);++ var loginButton = Page.Locator("button[type='submit']");+ await loginButton.ClickAsync();+ }+/// <summary>/// Logout the current user and register a new account./// </summary>diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/AuthPasswordChangeTest.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/AuthPasswordChangeTest.csindex 1e50d59fc..d299ef5c1 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/AuthPasswordChangeTest.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/AuthPasswordChangeTest.cs@@ -84,27 +84,4 @@ public class AuthPasswordChangeTest : ClientPlaywrightTestpageContent = await Page.TextContentAsync("body");Assert.That(pageContent, Does.Contain(serviceNameBefore), "Created credential service name does not appear on login page after hard page reload. Check if the database is correctly persisted and then loaded from the server.");}-- /// <summary>- /// Login (again).- /// </summary>- /// <returns>Async task.</returns>- private async Task Login()- {- await NavigateUsingBlazorRouter("/");-- // 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 WaitForUrlAsync("user/login");-- // Try to login with test credentials.- var emailField = Page.Locator("input[id='email']");- var passwordField = Page.Locator("input[id='password']");- await emailField.FillAsync(TestUserUsername);- await passwordField.FillAsync(TestUserPassword);-- // Check if we get redirected when clicking on the login button.- var loginButton = Page.Locator("button[type='submit']");- await loginButton.ClickAsync();- }}diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.csindex 876c80ae8..d64a3d285 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/AuthTests.cs@@ -49,6 +49,12 @@ public class AuthTests : ClientPlaywrightTestawait Login();+ await WaitForUrlAsync(AppBaseUrl, "Welcome to AliasVault");++ // Check if the login was successful by verifying content.+ var pageContent = await Page.TextContentAsync("body");+ Assert.That(pageContent, Does.Contain("Welcome to AliasVault"), "No index content after logging in.");+// Check if login has created an auth log entry.var authLogEntry = await ApiDbContext.AuthLogs.FirstOrDefaultAsync(x => x.Username == TestUserUsername && x.EventType == AuthEventType.Login);Assert.That(authLogEntry, Is.Not.Null, "Auth log entry not found in database after login.");@@ -136,32 +142,4 @@ public class AuthTests : ClientPlaywrightTestvar pageContent = await Page.TextContentAsync("body");Assert.That(pageContent, Does.Contain("locked out"), "No account lockout message.");}-- /// <summary>- /// Test if logging in works.- /// </summary>- /// <returns>Async task.</returns>- private async Task Login()- {- await NavigateUsingBlazorRouter("/");-- // 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 WaitForUrlAsync("user/login");-- // Try to login with test credentials.- var emailField = Page.Locator("input[id='email']");- var passwordField = Page.Locator("input[id='password']");- await emailField.FillAsync(TestUserUsername);- await passwordField.FillAsync(TestUserPassword);-- // Check if we get redirected when clicking on the login button.- var loginButton = Page.Locator("button[type='submit']");- await loginButton.ClickAsync();- await WaitForUrlAsync(AppBaseUrl, "Welcome to AliasVault");-- // Check if the login was successful by verifying content.- var pageContent = await Page.TextContentAsync("body");- Assert.That(pageContent, Does.Contain("Welcome to AliasVault"), "No index content after logging in.");- }}diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/DbUpgradeTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/DbUpgradeTests.csindex c2fef6778..891b86a59 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/DbUpgradeTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/DbUpgradeTests.cs@@ -56,9 +56,13 @@ public class DbUpgradeTests : ClientPlaywrightTest});await ApiDbContext.SaveChangesAsync();- // Refresh page so the database gets dropped then unlock the vault again which will- // refetch the newly inserted database from the server.- await RefreshPageAndUnlockVault();+ // Logout.+ await NavigateUsingBlazorRouter("user/logout");+ await WaitForUrlAsync("user/logout", "AliasVault");++ // Wait and check if we get redirected to /user/login.+ await WaitForUrlAsync("user/login");+ await Login();// Wait for two things: either the homepage to show with credentials OR the// vault upgrade step to show.@@ -67,9 +71,6 @@ public class DbUpgradeTests : ClientPlaywrightTestvar submitButton = Page.Locator("text=Start upgrade process").First;await submitButton.ClickAsync();- // Wait for welcome page to show up.- await WaitForUrlAsync(string.Empty, "Welcome to AliasVault");-// Soft navigate to credentials.await NavigateUsingBlazorRouter("credentials");await WaitForUrlAsync(string.Empty, "Test credential 1");