mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 14:04:12 +01:00
Make tips and discount properties disabled in POS setting (#5619)
* Make tips and discount properties disabled in POS setting * Update discount and tips boolean properties in model and swagger json * update pos tests to cater for default tip and discount state * Remove custom IDs and unify tests --------- Co-authored-by: Dennis Reimann <mail@dennisreimann.de>
This commit is contained in:
parent
c7eef01fd5
commit
b5405e9313
4 changed files with 27 additions and 13 deletions
|
@ -27,10 +27,10 @@ namespace BTCPayServer.Client.Models
|
||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
public PosViewType DefaultView { get; set; }
|
public PosViewType DefaultView { get; set; }
|
||||||
public bool ShowCustomAmount { get; set; } = false;
|
public bool ShowCustomAmount { get; set; } = false;
|
||||||
public bool ShowDiscount { get; set; } = true;
|
public bool ShowDiscount { get; set; } = false;
|
||||||
public bool ShowSearch { get; set; } = true;
|
public bool ShowSearch { get; set; } = true;
|
||||||
public bool ShowCategories { get; set; } = true;
|
public bool ShowCategories { get; set; } = true;
|
||||||
public bool EnableTips { get; set; } = true;
|
public bool EnableTips { get; set; } = false;
|
||||||
public string CustomAmountPayButtonText { get; set; } = null;
|
public string CustomAmountPayButtonText { get; set; } = null;
|
||||||
public string FixedAmountPayButtonText { get; set; } = null;
|
public string FixedAmountPayButtonText { get; set; } = null;
|
||||||
public string TipText { get; set; } = null;
|
public string TipText { get; set; } = null;
|
||||||
|
|
|
@ -2326,7 +2326,6 @@ namespace BTCPayServer.Tests
|
||||||
s.Server.ActivateLightning();
|
s.Server.ActivateLightning();
|
||||||
await s.StartAsync();
|
await s.StartAsync();
|
||||||
await s.Server.EnsureChannelsSetup();
|
await s.Server.EnsureChannelsSetup();
|
||||||
|
|
||||||
s.RegisterNewUser(true);
|
s.RegisterNewUser(true);
|
||||||
s.CreateNewStore();
|
s.CreateNewStore();
|
||||||
s.GoToStore();
|
s.GoToStore();
|
||||||
|
@ -2337,8 +2336,15 @@ namespace BTCPayServer.Tests
|
||||||
TestUtils.Eventually(() => Assert.Contains("App successfully created", s.FindAlertMessage().Text));
|
TestUtils.Eventually(() => Assert.Contains("App successfully created", s.FindAlertMessage().Text));
|
||||||
s.Driver.FindElement(By.CssSelector("label[for='DefaultView_Light']")).Click();
|
s.Driver.FindElement(By.CssSelector("label[for='DefaultView_Light']")).Click();
|
||||||
s.Driver.FindElement(By.Id("Currency")).SendKeys("EUR");
|
s.Driver.FindElement(By.Id("Currency")).SendKeys("EUR");
|
||||||
|
|
||||||
|
Assert.False(s.Driver.FindElement(By.Id("EnableTips")).Selected);
|
||||||
|
s.Driver.FindElement(By.Id("EnableTips")).Click();
|
||||||
|
Assert.True(s.Driver.FindElement(By.Id("EnableTips")).Selected);
|
||||||
|
Thread.Sleep(250);
|
||||||
s.Driver.FindElement(By.Id("CustomTipPercentages")).Clear();
|
s.Driver.FindElement(By.Id("CustomTipPercentages")).Clear();
|
||||||
s.Driver.FindElement(By.Id("CustomTipPercentages")).SendKeys("10,21");
|
s.Driver.FindElement(By.Id("CustomTipPercentages")).SendKeys("10,21");
|
||||||
|
Assert.False(s.Driver.FindElement(By.Id("ShowDiscount")).Selected);
|
||||||
|
s.Driver.FindElement(By.Id("ShowDiscount")).Click();
|
||||||
s.Driver.FindElement(By.Id("SaveSettings")).Click();
|
s.Driver.FindElement(By.Id("SaveSettings")).Click();
|
||||||
Assert.Contains("App updated", s.FindAlertMessage().Text);
|
Assert.Contains("App updated", s.FindAlertMessage().Text);
|
||||||
s.Driver.FindElement(By.Id("ViewApp")).Click();
|
s.Driver.FindElement(By.Id("ViewApp")).Click();
|
||||||
|
@ -2346,7 +2352,7 @@ namespace BTCPayServer.Tests
|
||||||
Assert.Equal(2, windows.Count);
|
Assert.Equal(2, windows.Count);
|
||||||
s.Driver.SwitchTo().Window(windows[1]);
|
s.Driver.SwitchTo().Window(windows[1]);
|
||||||
s.Driver.WaitForElement(By.ClassName("keypad"));
|
s.Driver.WaitForElement(By.ClassName("keypad"));
|
||||||
|
|
||||||
// basic checks
|
// basic checks
|
||||||
Assert.Contains("EUR", s.Driver.FindElement(By.Id("Currency")).Text);
|
Assert.Contains("EUR", s.Driver.FindElement(By.Id("Currency")).Text);
|
||||||
Assert.Contains("0,00", s.Driver.FindElement(By.Id("Amount")).Text);
|
Assert.Contains("0,00", s.Driver.FindElement(By.Id("Amount")).Text);
|
||||||
|
@ -2354,7 +2360,7 @@ namespace BTCPayServer.Tests
|
||||||
Assert.True(s.Driver.FindElement(By.Id("ModeTablist-amounts")).Selected);
|
Assert.True(s.Driver.FindElement(By.Id("ModeTablist-amounts")).Selected);
|
||||||
Assert.False(s.Driver.FindElement(By.Id("ModeTablist-discount")).Enabled);
|
Assert.False(s.Driver.FindElement(By.Id("ModeTablist-discount")).Enabled);
|
||||||
Assert.False(s.Driver.FindElement(By.Id("ModeTablist-tip")).Enabled);
|
Assert.False(s.Driver.FindElement(By.Id("ModeTablist-tip")).Enabled);
|
||||||
|
|
||||||
// Amount: 1234,56
|
// Amount: 1234,56
|
||||||
s.Driver.FindElement(By.CssSelector(".keypad [data-key='1']")).Click();
|
s.Driver.FindElement(By.CssSelector(".keypad [data-key='1']")).Click();
|
||||||
s.Driver.FindElement(By.CssSelector(".keypad [data-key='2']")).Click();
|
s.Driver.FindElement(By.CssSelector(".keypad [data-key='2']")).Click();
|
||||||
|
@ -2371,7 +2377,7 @@ namespace BTCPayServer.Tests
|
||||||
Assert.True(s.Driver.FindElement(By.Id("ModeTablist-discount")).Enabled);
|
Assert.True(s.Driver.FindElement(By.Id("ModeTablist-discount")).Enabled);
|
||||||
Assert.True(s.Driver.FindElement(By.Id("ModeTablist-tip")).Enabled);
|
Assert.True(s.Driver.FindElement(By.Id("ModeTablist-tip")).Enabled);
|
||||||
Assert.Equal("1.234,00 € + 0,56 €", s.Driver.FindElement(By.Id("Calculation")).Text);
|
Assert.Equal("1.234,00 € + 0,56 €", s.Driver.FindElement(By.Id("Calculation")).Text);
|
||||||
|
|
||||||
// Discount: 10%
|
// Discount: 10%
|
||||||
s.Driver.FindElement(By.CssSelector("label[for='ModeTablist-discount']")).Click();
|
s.Driver.FindElement(By.CssSelector("label[for='ModeTablist-discount']")).Click();
|
||||||
s.Driver.FindElement(By.CssSelector(".keypad [data-key='1']")).Click();
|
s.Driver.FindElement(By.CssSelector(".keypad [data-key='1']")).Click();
|
||||||
|
@ -2379,14 +2385,14 @@ namespace BTCPayServer.Tests
|
||||||
Assert.Contains("1.111,10", s.Driver.FindElement(By.Id("Amount")).Text);
|
Assert.Contains("1.111,10", s.Driver.FindElement(By.Id("Amount")).Text);
|
||||||
Assert.Contains("10% discount", s.Driver.FindElement(By.Id("Discount")).Text);
|
Assert.Contains("10% discount", s.Driver.FindElement(By.Id("Discount")).Text);
|
||||||
Assert.Contains("1.234,00 € + 0,56 € - 123,46 € (10%)", s.Driver.FindElement(By.Id("Calculation")).Text);
|
Assert.Contains("1.234,00 € + 0,56 € - 123,46 € (10%)", s.Driver.FindElement(By.Id("Calculation")).Text);
|
||||||
|
|
||||||
// Tip: 10%
|
// Tip: 10%
|
||||||
s.Driver.FindElement(By.CssSelector("label[for='ModeTablist-tip']")).Click();
|
s.Driver.FindElement(By.CssSelector("label[for='ModeTablist-tip']")).Click();
|
||||||
s.Driver.WaitForElement(By.Id("Tip-Custom"));
|
s.Driver.WaitForElement(By.Id("Tip-Custom"));
|
||||||
s.Driver.FindElement(By.Id("Tip-10")).Click();
|
s.Driver.FindElement(By.Id("Tip-10")).Click();
|
||||||
Assert.Contains("1.222,21", s.Driver.FindElement(By.Id("Amount")).Text);
|
Assert.Contains("1.222,21", s.Driver.FindElement(By.Id("Amount")).Text);
|
||||||
Assert.Contains("1.234,00 € + 0,56 € - 123,46 € (10%) + 111,11 € (10%)", s.Driver.FindElement(By.Id("Calculation")).Text);
|
Assert.Contains("1.234,00 € + 0,56 € - 123,46 € (10%) + 111,11 € (10%)", s.Driver.FindElement(By.Id("Calculation")).Text);
|
||||||
|
|
||||||
// Pay
|
// Pay
|
||||||
s.Driver.FindElement(By.Id("pay-button")).Click();
|
s.Driver.FindElement(By.Id("pay-button")).Click();
|
||||||
s.Driver.WaitUntilAvailable(By.Id("Checkout-v2"));
|
s.Driver.WaitUntilAvailable(By.Id("Checkout-v2"));
|
||||||
|
@ -2415,8 +2421,14 @@ namespace BTCPayServer.Tests
|
||||||
Assert.Contains("App successfully created", s.FindAlertMessage().Text);
|
Assert.Contains("App successfully created", s.FindAlertMessage().Text);
|
||||||
s.Driver.FindElement(By.CssSelector("label[for='DefaultView_Cart']")).Click();
|
s.Driver.FindElement(By.CssSelector("label[for='DefaultView_Cart']")).Click();
|
||||||
s.Driver.FindElement(By.Id("Currency")).SendKeys("EUR");
|
s.Driver.FindElement(By.Id("Currency")).SendKeys("EUR");
|
||||||
|
Assert.False(s.Driver.FindElement(By.Id("EnableTips")).Selected);
|
||||||
|
s.Driver.FindElement(By.Id("EnableTips")).Click();
|
||||||
|
Assert.True(s.Driver.FindElement(By.Id("EnableTips")).Selected);
|
||||||
|
Thread.Sleep(250);
|
||||||
s.Driver.FindElement(By.Id("CustomTipPercentages")).Clear();
|
s.Driver.FindElement(By.Id("CustomTipPercentages")).Clear();
|
||||||
s.Driver.FindElement(By.Id("CustomTipPercentages")).SendKeys("10,21");
|
s.Driver.FindElement(By.Id("CustomTipPercentages")).SendKeys("10,21");
|
||||||
|
Assert.False(s.Driver.FindElement(By.Id("ShowDiscount")).Selected);
|
||||||
|
s.Driver.FindElement(By.Id("ShowDiscount")).Click();
|
||||||
s.Driver.FindElement(By.Id("SaveSettings")).Click();
|
s.Driver.FindElement(By.Id("SaveSettings")).Click();
|
||||||
Assert.Contains("App updated", s.FindAlertMessage().Text);
|
Assert.Contains("App updated", s.FindAlertMessage().Text);
|
||||||
s.Driver.FindElement(By.Id("ViewApp")).Click();
|
s.Driver.FindElement(By.Id("ViewApp")).Click();
|
||||||
|
@ -2483,19 +2495,19 @@ namespace BTCPayServer.Tests
|
||||||
Thread.Sleep(250);
|
Thread.Sleep(250);
|
||||||
Assert.Equal(7, s.Driver.FindElements(By.CssSelector("#CartItems tr")).Count);
|
Assert.Equal(7, s.Driver.FindElements(By.CssSelector("#CartItems tr")).Count);
|
||||||
Assert.Equal("10,00 €", s.Driver.FindElement(By.Id("CartTotal")).Text);
|
Assert.Equal("10,00 €", s.Driver.FindElement(By.Id("CartTotal")).Text);
|
||||||
|
|
||||||
// Discount: 10%
|
// Discount: 10%
|
||||||
s.Driver.ElementDoesNotExist(By.Id("CartDiscount"));
|
s.Driver.ElementDoesNotExist(By.Id("CartDiscount"));
|
||||||
s.Driver.FindElement(By.Id("Discount")).SendKeys("10");
|
s.Driver.FindElement(By.Id("Discount")).SendKeys("10");
|
||||||
Assert.Contains("10% = 1,00 €", s.Driver.FindElement(By.Id("CartDiscount")).Text);
|
Assert.Contains("10% = 1,00 €", s.Driver.FindElement(By.Id("CartDiscount")).Text);
|
||||||
Assert.Equal("9,00 €", s.Driver.FindElement(By.Id("CartTotal")).Text);
|
Assert.Equal("9,00 €", s.Driver.FindElement(By.Id("CartTotal")).Text);
|
||||||
|
|
||||||
// Tip: 10%
|
// Tip: 10%
|
||||||
s.Driver.ElementDoesNotExist(By.Id("CartTip"));
|
s.Driver.ElementDoesNotExist(By.Id("CartTip"));
|
||||||
s.Driver.FindElement(By.Id("Tip-10")).Click();
|
s.Driver.FindElement(By.Id("Tip-10")).Click();
|
||||||
Assert.Contains("10% = 0,90 €", s.Driver.FindElement(By.Id("CartTip")).Text);
|
Assert.Contains("10% = 0,90 €", s.Driver.FindElement(By.Id("CartTip")).Text);
|
||||||
Assert.Equal("9,90 €", s.Driver.FindElement(By.Id("CartTotal")).Text);
|
Assert.Equal("9,90 €", s.Driver.FindElement(By.Id("CartTotal")).Text);
|
||||||
|
|
||||||
// Check values on checkout page
|
// Check values on checkout page
|
||||||
s.Driver.FindElement(By.Id("CartSubmit")).Click();
|
s.Driver.FindElement(By.Id("CartSubmit")).Click();
|
||||||
s.Driver.WaitUntilAvailable(By.Id("Checkout-v2"));
|
s.Driver.WaitUntilAvailable(By.Id("Checkout-v2"));
|
||||||
|
|
|
@ -76,10 +76,10 @@ namespace BTCPayServer.Services.Apps
|
||||||
});
|
});
|
||||||
DefaultView = PosViewType.Static;
|
DefaultView = PosViewType.Static;
|
||||||
ShowCustomAmount = false;
|
ShowCustomAmount = false;
|
||||||
ShowDiscount = true;
|
ShowDiscount = false;
|
||||||
ShowSearch = true;
|
ShowSearch = true;
|
||||||
ShowCategories = true;
|
ShowCategories = true;
|
||||||
EnableTips = true;
|
EnableTips = false;
|
||||||
RequiresRefundEmail = RequiresRefundEmail.InheritFromStore;
|
RequiresRefundEmail = RequiresRefundEmail.InheritFromStore;
|
||||||
}
|
}
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
|
|
|
@ -466,6 +466,7 @@
|
||||||
"example": true
|
"example": true
|
||||||
},
|
},
|
||||||
"showDiscount": {
|
"showDiscount": {
|
||||||
|
"default": false,
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Whether the option to enter a discount is shown",
|
"description": "Whether the option to enter a discount is shown",
|
||||||
"example": false
|
"example": false
|
||||||
|
@ -483,6 +484,7 @@
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
"enableTips": {
|
"enableTips": {
|
||||||
|
"default": false,
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Whether the option to enter a tip is shown",
|
"description": "Whether the option to enter a tip is shown",
|
||||||
"example": true
|
"example": true
|
||||||
|
|
Loading…
Add table
Reference in a new issue