Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Add second merge test (#186)
Leendert de Borst86eacb0ad86c
diff --git a/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs b/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.csindex a70799ca3..aefc80cbf 100644--- a/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs+++ b/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs@@ -183,13 +183,44 @@ public class ClientPlaywrightTest : PlaywrightTestvar submitButton = Page.Locator("text=Save Credentials").First;await submitButton.ClickAsync();- await WaitForUrlAsync("credentials/**", "View credentials entry");+ await WaitForUrlAsync("credentials/**", "Credentials created successfully");// Check if the credential was createdvar pageContent = await Page.TextContentAsync("body");Assert.That(pageContent, Does.Contain("View credentials entry"), "Credential not created.");}+ /// <summary>+ /// Update existing credential entry.+ /// </summary>+ /// <param name="credentialName">Name of the credential to update.</param>+ /// <param name="formValues">Dictionary with html element ids and values to input as field value.</param>+ /// <returns>Async task.</returns>+ protected async Task UpdateCredentialEntry(string credentialName, Dictionary<string, string>? formValues = null)+ {+ await NavigateUsingBlazorRouter("credentials");+ await WaitForUrlAsync("credentials", "Find all of your credentials");+ await Page.ClickAsync("text=" + credentialName);++ // Wait for the credential details page to load.+ await WaitForUrlAsync("credentials/**", "Edit credentials entry");+ await Page.ClickAsync("text=Edit credentials entry");++ // Wait for the edit credential page to load.+ await WaitForUrlAsync("credentials/**/edit", "Edit the existing credentials");++ // Fill all input fields with specified values and remaining empty fields with random data.+ await InputHelper.FillInputFields(formValues);++ var submitButton = Page.Locator("text=Save Credentials").First;+ await submitButton.ClickAsync();+ await WaitForUrlAsync("credentials/**", "Credentials updated successfully");++ // Check if the credential was created+ var pageContent = await Page.TextContentAsync("body");+ Assert.That(pageContent, Does.Contain("Credentials updated successfully"), "Credential not updated successfully.");+ }+/// <summary>/// Login (again) as current user./// </summary>diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/DbSyncTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/DbSyncTests.csindex 800230cd9..2c62a7993 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/DbSyncTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/DbSyncTests.cs@@ -64,6 +64,66 @@ public class DbSyncTests : ClientPlaywrightTest}}+ /// <summary>+ /// Test that client side merge works correctly when two or more conflicting vault versions have been detected.+ /// </summary>+ /// <returns>Async task.</returns>+ [Test]+ [Order(2)]+ public async Task DbSyncClientMergeCredentialPropertiesTest()+ {+ var baselineVault = await CreateBaselineVault(async () =>+ {+ ApiTimeProvider.AdvanceBy(TimeSpan.FromSeconds(1));+ await CreateCredentialEntry(new Dictionary<string, string> { { "service-name", "TestBaseline1" }, { "username", "user1" }, { "email", "email1" } });+ ApiTimeProvider.AdvanceBy(TimeSpan.FromSeconds(1));+ await CreateCredentialEntry(new Dictionary<string, string> { { "service-name", "TestBaseline2" }, { "username", "user2" }, { "email", "email2" } });+ ApiTimeProvider.AdvanceBy(TimeSpan.FromSeconds(1));+ await CreateCredentialEntry(new Dictionary<string, string> { { "service-name", "TestBaseline3" }, { "username", "user3" }, { "email", "email3" } });+ });++ var client1Vault = await SimulateClient(baselineVault, async () =>+ {+ await UpdateCredentialEntry("TestBaseline2", new Dictionary<string, string> { { "service-name", "TestBaseMutate2" }, { "username", "usermutate2" }, { "email", "emailmutate2" } });+ });++ await SimulateClient(baselineVault, async () =>+ {+ // Re-add client1 vault to simulate conflict when this second client updates the same vault.+ client1Vault.Id = Guid.NewGuid();+ ApiDbContext.Vaults.Add(client1Vault);+ await ApiDbContext.SaveChangesAsync();++ await UpdateCredentialEntry("TestBaseline3", new Dictionary<string, string> { { "service-name", "TestBaseMutate3" }, { "username", "usermutate3" }, { "email", "emailmutate3" } });+ });++ // Assert that the two conflicting vaults have been merged and all mutated service names are found.+ Dictionary<string, List<string>> expectedStrings = new()+ {+ { "TestBaseMutate2", new List<string> { "usermutate2", "[email protected]" } },+ { "TestBaseMutate3", new List<string> { "usermutate3", "[email protected]" } },+ };++ foreach (var serviceName in expectedStrings)+ {+ // Navigate to the credential details page.+ await NavigateUsingBlazorRouter("credentials");+ await WaitForUrlAsync("credentials", "Find all of your credentials");++ await Page.ClickAsync($"text={serviceName.Key}");+ await WaitForUrlAsync($"credentials/**", "View credentials entry");+ foreach (var property in serviceName.Value)+ {+ // Check if any input on the page has the expected value+ var inputWithValue = await Page.EvaluateAsync<bool>($@"+ Array.from(document.querySelectorAll('input, textarea'))+ .some(el => el.value === '{property}')");++ Assert.That(inputWithValue, Is.True, $"No input found with value '{property}' in {serviceName.Key} credential page after merge.");+ }+ }+ }+/// <summary>/// Create a baseline vault./// </summary>