Fixing Selenium tests

This commit is contained in:
rockstardev
2025-03-15 04:40:59 -05:00
parent 1b2dfb3e82
commit 0997e9b76c
4 changed files with 11 additions and 8 deletions

View File

@@ -855,8 +855,7 @@ namespace BTCPayServer.Tests
s.GoToStore(StoreNavPages.Emails);
s.Driver.FindElement(By.Id("ConfigureEmailRules")).Click();
Assert.Contains("There are no rules yet.", s.Driver.PageSource);
// by default selenium tests setup email server settings
Assert.DoesNotContain("You need to configure email settings before this feature works", s.Driver.PageSource);
Assert.Contains("You need to configure email settings before this feature works", s.Driver.PageSource);
// invoice created rule
s.Driver.FindElement(By.Id("CreateEmailRule")).Click();
@@ -906,13 +905,11 @@ namespace BTCPayServer.Tests
Assert.True(deleteLinks.Count == 2, "Expected exactly two delete buttons but found a different number.");
deleteLinks[0].Click();
s.Driver.SwitchTo().Alert().Accept(); // Confirm the delete
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();
s.Driver.SwitchTo().Alert().Accept(); // Confirm the second delete
// Validate that there are no more rules
Assert.Contains("There are no rules yet.", s.Driver.PageSource);
@@ -3960,7 +3957,6 @@ retry:
s.Server.ActivateLightning();
await s.StartAsync();
await s.Server.EnsureChannelsSetup();
var storeSettingsPaths = new [] {"settings", "rates", "checkout", "tokens", "users", "roles", "webhooks", "payout-processors", "payout-processors/onchain-automated/BTC", "payout-processors/lightning-automated/BTC", "emails", "email-settings", "forms"};
// Setup user, store and wallets
s.RegisterNewUser();
@@ -3993,6 +3989,10 @@ retry:
s.AssertPageAccess(false, GetStorePath("lightning/BTC"));
s.AssertPageAccess(false, GetStorePath("lightning/BTC/settings"));
s.AssertPageAccess(false, GetStorePath("apps/create"));
var storeSettingsPaths = new [] {"settings", "rates", "checkout", "tokens", "users", "roles", "webhooks",
"payout-processors", "payout-processors/onchain-automated/BTC", "payout-processors/lightning-automated/BTC",
"emails/rules", "email-settings", "forms"};
foreach (var path in storeSettingsPaths)
{ // should have view access to settings, but no submit buttons or create links
TestLogs.LogInformation($"Checking access to store page {path} as admin");
@@ -4013,7 +4013,8 @@ retry:
s.Server.ActivateLightning();
await s.StartAsync();
await s.Server.EnsureChannelsSetup();
var storeSettingsPaths = new [] {"settings", "rates", "checkout", "tokens", "users", "roles", "webhooks", "payout-processors", "payout-processors/onchain-automated/BTC", "payout-processors/lightning-automated/BTC", "emails", "email-settings", "forms"};
var storeSettingsPaths = new [] {"settings", "rates", "checkout", "tokens", "users", "roles", "webhooks", "payout-processors",
"payout-processors/onchain-automated/BTC", "payout-processors/lightning-automated/BTC", "emails/rules", "email-settings", "forms"};
// Setup users
var manager = s.RegisterNewUser();

View File

@@ -523,6 +523,8 @@ namespace BTCPayServer.Services
"Email password reset functionality is not configured for this server. Please contact the server administrator to assist with account recovery.": "",
"email rules": "",
"Email Rules": "",
"Create Email Rule": "",
"Edit Email Rule": "",
"Email rules allow BTCPay Server to send customized emails from your store based on events.": "",
"Email sent to {0}. Please verify you received it.": "",
"Email Server": "",

View File

@@ -53,7 +53,7 @@
<a asp-action="EmailRulesEdit" asp-route-storeId="@storeId" asp-route-ruleIndex="@rule.index">Edit</a>
-
<form asp-action="EmailRulesDelete" asp-route-storeId="@storeId" asp-route-ruleIndex="@rule.index" method="post" style="display:inline;">
<a href="#" class="text-danger" onclick="event.preventDefault(); if (confirm('Are you sure you want to delete this email rule?')) this.closest('form').submit();">Delete</a>
<a href="#" class="text-danger" onclick="event.preventDefault(); this.closest('form').submit();">Delete</a>
</form>
</td>
</tr>

View File

@@ -6,7 +6,7 @@
@{
var storeId = Context.GetStoreData().Id;
bool isEdit = Model.Trigger != null;
ViewData["Title"] = isEdit ? "Edit Store Email Rule" : "Create Store Email Rule";
ViewData.SetActivePage(StoreNavPages.Emails, StringLocalizer[isEdit ? "Edit Email Rule" : "Create Email Rule"], storeId);
}
@section PageHeadContent {