Fix default payment bug (#2975)

* Fix default payment bug

This attempts to fix the default payment bug described in #2963.

Update to complete #2986

This takes into account #2986 and @NicolasDorier 's suggestion to add a default payment type as an empty (valueless) option that is selected by default.

* Fix tests

Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
This commit is contained in:
Samuel B. Atwood
2021-10-20 01:34:04 -04:00
committed by GitHub
parent 791d0abb34
commit 5655f22397
2 changed files with 7 additions and 3 deletions

View File

@@ -21,6 +21,7 @@ using OpenQA.Selenium;
using OpenQA.Selenium.Chrome; using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.Extensions; using OpenQA.Selenium.Support.Extensions;
using Xunit; using Xunit;
using OpenQA.Selenium.Support.UI;
namespace BTCPayServer.Tests namespace BTCPayServer.Tests
{ {
@@ -352,7 +353,7 @@ namespace BTCPayServer.Tests
decimal? amount = 100, decimal? amount = 100,
string currency = "USD", string currency = "USD",
string refundEmail = "", string refundEmail = "",
string defaultPaymentMethod = "BTC" string defaultPaymentMethod = null
) )
{ {
GoToInvoices(); GoToInvoices();
@@ -364,7 +365,8 @@ namespace BTCPayServer.Tests
currencyEl.SendKeys(currency); currencyEl.SendKeys(currency);
Driver.FindElement(By.Id("BuyerEmail")).SendKeys(refundEmail); Driver.FindElement(By.Id("BuyerEmail")).SendKeys(refundEmail);
Driver.FindElement(By.Name("StoreId")).SendKeys(storeName); Driver.FindElement(By.Name("StoreId")).SendKeys(storeName);
Driver.FindElement(By.Name("DefaultPaymentMethod")).SendKeys(defaultPaymentMethod); if (defaultPaymentMethod is string)
new SelectElement(Driver.FindElement(By.Name("DefaultPaymentMethod"))).SelectByValue(defaultPaymentMethod);
Driver.FindElement(By.Id("Create")).Click(); Driver.FindElement(By.Id("Create")).Click();
var statusElement = FindAlertMessage(); var statusElement = FindAlertMessage();

View File

@@ -81,7 +81,9 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label asp-for="DefaultPaymentMethod" class="form-label"></label> <label asp-for="DefaultPaymentMethod" class="form-label"></label>
<select asp-for="DefaultPaymentMethod" asp-items="Model.AvailablePaymentMethods" class="form-select"></select> <select asp-for="DefaultPaymentMethod" asp-items="Model.AvailablePaymentMethods" class="form-select">
<option value="" selected>Store's default settings</option>
</select>
<span asp-validation-for="DefaultPaymentMethod" class="text-danger"></span> <span asp-validation-for="DefaultPaymentMethod" class="text-danger"></span>
</div> </div>
<div class="form-group"> <div class="form-group">