mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 22:11:48 +01:00
* Excerpts from #971 Relating to selenium tests + small renamings * fix build
This commit is contained in:
parent
8f464b0838
commit
7208e63155
9 changed files with 68 additions and 39 deletions
|
@ -56,7 +56,6 @@ namespace BTCPayServer
|
||||||
InitFeathercoin();
|
InitFeathercoin();
|
||||||
InitGroestlcoin();
|
InitGroestlcoin();
|
||||||
InitViacoin();
|
InitViacoin();
|
||||||
|
|
||||||
// Assume that electrum mappings are same as BTC if not specified
|
// Assume that electrum mappings are same as BTC if not specified
|
||||||
foreach (var network in _Networks.Values.OfType<BTCPayNetwork>())
|
foreach (var network in _Networks.Values.OfType<BTCPayNetwork>())
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,14 +67,15 @@ namespace BTCPayServer.Tests
|
||||||
return usr;
|
return usr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string CreateNewStore()
|
public (string storeName, string storeId) CreateNewStore()
|
||||||
{
|
{
|
||||||
var usr = "Store" + RandomUtils.GetUInt64().ToString();
|
var usr = "Store" + RandomUtils.GetUInt64().ToString();
|
||||||
Driver.FindElement(By.Id("Stores")).Click();
|
Driver.FindElement(By.Id("Stores")).Click();
|
||||||
Driver.FindElement(By.Id("CreateStore")).Click();
|
Driver.FindElement(By.Id("CreateStore")).Click();
|
||||||
Driver.FindElement(By.Id("Name")).SendKeys(usr);
|
Driver.FindElement(By.Id("Name")).SendKeys(usr);
|
||||||
Driver.FindElement(By.Id("Create")).Click();
|
Driver.FindElement(By.Id("Create")).Click();
|
||||||
return usr;
|
|
||||||
|
return (usr, Driver.FindElement(By.Id("Id")).GetAttribute("value"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddDerivationScheme(string derivationScheme = "xpub661MyMwAqRbcGABgHMUXDzPzH1tU7eZaAaJQXhDXsSxsqyQzQeU6kznNfSuAyqAK9UaWSaZaMFdNiY5BCF4zBPAzSnwfUAwUhwttuAKwfRX-[legacy]")
|
public void AddDerivationScheme(string derivationScheme = "xpub661MyMwAqRbcGABgHMUXDzPzH1tU7eZaAaJQXhDXsSxsqyQzQeU6kznNfSuAyqAK9UaWSaZaMFdNiY5BCF4zBPAzSnwfUAwUhwttuAKwfRX-[legacy]")
|
||||||
|
@ -99,14 +100,24 @@ namespace BTCPayServer.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateInvoice(string random)
|
public string CreateInvoice(string random, string refundEmail = "")
|
||||||
{
|
{
|
||||||
Driver.FindElement(By.Id("Invoices")).Click();
|
Driver.FindElement(By.Id("Invoices")).Click();
|
||||||
Driver.FindElement(By.Id("CreateNewInvoice")).Click();
|
Driver.FindElement(By.Id("CreateNewInvoice")).Click();
|
||||||
Driver.FindElement(By.CssSelector("input#Amount.form-control")).SendKeys("100");
|
Driver.FindElement(By.CssSelector("input#Amount.form-control")).SendKeys("100");
|
||||||
Driver.FindElement(By.Name("StoreId")).SendKeys("Deriv" + random + Keys.Enter);
|
Driver.FindElement(By.Name("StoreId")).SendKeys("Deriv" + random + Keys.Enter);
|
||||||
Driver.FindElement(By.Id("Create")).Click();
|
Driver.FindElement(By.Id("Create")).Click();
|
||||||
return;
|
var statusElement = Driver.FindElement(By.ClassName("alert-success"));
|
||||||
|
var id = statusElement.Text.Split(" ")[1];
|
||||||
|
if (!string.IsNullOrEmpty(refundEmail))
|
||||||
|
{
|
||||||
|
GoToInvoiceCheckout(id);
|
||||||
|
Driver.FindElement(By.Id("emailAddressFormInput")).SendKeys(refundEmail);
|
||||||
|
Driver.FindElement(By.Id("emailAddressForm")).FindElement(By.CssSelector("button.action-button"))
|
||||||
|
.Click();
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,5 +158,31 @@ namespace BTCPayServer.Tests
|
||||||
Driver.FindElement(By.Id("LoginButton")).Click();
|
Driver.FindElement(By.Id("LoginButton")).Click();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GoToStore(string storeId)
|
||||||
|
{
|
||||||
|
Driver.FindElement(By.Id("Stores")).Click();
|
||||||
|
Driver.FindElement(By.Id($"update-store-{storeId}")).Click();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GoToInvoiceCheckout(string invoiceId)
|
||||||
|
{
|
||||||
|
Driver.FindElement(By.Id("Invoices")).Click();
|
||||||
|
Driver.FindElement(By.Id($"invoice-checkout-{invoiceId}")).Click();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void SetCheckbox(IWebElement element, bool value)
|
||||||
|
{
|
||||||
|
if ((value && !element.Selected) || (!value && element.Selected))
|
||||||
|
{
|
||||||
|
element.Click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetCheckbox(SeleniumTester s, string inputName, bool value)
|
||||||
|
{
|
||||||
|
SetCheckbox(s.Driver.FindElement(By.Name(inputName)), value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ namespace BTCPayServer.Tests
|
||||||
{
|
{
|
||||||
s.Start();
|
s.Start();
|
||||||
var alice = s.RegisterNewUser();
|
var alice = s.RegisterNewUser();
|
||||||
var store = s.CreateNewStore();
|
var store = s.CreateNewStore().storeName;
|
||||||
s.AddDerivationScheme();
|
s.AddDerivationScheme();
|
||||||
s.Driver.AssertNoError();
|
s.Driver.AssertNoError();
|
||||||
Assert.Contains(store, s.Driver.PageSource);
|
Assert.Contains(store, s.Driver.PageSource);
|
||||||
|
@ -201,7 +201,7 @@ namespace BTCPayServer.Tests
|
||||||
{
|
{
|
||||||
s.Start();
|
s.Start();
|
||||||
s.RegisterNewUser();
|
s.RegisterNewUser();
|
||||||
var store = s.CreateNewStore();
|
var store = s.CreateNewStore().storeName;
|
||||||
s.AddDerivationScheme();
|
s.AddDerivationScheme();
|
||||||
|
|
||||||
CreateInvoice(s, store);
|
CreateInvoice(s, store);
|
||||||
|
@ -236,11 +236,11 @@ namespace BTCPayServer.Tests
|
||||||
|
|
||||||
s.Driver.FindElement(By.Id("Apps")).Click();
|
s.Driver.FindElement(By.Id("Apps")).Click();
|
||||||
s.Driver.FindElement(By.Id("CreateNewApp")).Click();
|
s.Driver.FindElement(By.Id("CreateNewApp")).Click();
|
||||||
s.Driver.FindElement(By.Name("Name")).SendKeys("PoS" + store);
|
s.Driver.FindElement(By.Name("Name")).SendKeys("PoS" + Guid.NewGuid());
|
||||||
s.Driver.FindElement(By.CssSelector("select#SelectedAppType.form-control")).SendKeys("PointOfSale" + Keys.Enter);
|
s.Driver.FindElement(By.Id("SelectedAppType")).SendKeys("PointOfSale" + Keys.Enter);
|
||||||
s.Driver.FindElement(By.CssSelector("select#SelectedStore.form-control")).SendKeys(store + Keys.Enter);
|
s.Driver.FindElement(By.Id("SelectedStore")).SendKeys(store + Keys.Enter);
|
||||||
s.Driver.FindElement(By.Id("Create")).Click();
|
s.Driver.FindElement(By.Id("Create")).Click();
|
||||||
s.Driver.FindElement(By.CssSelector("input#EnableShoppingCart.form-check")).Click();
|
s.Driver.FindElement(By.Id("EnableShoppingCart")).Click();
|
||||||
s.Driver.FindElement(By.Id("SaveSettings")).ForceClick();
|
s.Driver.FindElement(By.Id("SaveSettings")).ForceClick();
|
||||||
s.Driver.FindElement(By.Id("ViewApp")).ForceClick();
|
s.Driver.FindElement(By.Id("ViewApp")).ForceClick();
|
||||||
s.Driver.SwitchTo().Window(s.Driver.WindowHandles.Last());
|
s.Driver.SwitchTo().Window(s.Driver.WindowHandles.Last());
|
||||||
|
@ -261,9 +261,9 @@ namespace BTCPayServer.Tests
|
||||||
|
|
||||||
s.Driver.FindElement(By.Id("Apps")).Click();
|
s.Driver.FindElement(By.Id("Apps")).Click();
|
||||||
s.Driver.FindElement(By.Id("CreateNewApp")).Click();
|
s.Driver.FindElement(By.Id("CreateNewApp")).Click();
|
||||||
s.Driver.FindElement(By.Name("Name")).SendKeys("CF" + store);
|
s.Driver.FindElement(By.Name("Name")).SendKeys("CF" + Guid.NewGuid());
|
||||||
s.Driver.FindElement(By.CssSelector("select#SelectedAppType.form-control")).SendKeys("Crowdfund" + Keys.Enter);
|
s.Driver.FindElement(By.Id("SelectedAppType")).SendKeys("Crowdfund" + Keys.Enter);
|
||||||
s.Driver.FindElement(By.CssSelector("select#SelectedStore.form-control")).SendKeys(store + Keys.Enter);
|
s.Driver.FindElement(By.Id("SelectedStore")).SendKeys(store + Keys.Enter);
|
||||||
s.Driver.FindElement(By.Id("Create")).Click();
|
s.Driver.FindElement(By.Id("Create")).Click();
|
||||||
s.Driver.FindElement(By.Id("Title")).SendKeys("Kukkstarter");
|
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.CssSelector("div.note-editable.card-block")).SendKeys("1BTC = 1BTC");
|
||||||
|
|
|
@ -506,7 +506,7 @@ namespace BTCPayServer.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
var changellyEnabled = storeBlob.ChangellySettings != null && storeBlob.ChangellySettings.Enabled;
|
var changellyEnabled = storeBlob.ChangellySettings != null && storeBlob.ChangellySettings.Enabled;
|
||||||
vm.ThirdPartyPaymentMethods.Add(new StoreViewModel.ThirdPartyPaymentMethod()
|
vm.ThirdPartyPaymentMethods.Add(new StoreViewModel.AdditionalPaymentMethod()
|
||||||
{
|
{
|
||||||
Enabled = changellyEnabled,
|
Enabled = changellyEnabled,
|
||||||
Action = nameof(UpdateChangellySettings),
|
Action = nameof(UpdateChangellySettings),
|
||||||
|
@ -514,7 +514,7 @@ namespace BTCPayServer.Controllers
|
||||||
});
|
});
|
||||||
|
|
||||||
var coinSwitchEnabled = storeBlob.CoinSwitchSettings != null && storeBlob.CoinSwitchSettings.Enabled;
|
var coinSwitchEnabled = storeBlob.CoinSwitchSettings != null && storeBlob.CoinSwitchSettings.Enabled;
|
||||||
vm.ThirdPartyPaymentMethods.Add(new StoreViewModel.ThirdPartyPaymentMethod()
|
vm.ThirdPartyPaymentMethods.Add(new StoreViewModel.AdditionalPaymentMethod()
|
||||||
{
|
{
|
||||||
Enabled = coinSwitchEnabled,
|
Enabled = coinSwitchEnabled,
|
||||||
Action = nameof(UpdateCoinSwitchSettings),
|
Action = nameof(UpdateCoinSwitchSettings),
|
||||||
|
|
|
@ -1,14 +1,7 @@
|
||||||
using BTCPayServer.Data;
|
using BTCPayServer.Validation;
|
||||||
using BTCPayServer.Services;
|
|
||||||
using BTCPayServer.Services.Invoices;
|
|
||||||
using BTCPayServer.Services.Rates;
|
|
||||||
using BTCPayServer.Validation;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using BTCPayServer.Data;
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace BTCPayServer.Models.StoreViewModels
|
namespace BTCPayServer.Models.StoreViewModels
|
||||||
{
|
{
|
||||||
|
@ -22,7 +15,7 @@ namespace BTCPayServer.Models.StoreViewModels
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ThirdPartyPaymentMethod
|
public class AdditionalPaymentMethod
|
||||||
{
|
{
|
||||||
public string Provider { get; set; }
|
public string Provider { get; set; }
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
|
@ -58,8 +51,8 @@ namespace BTCPayServer.Models.StoreViewModels
|
||||||
|
|
||||||
public List<StoreViewModel.DerivationScheme> DerivationSchemes { get; set; } = new List<StoreViewModel.DerivationScheme>();
|
public List<StoreViewModel.DerivationScheme> DerivationSchemes { get; set; } = new List<StoreViewModel.DerivationScheme>();
|
||||||
|
|
||||||
public List<ThirdPartyPaymentMethod> ThirdPartyPaymentMethods { get; set; } =
|
public List<AdditionalPaymentMethod> ThirdPartyPaymentMethods { get; set; } =
|
||||||
new List<ThirdPartyPaymentMethod>();
|
new List<AdditionalPaymentMethod>();
|
||||||
|
|
||||||
[Display(Name = "Invoice expires if the full amount has not been paid after ... minutes")]
|
[Display(Name = "Invoice expires if the full amount has not been paid after ... minutes")]
|
||||||
[Range(1, 60 * 24 * 24)]
|
[Range(1, 60 * 24 * 24)]
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
{
|
{
|
||||||
<th class="text-right">Overpaid</th>
|
<th class="text-right">Overpaid</th>
|
||||||
}
|
}
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var payment in Model.CryptoPayments)
|
@foreach (var payment in Model.CryptoPayments)
|
||||||
|
|
|
@ -245,7 +245,7 @@
|
||||||
@if (invoice.ShowCheckout)
|
@if (invoice.ShowCheckout)
|
||||||
{
|
{
|
||||||
<span>
|
<span>
|
||||||
<a asp-action="Checkout" class="invoice-checkout-link" asp-route-invoiceId="@invoice.InvoiceId">Checkout</a>
|
<a asp-action="Checkout" class="invoice-checkout-link" id="invoice-checkout-@invoice.InvoiceId" asp-route-invoiceId="@invoice.InvoiceId">Checkout</a>
|
||||||
<a href="javascript:btcpay.showInvoice('@invoice.InvoiceId')">[^]</a>
|
<a href="javascript:btcpay.showInvoice('@invoice.InvoiceId')">[^]</a>
|
||||||
@if (!invoice.CanMarkStatus)
|
@if (!invoice.CanMarkStatus)
|
||||||
{
|
{
|
||||||
|
|
|
@ -180,24 +180,24 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<h5>Third party Payment methods</h5>
|
<h5>Additional Payment methods</h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<table class="table table-sm table-responsive-md">
|
<table class="table table-sm table-responsive-md">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Provider</th>
|
<th>Provider</th>
|
||||||
<th style="text-align:center;">Enabled</th>
|
<th class="text-center">Enabled</th>
|
||||||
<th style="text-align:right">Actions</th>
|
<th class="text-right">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach(var scheme in Model.ThirdPartyPaymentMethods)
|
@foreach (var scheme in Model.ThirdPartyPaymentMethods)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr>
|
||||||
<td>@scheme.Provider</td>
|
<td>@scheme.Provider</td>
|
||||||
<td style="text-align:center;">
|
<td class="text-center">
|
||||||
@if(scheme.Enabled)
|
@if (scheme.Enabled)
|
||||||
{
|
{
|
||||||
<span class="fa fa-check"></span>
|
<span class="fa fa-check"></span>
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@
|
||||||
<span class="fa fa-times"></span>
|
<span class="fa fa-times"></span>
|
||||||
}
|
}
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align:right"><a asp-action="@scheme.Action" >Modify</a></td>
|
<td class="text-right"><a asp-action="@scheme.Action" id='Modify-@scheme.Provider'>Modify</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (var store in Model.Stores)
|
@foreach (var store in Model.Stores)
|
||||||
{
|
{
|
||||||
<tr>
|
<tr id="store-@store.Id">
|
||||||
<td>@store.Name</td>
|
<td>@store.Name</td>
|
||||||
<td>
|
<td>
|
||||||
@if (!string.IsNullOrEmpty(store.WebSite))
|
@if (!string.IsNullOrEmpty(store.WebSite))
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
<a asp-action="ListInvoices" asp-controller="Invoice" asp-route-searchTerm="storeid:@store.Id">Invoices</a><span> - </span>
|
<a asp-action="ListInvoices" asp-controller="Invoice" asp-route-searchTerm="storeid:@store.Id">Invoices</a><span> - </span>
|
||||||
@if (store.IsOwner)
|
@if (store.IsOwner)
|
||||||
{
|
{
|
||||||
<a asp-action="UpdateStore" asp-controller="Stores" asp-route-storeId="@store.Id">Settings</a><span> - </span>
|
<a asp-action="UpdateStore" asp-controller="Stores" asp-route-storeId="@store.Id" id="update-store-@store.Id">Settings</a><span> - </span>
|
||||||
}
|
}
|
||||||
<a asp-action="DeleteStore" asp-route-storeId="@store.Id">Remove</a>
|
<a asp-action="DeleteStore" asp-route-storeId="@store.Id">Remove</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Add table
Reference in a new issue