mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +01:00
Fix build warnings and flaky tests (#5780)
* Make checkout v2 selenium tests more robust * Fix build warnings * Make payjoin test more robust * Make LNURL test more robust
This commit is contained in:
@@ -130,9 +130,12 @@ namespace BTCPayServer.Tests
|
|||||||
expirySeconds.SendKeys("3");
|
expirySeconds.SendKeys("3");
|
||||||
s.Driver.FindElement(By.Id("Expire")).Click();
|
s.Driver.FindElement(By.Id("Expire")).Click();
|
||||||
|
|
||||||
|
TestUtils.Eventually(() =>
|
||||||
|
{
|
||||||
var paymentInfo = s.Driver.WaitForElement(By.Id("PaymentInfo"));
|
var paymentInfo = s.Driver.WaitForElement(By.Id("PaymentInfo"));
|
||||||
Assert.Contains("This invoice will expire in", paymentInfo.Text);
|
Assert.Contains("This invoice will expire in", paymentInfo.Text);
|
||||||
Assert.DoesNotContain("Please send", paymentInfo.Text);
|
Assert.DoesNotContain("Please send", paymentInfo.Text);
|
||||||
|
});
|
||||||
TestUtils.Eventually(() =>
|
TestUtils.Eventually(() =>
|
||||||
{
|
{
|
||||||
var expiredSection = s.Driver.FindElement(By.Id("unpaid"));
|
var expiredSection = s.Driver.FindElement(By.Id("unpaid"));
|
||||||
@@ -140,7 +143,6 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Contains("Invoice Expired", expiredSection.Text);
|
Assert.Contains("Invoice Expired", expiredSection.Text);
|
||||||
Assert.Contains("resubmit a payment", expiredSection.Text);
|
Assert.Contains("resubmit a payment", expiredSection.Text);
|
||||||
Assert.DoesNotContain("This invoice expired with partial payment", expiredSection.Text);
|
Assert.DoesNotContain("This invoice expired with partial payment", expiredSection.Text);
|
||||||
|
|
||||||
});
|
});
|
||||||
Assert.True(s.Driver.ElementDoesNotExist(By.Id("ContactLink")));
|
Assert.True(s.Driver.ElementDoesNotExist(By.Id("ContactLink")));
|
||||||
Assert.True(s.Driver.ElementDoesNotExist(By.Id("ReceiptLink")));
|
Assert.True(s.Driver.ElementDoesNotExist(By.Id("ReceiptLink")));
|
||||||
@@ -164,9 +166,12 @@ namespace BTCPayServer.Tests
|
|||||||
expirySeconds.SendKeys("3");
|
expirySeconds.SendKeys("3");
|
||||||
s.Driver.FindElement(By.Id("Expire")).Click();
|
s.Driver.FindElement(By.Id("Expire")).Click();
|
||||||
|
|
||||||
paymentInfo = s.Driver.WaitForElement(By.Id("PaymentInfo"));
|
TestUtils.Eventually(() =>
|
||||||
|
{
|
||||||
|
var paymentInfo = s.Driver.WaitForElement(By.Id("PaymentInfo"));
|
||||||
Assert.Contains("The invoice hasn't been paid in full.", paymentInfo.Text);
|
Assert.Contains("The invoice hasn't been paid in full.", paymentInfo.Text);
|
||||||
Assert.Contains("Please send", paymentInfo.Text);
|
Assert.Contains("Please send", paymentInfo.Text);
|
||||||
|
});
|
||||||
TestUtils.Eventually(() =>
|
TestUtils.Eventually(() =>
|
||||||
{
|
{
|
||||||
var expiredSection = s.Driver.FindElement(By.Id("unpaid"));
|
var expiredSection = s.Driver.FindElement(By.Id("unpaid"));
|
||||||
@@ -210,7 +215,7 @@ namespace BTCPayServer.Tests
|
|||||||
{
|
{
|
||||||
s.Driver.FindElement(By.Id("FakePayment")).Click();
|
s.Driver.FindElement(By.Id("FakePayment")).Click();
|
||||||
s.Driver.FindElement(By.Id("mine-block")).Click();
|
s.Driver.FindElement(By.Id("mine-block")).Click();
|
||||||
paymentInfo = s.Driver.WaitForElement(By.Id("PaymentInfo"));
|
var paymentInfo = s.Driver.WaitForElement(By.Id("PaymentInfo"));
|
||||||
Assert.Contains("The invoice hasn't been paid in full", paymentInfo.Text);
|
Assert.Contains("The invoice hasn't been paid in full", paymentInfo.Text);
|
||||||
Assert.Contains("Please send", paymentInfo.Text);
|
Assert.Contains("Please send", paymentInfo.Text);
|
||||||
});
|
});
|
||||||
@@ -359,11 +364,13 @@ namespace BTCPayServer.Tests
|
|||||||
expirySeconds.Clear();
|
expirySeconds.Clear();
|
||||||
expirySeconds.SendKeys("5");
|
expirySeconds.SendKeys("5");
|
||||||
s.Driver.FindElement(By.Id("Expire")).Click();
|
s.Driver.FindElement(By.Id("Expire")).Click();
|
||||||
|
TestUtils.Eventually(() =>
|
||||||
paymentInfo = s.Driver.WaitForElement(By.Id("PaymentInfo"));
|
{
|
||||||
|
var paymentInfo = s.Driver.WaitForElement(By.Id("PaymentInfo"));
|
||||||
Assert.Contains("This invoice will expire in", paymentInfo.Text);
|
Assert.Contains("This invoice will expire in", paymentInfo.Text);
|
||||||
Assert.Contains("00:0", paymentInfo.Text);
|
Assert.Contains("00:0", paymentInfo.Text);
|
||||||
Assert.DoesNotContain("Please send", paymentInfo.Text);
|
Assert.DoesNotContain("Please send", paymentInfo.Text);
|
||||||
|
});
|
||||||
|
|
||||||
// Configure countdown timer
|
// Configure countdown timer
|
||||||
s.GoToHome();
|
s.GoToHome();
|
||||||
@@ -379,7 +386,7 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
s.GoToInvoiceCheckout(invoiceId);
|
s.GoToInvoiceCheckout(invoiceId);
|
||||||
s.Driver.WaitUntilAvailable(By.Id("Checkout-v2"));
|
s.Driver.WaitUntilAvailable(By.Id("Checkout-v2"));
|
||||||
paymentInfo = s.Driver.FindElement(By.Id("PaymentInfo"));
|
var paymentInfo = s.Driver.FindElement(By.Id("PaymentInfo"));
|
||||||
Assert.False(paymentInfo.Displayed);
|
Assert.False(paymentInfo.Displayed);
|
||||||
Assert.DoesNotContain("This invoice will expire in", paymentInfo.Text);
|
Assert.DoesNotContain("This invoice will expire in", paymentInfo.Text);
|
||||||
|
|
||||||
@@ -387,11 +394,13 @@ namespace BTCPayServer.Tests
|
|||||||
expirySeconds.Clear();
|
expirySeconds.Clear();
|
||||||
expirySeconds.SendKeys("599");
|
expirySeconds.SendKeys("599");
|
||||||
s.Driver.FindElement(By.Id("Expire")).Click();
|
s.Driver.FindElement(By.Id("Expire")).Click();
|
||||||
|
TestUtils.Eventually(() =>
|
||||||
|
{
|
||||||
paymentInfo = s.Driver.WaitForElement(By.Id("PaymentInfo"));
|
paymentInfo = s.Driver.WaitForElement(By.Id("PaymentInfo"));
|
||||||
Assert.True(paymentInfo.Displayed);
|
Assert.True(paymentInfo.Displayed);
|
||||||
Assert.Contains("This invoice will expire in", paymentInfo.Text);
|
Assert.Contains("This invoice will expire in", paymentInfo.Text);
|
||||||
Assert.Contains("09:5", paymentInfo.Text);
|
Assert.Contains("09:5", paymentInfo.Text);
|
||||||
|
});
|
||||||
|
|
||||||
// Disable LNURL again
|
// Disable LNURL again
|
||||||
s.GoToHome();
|
s.GoToHome();
|
||||||
@@ -457,13 +466,12 @@ namespace BTCPayServer.Tests
|
|||||||
.GetPaymentMethodDetails().GetPaymentDestination(), Network.RegTest),
|
.GetPaymentMethodDetails().GetPaymentDestination(), Network.RegTest),
|
||||||
new Money(0.001m, MoneyUnit.BTC));
|
new Money(0.001m, MoneyUnit.BTC));
|
||||||
|
|
||||||
IWebElement closebutton = null;
|
|
||||||
TestUtils.Eventually(() =>
|
TestUtils.Eventually(() =>
|
||||||
{
|
{
|
||||||
closebutton = iframe.FindElement(By.Id("close"));
|
var closeButton = iframe.FindElement(By.Id("close"));
|
||||||
Assert.True(closebutton.Displayed);
|
Assert.True(closeButton.Displayed);
|
||||||
|
closeButton.Click();
|
||||||
});
|
});
|
||||||
closebutton.Click();
|
|
||||||
s.Driver.AssertElementNotFound(By.Name("btcpay"));
|
s.Driver.AssertElementNotFound(By.Name("btcpay"));
|
||||||
Assert.Equal(s.Driver.Url,
|
Assert.Equal(s.Driver.Url,
|
||||||
new Uri(s.ServerUri, $"tests/index.html?invoice={invoiceId}").ToString());
|
new Uri(s.ServerUri, $"tests/index.html?invoice={invoiceId}").ToString());
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BTCPayServer.Abstractions.Models;
|
using BTCPayServer.Abstractions.Models;
|
||||||
using BTCPayServer.BIP78.Sender;
|
using BTCPayServer.BIP78.Sender;
|
||||||
@@ -311,7 +312,7 @@ namespace BTCPayServer.Tests
|
|||||||
//payjoin is enabled by default.
|
//payjoin is enabled by default.
|
||||||
var invoiceId = s.CreateInvoice(receiver.storeId);
|
var invoiceId = s.CreateInvoice(receiver.storeId);
|
||||||
s.GoToInvoiceCheckout(invoiceId);
|
s.GoToInvoiceCheckout(invoiceId);
|
||||||
var bip21 = s.Driver.FindElement(By.ClassName("payment__details__instruction__open-wallet__btn"))
|
var bip21 = s.Driver.WaitForElement(By.ClassName("payment__details__instruction__open-wallet__btn"))
|
||||||
.GetAttribute("href");
|
.GetAttribute("href");
|
||||||
Assert.Contains($"{PayjoinClient.BIP21EndpointKey}=", bip21);
|
Assert.Contains($"{PayjoinClient.BIP21EndpointKey}=", bip21);
|
||||||
|
|
||||||
@@ -327,7 +328,7 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
invoiceId = s.CreateInvoice(receiver.storeId);
|
invoiceId = s.CreateInvoice(receiver.storeId);
|
||||||
s.GoToInvoiceCheckout(invoiceId);
|
s.GoToInvoiceCheckout(invoiceId);
|
||||||
bip21 = s.Driver.FindElement(By.ClassName("payment__details__instruction__open-wallet__btn"))
|
bip21 = s.Driver.WaitForElement(By.ClassName("payment__details__instruction__open-wallet__btn"))
|
||||||
.GetAttribute("href");
|
.GetAttribute("href");
|
||||||
Assert.Contains($"{PayjoinClient.BIP21EndpointKey}=", bip21);
|
Assert.Contains($"{PayjoinClient.BIP21EndpointKey}=", bip21);
|
||||||
|
|
||||||
@@ -361,7 +362,7 @@ namespace BTCPayServer.Tests
|
|||||||
//let's do it all again, except now the receiver has funds and is able to payjoin
|
//let's do it all again, except now the receiver has funds and is able to payjoin
|
||||||
invoiceId = s.CreateInvoice();
|
invoiceId = s.CreateInvoice();
|
||||||
s.GoToInvoiceCheckout(invoiceId);
|
s.GoToInvoiceCheckout(invoiceId);
|
||||||
bip21 = s.Driver.FindElement(By.ClassName("payment__details__instruction__open-wallet__btn"))
|
bip21 = s.Driver.WaitForElement(By.ClassName("payment__details__instruction__open-wallet__btn"))
|
||||||
.GetAttribute("href");
|
.GetAttribute("href");
|
||||||
Assert.Contains($"{PayjoinClient.BIP21EndpointKey}", bip21);
|
Assert.Contains($"{PayjoinClient.BIP21EndpointKey}", bip21);
|
||||||
|
|
||||||
@@ -414,13 +415,13 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.False(paymentValueRowColumn.Text.Contains("payjoin",
|
Assert.False(paymentValueRowColumn.Text.Contains("payjoin",
|
||||||
StringComparison.InvariantCultureIgnoreCase));
|
StringComparison.InvariantCultureIgnoreCase));
|
||||||
|
|
||||||
|
s.GoToWallet(receiverWalletId, WalletsNavPages.Transactions);
|
||||||
|
s.Driver.WaitForElement(By.CssSelector("#WalletTransactionsList tr"));
|
||||||
TestUtils.Eventually(() =>
|
TestUtils.Eventually(() =>
|
||||||
{
|
{
|
||||||
s.GoToWallet(receiverWalletId, WalletsNavPages.Transactions);
|
|
||||||
Assert.Contains(invoiceId, s.Driver.PageSource);
|
|
||||||
Assert.Contains("payjoin", s.Driver.PageSource);
|
Assert.Contains("payjoin", s.Driver.PageSource);
|
||||||
//this label does not always show since input gets used
|
// Either the invoice id or the payjoin-exposed label, depending on the input having been used
|
||||||
// Assert.Contains("payjoin-exposed", s.Driver.PageSource);
|
Assert.Matches(new Regex($"({invoiceId}|payjoin-exposed)"), s.Driver.PageSource);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2792,7 +2792,7 @@ namespace BTCPayServer.Tests
|
|||||||
// Topup Invoice test
|
// Topup Invoice test
|
||||||
var i = s.CreateInvoice(storeId, null, cryptoCode);
|
var i = s.CreateInvoice(storeId, null, cryptoCode);
|
||||||
s.GoToInvoiceCheckout(i);
|
s.GoToInvoiceCheckout(i);
|
||||||
s.Driver.FindElement(By.Id("copy-tab")).Click();
|
s.Driver.WaitForElement(By.Id("copy-tab")).Click();
|
||||||
var lnurl = s.Driver.FindElement(By.CssSelector("input.checkoutTextbox")).GetAttribute("value");
|
var lnurl = s.Driver.FindElement(By.CssSelector("input.checkoutTextbox")).GetAttribute("value");
|
||||||
var parsed = LNURL.LNURL.Parse(lnurl, out var tag);
|
var parsed = LNURL.LNURL.Parse(lnurl, out var tag);
|
||||||
var fetchedReuqest =
|
var fetchedReuqest =
|
||||||
@@ -2831,7 +2831,7 @@ namespace BTCPayServer.Tests
|
|||||||
s.GoToInvoiceCheckout(i);
|
s.GoToInvoiceCheckout(i);
|
||||||
s.Driver.FindElement(By.ClassName("payment__currencies_noborder")).Click();
|
s.Driver.FindElement(By.ClassName("payment__currencies_noborder")).Click();
|
||||||
// BOLT11 is also displayed for standard invoice (not LNURL, even if it is available)
|
// BOLT11 is also displayed for standard invoice (not LNURL, even if it is available)
|
||||||
s.Driver.FindElement(By.Id("copy-tab")).Click();
|
s.Driver.WaitForElement(By.Id("copy-tab")).Click();
|
||||||
var bolt11 = s.Driver.FindElement(By.CssSelector("input.checkoutTextbox")).GetAttribute("value");
|
var bolt11 = s.Driver.FindElement(By.CssSelector("input.checkoutTextbox")).GetAttribute("value");
|
||||||
Lightning.BOLT11PaymentRequest.Parse(bolt11, s.Server.ExplorerNode.Network);
|
Lightning.BOLT11PaymentRequest.Parse(bolt11, s.Server.ExplorerNode.Network);
|
||||||
var invoiceId = s.Driver.Url.Split('/').Last();
|
var invoiceId = s.Driver.Url.Split('/').Last();
|
||||||
@@ -2888,7 +2888,7 @@ namespace BTCPayServer.Tests
|
|||||||
i = s.CreateInvoice(storeId, null, cryptoCode);
|
i = s.CreateInvoice(storeId, null, cryptoCode);
|
||||||
s.GoToInvoiceCheckout(i);
|
s.GoToInvoiceCheckout(i);
|
||||||
s.Driver.FindElement(By.ClassName("payment__currencies_noborder"));
|
s.Driver.FindElement(By.ClassName("payment__currencies_noborder"));
|
||||||
s.Driver.FindElement(By.Id("copy-tab")).Click();
|
s.Driver.WaitForElement(By.Id("copy-tab")).Click();
|
||||||
lnurl = s.Driver.FindElement(By.CssSelector("input.checkoutTextbox")).GetAttribute("value");
|
lnurl = s.Driver.FindElement(By.CssSelector("input.checkoutTextbox")).GetAttribute("value");
|
||||||
Assert.StartsWith("lnurlp", lnurl);
|
Assert.StartsWith("lnurlp", lnurl);
|
||||||
LNURL.LNURL.Parse(lnurl, out tag);
|
LNURL.LNURL.Parse(lnurl, out tag);
|
||||||
@@ -2903,7 +2903,7 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Contains($"{cryptoCode} Lightning settings successfully updated", s.FindAlertMessage().Text);
|
Assert.Contains($"{cryptoCode} Lightning settings successfully updated", s.FindAlertMessage().Text);
|
||||||
var invForPP = s.CreateInvoice(null, cryptoCode);
|
var invForPP = s.CreateInvoice(null, cryptoCode);
|
||||||
s.GoToInvoiceCheckout(invForPP);
|
s.GoToInvoiceCheckout(invForPP);
|
||||||
s.Driver.FindElement(By.Id("copy-tab")).Click();
|
s.Driver.WaitForElement(By.Id("copy-tab")).Click();
|
||||||
lnurl = s.Driver.FindElement(By.CssSelector("input.checkoutTextbox")).GetAttribute("value");
|
lnurl = s.Driver.FindElement(By.CssSelector("input.checkoutTextbox")).GetAttribute("value");
|
||||||
LNURL.LNURL.Parse(lnurl, out tag);
|
LNURL.LNURL.Parse(lnurl, out tag);
|
||||||
|
|
||||||
|
|||||||
@@ -95,8 +95,10 @@ public class LegacyInvoiceExportReportProvider : ReportProvider
|
|||||||
data.Add(invoiceEntity.Metadata.ItemCode);
|
data.Add(invoiceEntity.Metadata.ItemCode);
|
||||||
data.Add(invoiceEntity.Metadata.ItemDesc);
|
data.Add(invoiceEntity.Metadata.ItemDesc);
|
||||||
data.Add(invoiceEntity.GetInvoiceState().ToString());
|
data.Add(invoiceEntity.GetInvoiceState().ToString());
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
data.Add(invoiceEntity.StatusString);
|
data.Add(invoiceEntity.StatusString);
|
||||||
data.Add(invoiceEntity.ExceptionStatusString);
|
data.Add(invoiceEntity.ExceptionStatusString);
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
data.Add(invoiceEntity.Metadata.BuyerEmail);
|
data.Add(invoiceEntity.Metadata.BuyerEmail);
|
||||||
data.Add(payment.Accounted);
|
data.Add(payment.Accounted);
|
||||||
}
|
}
|
||||||
@@ -127,8 +129,10 @@ public class LegacyInvoiceExportReportProvider : ReportProvider
|
|||||||
data.Add(invoiceEntity.Metadata.ItemCode);
|
data.Add(invoiceEntity.Metadata.ItemCode);
|
||||||
data.Add(invoiceEntity.Metadata.ItemDesc);
|
data.Add(invoiceEntity.Metadata.ItemDesc);
|
||||||
data.Add(invoiceEntity.GetInvoiceState().ToString());
|
data.Add(invoiceEntity.GetInvoiceState().ToString());
|
||||||
|
#pragma warning disable CS0618 // Type or member is obsolete
|
||||||
data.Add(invoiceEntity.StatusString);
|
data.Add(invoiceEntity.StatusString);
|
||||||
data.Add(invoiceEntity.ExceptionStatusString);
|
data.Add(invoiceEntity.ExceptionStatusString);
|
||||||
|
#pragma warning restore CS0618 // Type or member is obsolete
|
||||||
data.Add(invoiceEntity.Metadata.BuyerEmail);
|
data.Add(invoiceEntity.Metadata.BuyerEmail);
|
||||||
data.Add(null); // Accounted
|
data.Add(null); // Accounted
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user