From a60c55c6dffbba24d33ea5693d91e04e214f59dc Mon Sep 17 00:00:00 2001 From: d11n Date: Thu, 12 Sep 2024 03:08:16 +0200 Subject: [PATCH] Transactions: Improve TX ID display (#6190) * Transactions: Improve TX ID display * Elastic fix * Test and behaviour fix --- BTCPayServer.Tests/CheckoutUITests.cs | 18 +++++++++--------- BTCPayServer.Tests/SeleniumTests.cs | 11 +++++------ .../Components/TruncateCenter/Default.cshtml | 15 ++++++--------- .../Views/UIWallets/WalletTransactions.cshtml | 2 +- .../UIWallets/_WalletTransactionsList.cshtml | 6 ++---- BTCPayServer/wwwroot/main/site.css | 4 +++- 6 files changed, 26 insertions(+), 30 deletions(-) diff --git a/BTCPayServer.Tests/CheckoutUITests.cs b/BTCPayServer.Tests/CheckoutUITests.cs index 3d813d1dd..7d07e9898 100644 --- a/BTCPayServer.Tests/CheckoutUITests.cs +++ b/BTCPayServer.Tests/CheckoutUITests.cs @@ -58,8 +58,8 @@ namespace BTCPayServer.Tests var qrValue = s.Driver.FindElement(By.CssSelector(".qr-container")).GetAttribute("data-qr-value"); var clipboard = s.Driver.FindElement(By.CssSelector(".qr-container")).GetAttribute("data-clipboard"); var payUrl = s.Driver.FindElement(By.Id("PayInWallet")).GetAttribute("href"); - var address = s.Driver.FindElement(By.CssSelector("#Address_BTC-CHAIN .truncate-center-start")).Text; - Assert.StartsWith("bcrt", s.Driver.FindElement(By.CssSelector("#Address_BTC-CHAIN .truncate-center-start")).Text); + var address = s.Driver.FindElement(By.CssSelector("#Address_BTC-CHAIN .truncate-center")).GetAttribute("data-text"); + Assert.StartsWith("bcrt", address); Assert.DoesNotContain("lightning=", payUrl); Assert.Equal($"bitcoin:{address}", payUrl); Assert.Equal($"bitcoin:{address}", clipboard); @@ -80,7 +80,7 @@ namespace BTCPayServer.Tests { payUrl = s.Driver.FindElement(By.Id("PayInWallet")).GetAttribute("href"); Assert.StartsWith("lightning:lnurl", payUrl); - Assert.StartsWith("lnurl", s.Driver.WaitForElement(By.CssSelector("#Lightning_BTC-CHAIN .truncate-center-start")).Text); + Assert.StartsWith("lnurl", s.Driver.WaitForElement(By.CssSelector("#Lightning_BTC-CHAIN .truncate-center")).GetAttribute("data-text")); s.Driver.ElementDoesNotExist(By.Id("Address_BTC-CHAIN")); }); @@ -94,7 +94,7 @@ namespace BTCPayServer.Tests qrValue = s.Driver.FindElement(By.CssSelector(".qr-container")).GetAttribute("data-qr-value"); clipboard = s.Driver.FindElement(By.CssSelector(".qr-container")).GetAttribute("data-clipboard"); payUrl = s.Driver.FindElement(By.Id("PayInWallet")).GetAttribute("href"); - address = s.Driver.FindElement(By.CssSelector("#Lightning_BTC-LN .truncate-center-start")).Text; + address = s.Driver.FindElement(By.CssSelector("#Lightning_BTC-LN .truncate-center")).GetAttribute("data-text"); Assert.Equal($"lightning:{address}", payUrl); Assert.Equal($"lightning:{address}", clipboard); Assert.Equal($"lightning:{address.ToUpperInvariant()}", qrValue); @@ -147,7 +147,7 @@ namespace BTCPayServer.Tests invoiceId = s.CreateInvoice(2100, "EUR"); s.GoToInvoiceCheckout(invoiceId); await Task.Delay(200); - address = s.Driver.FindElement(By.CssSelector("#Address_BTC-CHAIN .truncate-center-start")).Text; + address = s.Driver.FindElement(By.CssSelector("#Address_BTC-CHAIN .truncate-center")).GetAttribute("data-text"); var amountFraction = "0.00001"; await s.Server.ExplorerNode.SendToAddressAsync(BitcoinAddress.Create(address, Network.RegTest), Money.Parse(amountFraction)); @@ -261,8 +261,8 @@ namespace BTCPayServer.Tests qrValue = s.Driver.FindElement(By.CssSelector(".qr-container")).GetAttribute("data-qr-value"); clipboard = s.Driver.FindElement(By.CssSelector(".qr-container")).GetAttribute("data-clipboard"); payUrl = s.Driver.FindElement(By.Id("PayInWallet")).GetAttribute("href"); - var copyAddressOnchain = s.Driver.FindElement(By.CssSelector("#Address_BTC-CHAIN .truncate-center-start")).Text; - var copyAddressLightning = s.Driver.FindElement(By.CssSelector("#Lightning_BTC-CHAIN .truncate-center-start")).Text; + var copyAddressOnchain = s.Driver.FindElement(By.CssSelector("#Address_BTC-CHAIN .truncate-center")).GetAttribute("data-text"); + var copyAddressLightning = s.Driver.FindElement(By.CssSelector("#Lightning_BTC-CHAIN .truncate-center")).GetAttribute("data-text"); Assert.StartsWith($"bitcoin:{copyAddressOnchain}?amount=", payUrl); Assert.Contains("?amount=", payUrl); Assert.Contains("&lightning=", payUrl); @@ -327,8 +327,8 @@ namespace BTCPayServer.Tests qrValue = s.Driver.FindElement(By.CssSelector(".qr-container")).GetAttribute("data-qr-value"); clipboard = s.Driver.FindElement(By.CssSelector(".qr-container")).GetAttribute("data-clipboard"); payUrl = s.Driver.FindElement(By.Id("PayInWallet")).GetAttribute("href"); - copyAddressOnchain = s.Driver.FindElement(By.CssSelector("#Address_BTC-CHAIN .truncate-center-start")).Text; - copyAddressLightning = s.Driver.FindElement(By.CssSelector("#Lightning_BTC-CHAIN .truncate-center-start")).Text; + copyAddressOnchain = s.Driver.FindElement(By.CssSelector("#Address_BTC-CHAIN .truncate-center")).GetAttribute("data-text"); + copyAddressLightning = s.Driver.FindElement(By.CssSelector("#Lightning_BTC-CHAIN .truncate-center")).GetAttribute("data-text"); Assert.StartsWith($"bitcoin:{copyAddressOnchain}", payUrl); Assert.Contains("?lightning=lnurl", payUrl); Assert.DoesNotContain("amount=", payUrl); diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs index c690f7240..3d59c0b62 100644 --- a/BTCPayServer.Tests/SeleniumTests.cs +++ b/BTCPayServer.Tests/SeleniumTests.cs @@ -1872,7 +1872,7 @@ namespace BTCPayServer.Tests // Check the tx sent earlier arrived s.Driver.FindElement(By.Id($"StoreNav-Wallet{cryptoCode}")).Click(); s.Driver.WaitWalletTransactionsLoaded(); - s.Driver.FindElement(By.PartialLinkText(tx.ToString())); + s.Driver.FindElement(By.CssSelector($"[data-text='{tx}']")); var walletTransactionUri = new Uri(s.Driver.Url); @@ -1900,7 +1900,6 @@ namespace BTCPayServer.Tests var jack = new Key().PubKey.Hash.GetAddress(Network.RegTest); SetTransactionOutput(s, 0, jack, 0.01m); s.Driver.FindElement(By.Id("SignTransaction")).Click(); - Assert.Contains(jack.ToString(), s.Driver.PageSource); Assert.Contains("0.01000000", s.Driver.PageSource); Assert.EndsWith("psbt/ready", s.Driver.Url); @@ -3020,7 +3019,7 @@ namespace BTCPayServer.Tests // Topup Invoice test var i = s.CreateInvoice(storeId, null, cryptoCode); s.GoToInvoiceCheckout(i); - var lnurl = s.Driver.FindElement(By.CssSelector("#Lightning_BTC-LNURL .truncate-center-start")).Text; + var lnurl = s.Driver.FindElement(By.CssSelector("#Lightning_BTC-LNURL .truncate-center")).GetAttribute("data-text"); var parsed = LNURL.LNURL.Parse(lnurl, out var tag); var fetchedReuqest = Assert.IsType(await LNURL.LNURL.FetchInformation(parsed, new HttpClient())); @@ -3057,7 +3056,7 @@ namespace BTCPayServer.Tests i = s.CreateInvoice(storeId, 0.0000001m, cryptoCode); s.GoToInvoiceCheckout(i); // BOLT11 is also displayed for standard invoice (not LNURL, even if it is available) - var bolt11 = s.Driver.FindElement(By.CssSelector("#Lightning_BTC-LN .truncate-center-start")).Text; + var bolt11 = s.Driver.FindElement(By.CssSelector("#Lightning_BTC-LN .truncate-center")).GetAttribute("data-text"); BOLT11PaymentRequest.Parse(bolt11, s.Server.ExplorerNode.Network); var invoiceId = s.Driver.Url.Split('/').Last(); using (var resp = await s.Server.PayTester.HttpClient.GetAsync("BTC/lnurl/pay/i/" + invoiceId)) @@ -3110,7 +3109,7 @@ namespace BTCPayServer.Tests i = s.CreateInvoice(storeId, null, cryptoCode); s.GoToInvoiceCheckout(i); - lnurl = s.Driver.FindElement(By.CssSelector("#Lightning_BTC-LNURL .truncate-center-start")).Text; + lnurl = s.Driver.FindElement(By.CssSelector("#Lightning_BTC-LNURL .truncate-center")).GetAttribute("data-text"); Assert.StartsWith("lnurlp", lnurl); LNURL.LNURL.Parse(lnurl, out tag); @@ -3123,7 +3122,7 @@ namespace BTCPayServer.Tests Assert.Contains($"{cryptoCode} Lightning settings successfully updated", s.FindAlertMessage().Text); var invForPP = s.CreateInvoice(null, cryptoCode); s.GoToInvoiceCheckout(invForPP); - lnurl = s.Driver.FindElement(By.CssSelector("#Lightning_BTC-LNURL .truncate-center-start")).Text; + lnurl = s.Driver.FindElement(By.CssSelector("#Lightning_BTC-LNURL .truncate-center")).GetAttribute("data-text"); LNURL.LNURL.Parse(lnurl, out tag); // Check that pull payment has lightning option diff --git a/BTCPayServer/Components/TruncateCenter/Default.cshtml b/BTCPayServer/Components/TruncateCenter/Default.cshtml index 305c7fd8e..e692d389c 100644 --- a/BTCPayServer/Components/TruncateCenter/Default.cshtml +++ b/BTCPayServer/Components/TruncateCenter/Default.cshtml @@ -6,17 +6,17 @@ @if (Model.Elastic) classes += " truncate-center--elastic"; var prefix = Model.IsVue ? ":" : ""; } - + @if (Model.IsVue) { - + @if (Model.Elastic) { - + } else { - + } @@ -25,11 +25,8 @@ else { - @(Model.Elastic || !isTruncated ? Model.Text : $"{Model.Start}…") - @if (isTruncated) - { - @Model.End - } + @(Model.Elastic || !isTruncated ? Model.Text[..^Model.Padding] : $"{Model.Start}…") + @Model.End @Model.Text } diff --git a/BTCPayServer/Views/UIWallets/WalletTransactions.cshtml b/BTCPayServer/Views/UIWallets/WalletTransactions.cshtml index bf6439a79..4f537aa54 100644 --- a/BTCPayServer/Views/UIWallets/WalletTransactions.cshtml +++ b/BTCPayServer/Views/UIWallets/WalletTransactions.cshtml @@ -184,7 +184,7 @@ Label - Transaction Id + Transaction Amount diff --git a/BTCPayServer/Views/UIWallets/_WalletTransactionsList.cshtml b/BTCPayServer/Views/UIWallets/_WalletTransactionsList.cshtml index cd4bc0c4c..6e4f5e4e5 100644 --- a/BTCPayServer/Views/UIWallets/_WalletTransactionsList.cshtml +++ b/BTCPayServer/Views/UIWallets/_WalletTransactionsList.cshtml @@ -21,10 +21,8 @@ exclude-types="false" display-inline="true"/> - - - @transaction.Id - + + @transaction.Balance diff --git a/BTCPayServer/wwwroot/main/site.css b/BTCPayServer/wwwroot/main/site.css index 6faa26f87..32dd943ee 100644 --- a/BTCPayServer/wwwroot/main/site.css +++ b/BTCPayServer/wwwroot/main/site.css @@ -1085,7 +1085,9 @@ input.ts-wrapper.form-control:not(.ts-hidden-accessible,.ts-inline) { } .truncate-center-text { - display: none; + color: transparent; + position: absolute; + pointer-events: none; } }