From 1d210eb6e3def469abd9fa76205480e3573eaedd Mon Sep 17 00:00:00 2001 From: d11n Date: Fri, 6 Oct 2023 15:58:02 +0200 Subject: [PATCH] Crowdfund: Improve no perks case (#5378) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there are no perks configured, do not display the perks sidebar and contribute custom amount directly, when the main CTA "Contribute" is clicked. Before it opened a mopdal, where one had to select the only option (custom amount) manually — so this gets rid of the extra step. Closes #5376. --- BTCPayServer.Tests/SeleniumTests.cs | 25 +++++++++++++++++-- .../Crowdfund/Public/ViewCrowdfund.cshtml | 7 +++--- BTCPayServer/wwwroot/crowdfund/app.js | 14 ++++++++++- 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/BTCPayServer.Tests/SeleniumTests.cs b/BTCPayServer.Tests/SeleniumTests.cs index 134912988..6c97c6629 100644 --- a/BTCPayServer.Tests/SeleniumTests.cs +++ b/BTCPayServer.Tests/SeleniumTests.cs @@ -1107,7 +1107,7 @@ namespace BTCPayServer.Tests s.Driver.FindElement(By.Id("Title")).SendKeys("Kukkstarter"); s.Driver.FindElement(By.CssSelector("div.note-editable.card-block")).SendKeys("1BTC = 1BTC"); s.Driver.FindElement(By.Id("TargetCurrency")).Clear(); - s.Driver.FindElement(By.Id("TargetCurrency")).SendKeys("JPY"); + s.Driver.FindElement(By.Id("TargetCurrency")).SendKeys("EUR"); s.Driver.FindElement(By.Id("TargetAmount")).SendKeys("700"); // test wrong dates @@ -1122,7 +1122,8 @@ namespace BTCPayServer.Tests s.Driver.FindElement(By.Id("SaveSettings")).Click(); Assert.Contains("App updated", s.FindAlertMessage().Text); var appId = s.Driver.Url.Split('/')[4]; - + + // CHeck public page s.Driver.FindElement(By.Id("ViewApp")).Click(); var windows = s.Driver.WindowHandles; Assert.Equal(2, windows.Count); @@ -1132,6 +1133,26 @@ namespace BTCPayServer.Tests Assert.Equal("Currently active!", s.Driver.FindElement(By.CssSelector("[data-test='time-state']")).Text); + // Contribute + s.Driver.FindElement(By.Id("crowdfund-body-header-cta")).Click(); + Thread.Sleep(1000); + s.Driver.WaitUntilAvailable(By.Name("btcpay")); + + var frameElement = s.Driver.FindElement(By.Name("btcpay")); + Assert.True(frameElement.Displayed); + var iframe = s.Driver.SwitchTo().Frame(frameElement); + iframe.WaitUntilAvailable(By.Id("Checkout-v2")); + + IWebElement closebutton = null; + TestUtils.Eventually(() => + { + closebutton = iframe.FindElement(By.Id("close")); + Assert.True(closebutton.Displayed); + }); + closebutton.Click(); + s.Driver.AssertElementNotFound(By.Name("btcpay")); + + // Back to admin view s.Driver.Close(); s.Driver.SwitchTo().Window(windows[0]); diff --git a/BTCPayServer/Views/Shared/Crowdfund/Public/ViewCrowdfund.cshtml b/BTCPayServer/Views/Shared/Crowdfund/Public/ViewCrowdfund.cshtml index 294f1a964..8393a8c89 100644 --- a/BTCPayServer/Views/Shared/Crowdfund/Public/ViewCrowdfund.cshtml +++ b/BTCPayServer/Views/Shared/Crowdfund/Public/ViewCrowdfund.cshtml @@ -211,11 +211,11 @@
- +
-