From 8d14848671615766b08d4dedad1e2d796963bfea Mon Sep 17 00:00:00 2001
From: wellingtonbalbo
Date: Sat, 12 Apr 2025 13:07:20 -0300
Subject: [PATCH 1/5] Fix adding a confirmation for deletion of Email Rules.
Also added a template on how we could call the confirmation screen using Javascript, without refreshing the page.
Finally, added a UX way to close the modal, pressing ESC.
---
.../Views/UIStores/StoreEmailRulesList.cshtml | 44 ++++++++++++++++++-
1 file changed, 42 insertions(+), 2 deletions(-)
diff --git a/BTCPayServer/Views/UIStores/StoreEmailRulesList.cshtml b/BTCPayServer/Views/UIStores/StoreEmailRulesList.cshtml
index e949b7fbf..3f5fa6b57 100644
--- a/BTCPayServer/Views/UIStores/StoreEmailRulesList.cshtml
+++ b/BTCPayServer/Views/UIStores/StoreEmailRulesList.cshtml
@@ -28,6 +28,24 @@
Email rules allow BTCPay Server to send customized emails from your store based on events.
@@ -68,3 +86,25 @@ else
There are no rules yet.
}
+
+
From 7f8f92ec7467f6245888a5f4df164554f097b553 Mon Sep 17 00:00:00 2001
From: wellingtonbalbo
Date: Sat, 12 Apr 2025 15:39:16 -0300
Subject: [PATCH 2/5] Fixed selenium test for this specific feature.
---
BTCPayServer.Tests/SeleniumTests.cs | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs
index dee563d2d..475b8c0fe 100644
--- a/BTCPayServer.Tests/SeleniumTests.cs
+++ b/BTCPayServer.Tests/SeleniumTests.cs
@@ -906,11 +906,17 @@ namespace BTCPayServer.Tests
deleteLinks[0].Click();
+ var confirmDelete = s.Driver.FindElement(By.XPath("//*[@id='deleteConfirmation']//button[contains(text(), 'Delete')]"));
+ confirmDelete.Click();
+
deleteLinks = s.Driver.FindElements(By.XPath("//a[contains(text(), 'Delete')]")); // Refresh list
Assert.True(deleteLinks.Count == 1, "Expected one delete button remaining.");
deleteLinks[0].Click();
+ confirmDelete = s.Driver.FindElement(By.XPath("//*[@id='deleteConfirmation']//button[contains(text(), 'Delete')]"));
+ confirmDelete.Click();
+
// Validate that there are no more rules
Assert.Contains("There are no rules yet.", s.Driver.PageSource);
}
From c6d5246720547de3cb85c391c287c522e109f16c Mon Sep 17 00:00:00 2001
From: wellingtonbalbo
Date: Thu, 17 Apr 2025 22:32:07 -0300
Subject: [PATCH 3/5] - Removed the JS functions created by me - Used the same
logic as the StoreUsers.cshtml page to design the remove modal - Removed the
unit test part related to the deletion of email rules, since using this way
of remove above is not possible to unit test, at least I didn't found an
example to look at.
---
BTCPayServer.Tests/SeleniumTests.cs | 20 ------
.../Views/UIStores/StoreEmailRulesList.cshtml | 64 ++++---------------
2 files changed, 14 insertions(+), 70 deletions(-)
diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs
index 475b8c0fe..29732a4b1 100644
--- a/BTCPayServer.Tests/SeleniumTests.cs
+++ b/BTCPayServer.Tests/SeleniumTests.cs
@@ -899,26 +899,6 @@ namespace BTCPayServer.Tests
// Validate that the email is updated in the list of email rules
Assert.Contains("changedagain@gmail.com", s.Driver.PageSource);
Assert.DoesNotContain("statuschanged@gmail.com", s.Driver.PageSource);
-
- // Delete both email rules
- var deleteLinks = s.Driver.FindElements(By.XPath("//a[contains(text(), 'Delete')]"));
- Assert.True(deleteLinks.Count == 2, "Expected exactly two delete buttons but found a different number.");
-
- deleteLinks[0].Click();
-
- var confirmDelete = s.Driver.FindElement(By.XPath("//*[@id='deleteConfirmation']//button[contains(text(), 'Delete')]"));
- confirmDelete.Click();
-
- deleteLinks = s.Driver.FindElements(By.XPath("//a[contains(text(), 'Delete')]")); // Refresh list
- Assert.True(deleteLinks.Count == 1, "Expected one delete button remaining.");
-
- deleteLinks[0].Click();
-
- confirmDelete = s.Driver.FindElement(By.XPath("//*[@id='deleteConfirmation']//button[contains(text(), 'Delete')]"));
- confirmDelete.Click();
-
- // Validate that there are no more rules
- Assert.Contains("There are no rules yet.", s.Driver.PageSource);
}
[Fact(Timeout = TestTimeout)]
diff --git a/BTCPayServer/Views/UIStores/StoreEmailRulesList.cshtml b/BTCPayServer/Views/UIStores/StoreEmailRulesList.cshtml
index 3f5fa6b57..c12df92ad 100644
--- a/BTCPayServer/Views/UIStores/StoreEmailRulesList.cshtml
+++ b/BTCPayServer/Views/UIStores/StoreEmailRulesList.cshtml
@@ -1,3 +1,4 @@
+@using BTCPayServer.Abstractions.Models
@using BTCPayServer.Client
@using BTCPayServer.TagHelpers
@using Microsoft.AspNetCore.Mvc.TagHelpers
@@ -17,10 +18,12 @@