From 79af285124afbd790d90ecbb4ac9819514b1cd20 Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Fri, 27 Jun 2025 15:53:34 +0200 Subject: [PATCH] Update tests (#969) --- .../Main/Components/Email/EmailPreview.razor | 16 ++++++++-------- .../Main/Pages/Emails/Home.razor | 2 +- .../Client/Shard1/EmailDecryptionTests.cs | 18 ++++++++++++------ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/apps/server/AliasVault.Client/Main/Components/Email/EmailPreview.razor b/apps/server/AliasVault.Client/Main/Components/Email/EmailPreview.razor index 025a5e9f3..ab66802df 100644 --- a/apps/server/AliasVault.Client/Main/Components/Email/EmailPreview.razor +++ b/apps/server/AliasVault.Client/Main/Components/Email/EmailPreview.razor @@ -23,10 +23,10 @@ } else { - @Email?.Subject + @Email.Subject } - @@ -331,4 +331,4 @@ GlobalNotificationService.AddErrorMessage($"Error downloading attachment: {ex.Message}", true); } } -} \ No newline at end of file +} diff --git a/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor b/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor index 92e8ead80..556d72ee1 100644 --- a/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor +++ b/apps/server/AliasVault.Client/Main/Pages/Emails/Home.razor @@ -362,7 +362,7 @@ else // Auto-select first email on desktop layout if none is selected and emails exist (only for initial load) if (!appendToList && EmailList.Count > 0 && SelectedEmailId == null) { - var firstEmail = EmailList.First(); + var firstEmail = EmailList[0]; SelectedEmailId = firstEmail.Id; _ = LoadSelectedEmailForPreview(firstEmail.Id); } diff --git a/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard1/EmailDecryptionTests.cs b/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard1/EmailDecryptionTests.cs index 0f9c4243e..499ea140c 100644 --- a/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard1/EmailDecryptionTests.cs +++ b/apps/server/Tests/AliasVault.E2ETests/Tests/Client/Shard1/EmailDecryptionTests.cs @@ -121,9 +121,9 @@ public class EmailDecryptionTests : ClientPlaywrightTest emailContent = await Page.TextContentAsync("body"); Assert.That(emailContent, Does.Contain(textSubject), "Email not (correctly) decrypted and displayed on the emails page. Check email decryption logic."); - // Attempt to click on the email subject to open the modal. - await Page.Locator("text=" + textSubject).First.ClickAsync(); - await WaitForUrlAsync("emails**", "Delete"); + // Attempt to click on the email subject to open the email. + await Page.Locator("div", new PageLocatorOptions { HasTextString = textSubject }).First.ClickAsync(); + await WaitForUrlAsync("emails**", "Credential:"); // Assert that the anchor tag in the email iframe has target="_blank" attribute. var anchorTag = await Page.Locator("iframe").First.GetAttributeAsync("srcdoc"); @@ -132,6 +132,9 @@ public class EmailDecryptionTests : ClientPlaywrightTest // Click the delete button to delete the email. await Page.Locator("id=delete-email").First.ClickAsync(); + // Click the confirm button. + await Page.Locator("id=confirmButton").First.ClickAsync(); + // Wait for the email delete confirm message to show up. await WaitForUrlAsync("emails**", "Email deleted successfully"); @@ -240,9 +243,9 @@ public class EmailDecryptionTests : ClientPlaywrightTest var attachmentIndicator = await Page.Locator(".attachment-indicator").First.GetAttributeAsync("class"); Assert.That(attachmentIndicator, Is.Not.Null, "Attachment indicator not visible on email page. Check email attachment decryption logic."); - // Attempt to click on the email subject to open the modal. - await Page.Locator("text=" + textSubject).First.ClickAsync(); - await WaitForUrlAsync("emails**", "Delete"); + // Attempt to click on the email subject to open the email. + await Page.Locator("div", new PageLocatorOptions { HasTextString = textSubject }).First.ClickAsync(); + await WaitForUrlAsync("emails**", "Credential:"); // Assert that the anchor tag in the email iframe has target="_blank" attribute. var anchorTag = await Page.Locator("iframe").First.GetAttributeAsync("srcdoc"); @@ -272,6 +275,9 @@ public class EmailDecryptionTests : ClientPlaywrightTest // Click the delete button to delete the email. await Page.Locator("id=delete-email").First.ClickAsync(); + // Click the confirm button. + await Page.Locator("id=confirmButton").First.ClickAsync(); + // Wait for the email delete confirm message to show up. await WaitForUrlAsync("emails**", "Email deleted successfully");