Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.
Added attachment test that reproduces issue (#287)
Leendert de Borst6d795c637056
diff --git a/src/AliasVault.Client/Main/Components/Widgets/CreateNewIdentityWidget.razor b/src/AliasVault.Client/Main/Components/Widgets/CreateNewIdentityWidget.razorindex 923539c22..e4e1735bb 100644--- a/src/AliasVault.Client/Main/Components/Widgets/CreateNewIdentityWidget.razor+++ b/src/AliasVault.Client/Main/Components/Widgets/CreateNewIdentityWidget.razor@@ -159,7 +159,7 @@}// No error, add success message.- GlobalNotificationService.AddSuccessMessage("Credentials created successfully.");+ GlobalNotificationService.AddSuccessMessage("Credential created successfully.");NavigationManager.NavigateTo("/credentials/" + id);diff --git a/src/AliasVault.Client/Main/Pages/Credentials/AddEdit.razor b/src/AliasVault.Client/Main/Pages/Credentials/AddEdit.razorindex efcb2592c..4ca752453 100644--- a/src/AliasVault.Client/Main/Pages/Credentials/AddEdit.razor+++ b/src/AliasVault.Client/Main/Pages/Credentials/AddEdit.razor@@ -335,11 +335,11 @@ else// No error, add success message.if (EditMode){- GlobalNotificationService.AddSuccessMessage("Credentials updated successfully.");+ GlobalNotificationService.AddSuccessMessage("Credential updated successfully.");}else{- GlobalNotificationService.AddSuccessMessage("Credentials created successfully.");+ GlobalNotificationService.AddSuccessMessage("Credential created successfully.");}NavigationManager.NavigateTo("/credentials/" + Id);diff --git a/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs b/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.csindex c6e50dcb5..0ecee2b25 100644--- a/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs+++ b/src/Tests/AliasVault.E2ETests/Common/ClientPlaywrightTest.cs@@ -202,7 +202,7 @@ public class ClientPlaywrightTest : PlaywrightTestvar submitButton = Page.Locator("text=Save Credentials").First;await submitButton.ClickAsync();- await WaitForUrlAsync("credentials/**", "Credentials created successfully");+ await WaitForUrlAsync("credentials/**", "Credential created successfully");// Check if the credential was createdvar pageContent = await Page.TextContentAsync("body");@@ -237,11 +237,11 @@ public class ClientPlaywrightTest : PlaywrightTestvar submitButton = Page.Locator("text=Save Credentials").First;await submitButton.ClickAsync();- await WaitForUrlAsync("credentials/**", "Credentials updated successfully");+ await WaitForUrlAsync("credentials/**", "Credential updated successfully");// Check if the credential was createdvar pageContent = await Page.TextContentAsync("body");- Assert.That(pageContent, Does.Contain("Credentials updated successfully"), "Credential not updated successfully.");+ Assert.That(pageContent, Does.Contain("Credential updated successfully"), "Credential not updated successfully.");}/// <summary>diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/CredentialTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/CredentialTests.csindex dd5ea367a..741a6fd41 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/CredentialTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard1/CredentialTests.cs@@ -116,7 +116,7 @@ public class CredentialTests : ClientPlaywrightTestawait WaitForUrlAsync("credentials/**", "Delete");pageContent = await Page.TextContentAsync("body");- Assert.That(pageContent, Does.Contain("Credentials updated"), "Credential update confirmation message not shown.");+ Assert.That(pageContent, Does.Contain("Credential updated"), "Credential update confirmation message not shown.");Assert.That(pageContent, Does.Contain(serviceNameAfter), "Credential not updated correctly.");}diff --git a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard5/AttachmentTests.cs b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard5/AttachmentTests.csindex a7c2ddf7d..243088a55 100644--- a/src/Tests/AliasVault.E2ETests/Tests/Client/Shard5/AttachmentTests.cs+++ b/src/Tests/AliasVault.E2ETests/Tests/Client/Shard5/AttachmentTests.cs@@ -20,7 +20,8 @@ public class AttachmentTests : ClientPlaywrightTest/// </summary>/// <returns>Async task.</returns>[Test]- public async Task UploadAttachment()+ [Order(1)]+ public async Task UploadAndDownloadAttachment(){// Create a new alias with service name = "Test Service".var serviceName = "Test Service";@@ -43,14 +44,100 @@ public class AttachmentTests : ClientPlaywrightTest// Set the file input using the temporary fileawait fileInput.SetInputFilesAsync(tempFilePath);- await Task.Delay(5000); // Reduced delay for faster test execution+ // Delete the temporary file+ File.Delete(tempFilePath);+ });++ // Check that the attachment name appears on the alias page.+ var pageContent = await Page.TextContentAsync("body");+ Assert.That(pageContent, Does.Contain("TestAttachment.txt"), "Uploaded attachment name does not appear on alias page.");++ // Download the attachment+ var downloadPromise = Page.WaitForDownloadAsync();+ await Page.ClickAsync("text=TestAttachment.txt");+ var download = await downloadPromise;++ // Get the path of the downloaded file+ var downloadedFilePath = await download.PathAsync();++ // Read the content of the downloaded file+ var downloadedContent = await File.ReadAllBytesAsync(downloadedFilePath);++ // Compare the downloaded content with the original file content+ var originalContent = await ResourceReaderUtility.ReadEmbeddedResourceBytesAsync("AliasVault.E2ETests.TestData.TestAttachment.txt");+ Assert.That(downloadedContent, Is.EqualTo(originalContent), "Downloaded file content does not match the original file content.");++ // Clean up: delete the downloaded file+ File.Delete(downloadedFilePath);+ }++ /// <summary>+ /// Test that updating a credential with an existing attachment works correctly.+ /// </summary>+ /// <returns>Async task.</returns>+ [Test]+ [Order(2)]+ public async Task UpdateCredentialWithAttachment()+ {+ // Create a new alias with service name = "Test Service".+ var serviceName = "Test Service";+ var initialUsername = "initialuser";+ await CreateCredentialEntry(+ new Dictionary<string, string>+ {+ { "service-name", serviceName },+ { "username", initialUsername },+ },+ async () =>+ {+ // Upload file.+ var fileInput = Page.Locator("input[type='file']");+ var fileContent = await ResourceReaderUtility.ReadEmbeddedResourceBytesAsync("AliasVault.E2ETests.TestData.TestAttachment.txt");++ // Create a temporary file with the content and original file name+ var originalFileName = "TestAttachment.txt";+ var tempFilePath = Path.Combine(Path.GetTempPath(), originalFileName);+ await File.WriteAllBytesAsync(tempFilePath, fileContent);++ // Set the file input using the temporary file+ await fileInput.SetInputFilesAsync(tempFilePath);// Delete the temporary fileFile.Delete(tempFilePath);});- // Check that the service name is present in the content.+ // Check that the attachment name appears on the alias page.var pageContent = await Page.TextContentAsync("body");- Assert.That(pageContent, Does.Contain(serviceName), "Created credential service name does not appear on alias page.");+ Assert.That(pageContent, Does.Contain("TestAttachment.txt"), "Uploaded attachment name does not appear on alias page.");++ // Update the credential+ var updatedUsername = "updateduser";+ await UpdateCredentialEntry(serviceName, new Dictionary<string, string>+ {+ { "username", updatedUsername },+ });++ // Check that the updated username and attachment name still appear on the alias page.+ pageContent = await Page.TextContentAsync("body");+ Assert.That(pageContent, Does.Contain(updatedUsername), "Updated username does not appear on alias page.");+ Assert.That(pageContent, Does.Contain("TestAttachment.txt"), "Attachment name does not appear on alias page after update.");++ // Download the attachment+ var downloadPromise = Page.WaitForDownloadAsync();+ await Page.ClickAsync("text=TestAttachment.txt");+ var download = await downloadPromise;++ // Get the path of the downloaded file+ var downloadedFilePath = await download.PathAsync();++ // Read the content of the downloaded file+ var downloadedContent = await File.ReadAllBytesAsync(downloadedFilePath);++ // Compare the downloaded content with the original file content+ var originalContent = await ResourceReaderUtility.ReadEmbeddedResourceBytesAsync("AliasVault.E2ETests.TestData.TestAttachment.txt");+ Assert.That(downloadedContent, Is.EqualTo(originalContent), "Downloaded file content does not match the original file content after update.");++ // Clean up: delete the downloaded file+ File.Delete(downloadedFilePath);}}