mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 21:32:27 +01:00
Click around in selenium, and do not forget to run the selenium tests on circleCI
This commit is contained in:
parent
27fd49e61c
commit
cd6dd78759
@ -3,12 +3,17 @@ using System.Collections.Generic;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using OpenQA.Selenium;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace BTCPayServer.Tests
|
namespace BTCPayServer.Tests
|
||||||
{
|
{
|
||||||
public static class Extensions
|
public static class Extensions
|
||||||
{
|
{
|
||||||
|
public static void AssertNoError(this IWebDriver driver)
|
||||||
|
{
|
||||||
|
Assert.NotNull(driver.FindElement(By.ClassName("navbar-brand")));
|
||||||
|
}
|
||||||
public static T AssertViewModel<T>(this IActionResult result)
|
public static T AssertViewModel<T>(this IActionResult result)
|
||||||
{
|
{
|
||||||
Assert.NotNull(result);
|
Assert.NotNull(result);
|
||||||
|
@ -6,6 +6,7 @@ using BTCPayServer.Tests.Logging;
|
|||||||
using Xunit.Abstractions;
|
using Xunit.Abstractions;
|
||||||
using OpenQA.Selenium.Interactions;
|
using OpenQA.Selenium.Interactions;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using NBitcoin;
|
||||||
|
|
||||||
namespace BTCPayServer.Tests
|
namespace BTCPayServer.Tests
|
||||||
{
|
{
|
||||||
@ -24,6 +25,9 @@ namespace BTCPayServer.Tests
|
|||||||
using (var tester = ServerTester.Create())
|
using (var tester = ServerTester.Create())
|
||||||
{
|
{
|
||||||
tester.Start();
|
tester.Start();
|
||||||
|
var logOut = Driver.FindElements(By.Id("Logout"));
|
||||||
|
if (logOut.Count != 0)
|
||||||
|
logOut[0].Click();
|
||||||
func.Invoke(tester.PayTester.ServerUri.ToString());
|
func.Invoke(tester.PayTester.ServerUri.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,23 +43,27 @@ namespace BTCPayServer.Tests
|
|||||||
Driver = new ChromeDriver(Environment.CurrentDirectory, options);
|
Driver = new ChromeDriver(Environment.CurrentDirectory, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterNewUser(string random)
|
public string RegisterNewUser(bool isAdmin = false)
|
||||||
{
|
{
|
||||||
|
var usr = RandomUtils.GetUInt256().ToString() + "@a.com";
|
||||||
Driver.FindElement(By.Id("Register")).Click();
|
Driver.FindElement(By.Id("Register")).Click();
|
||||||
Driver.FindElement(By.Id("Email")).SendKeys(random + "@a.com");
|
Driver.FindElement(By.Id("Email")).SendKeys(usr);
|
||||||
Driver.FindElement(By.Id("Password")).SendKeys("123456");
|
Driver.FindElement(By.Id("Password")).SendKeys("123456");
|
||||||
Driver.FindElement(By.Id("ConfirmPassword")).SendKeys("123456");
|
Driver.FindElement(By.Id("ConfirmPassword")).SendKeys("123456");
|
||||||
|
Driver.FindElement(By.Id("IsAdmin")).Click();
|
||||||
Driver.FindElement(By.Id("RegisterButton")).Click();
|
Driver.FindElement(By.Id("RegisterButton")).Click();
|
||||||
return;
|
Driver.AssertNoError();
|
||||||
|
return usr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateNewStore(string random)
|
public string CreateNewStore()
|
||||||
{
|
{
|
||||||
|
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("Store" + random);
|
Driver.FindElement(By.Id("Name")).SendKeys(usr);
|
||||||
Driver.FindElement(By.Id("Create")).Click();
|
Driver.FindElement(By.Id("Create")).Click();
|
||||||
return;
|
return usr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddDerivationScheme()
|
public void AddDerivationScheme()
|
||||||
@ -80,9 +88,9 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Trait("Selenium", "Selenium")]
|
||||||
public class ChromeTests : Browsers
|
public class ChromeTests : Browsers
|
||||||
{
|
{
|
||||||
private string random = (new Random()).Next(1, 1000).ToString();
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void AccessRequiresLogin()
|
public void AccessRequiresLogin()
|
||||||
{
|
{
|
||||||
@ -94,6 +102,20 @@ namespace BTCPayServer.Tests
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void CanNavigateServerSettings()
|
||||||
|
{
|
||||||
|
Wrap(s =>
|
||||||
|
{
|
||||||
|
Driver.Navigate().GoToUrl(s);
|
||||||
|
RegisterNewUser(true);
|
||||||
|
Driver.FindElement(By.Id("ServerSettings")).Click();
|
||||||
|
Driver.AssertNoError();
|
||||||
|
ClickOnAllSideMenus();
|
||||||
|
Driver.Quit();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void NewUserLogin()
|
public void NewUserLogin()
|
||||||
{
|
{
|
||||||
@ -101,14 +123,16 @@ namespace BTCPayServer.Tests
|
|||||||
{
|
{
|
||||||
//Register & Log Out
|
//Register & Log Out
|
||||||
Driver.Navigate().GoToUrl(s);
|
Driver.Navigate().GoToUrl(s);
|
||||||
RegisterNewUser(random);
|
var email = RegisterNewUser();
|
||||||
Driver.FindElement(By.Id("Logout")).Click();
|
Driver.FindElement(By.Id("Logout")).Click();
|
||||||
|
Driver.AssertNoError();
|
||||||
|
|
||||||
//Same User Can Log Back In
|
//Same User Can Log Back In
|
||||||
Driver.FindElement(By.Id("Login")).Click();
|
Driver.FindElement(By.Id("Login")).Click();
|
||||||
Driver.FindElement(By.Id("Email")).SendKeys(random + "@a.com");
|
Driver.FindElement(By.Id("Email")).SendKeys(email);
|
||||||
Driver.FindElement(By.Id("Password")).SendKeys("123456");
|
Driver.FindElement(By.Id("Password")).SendKeys("123456");
|
||||||
Driver.FindElement(By.Id("LoginButton")).Click();
|
Driver.FindElement(By.Id("LoginButton")).Click();
|
||||||
|
Driver.AssertNoError();
|
||||||
|
|
||||||
//Change Password & Log Out
|
//Change Password & Log Out
|
||||||
Driver.FindElement(By.Id("MySettings")).Click();
|
Driver.FindElement(By.Id("MySettings")).Click();
|
||||||
@ -118,10 +142,11 @@ namespace BTCPayServer.Tests
|
|||||||
Driver.FindElement(By.Id("ConfirmPassword")).SendKeys("abc???");
|
Driver.FindElement(By.Id("ConfirmPassword")).SendKeys("abc???");
|
||||||
Driver.FindElement(By.Id("UpdatePassword")).Click();
|
Driver.FindElement(By.Id("UpdatePassword")).Click();
|
||||||
Driver.FindElement(By.Id("Logout")).Click();
|
Driver.FindElement(By.Id("Logout")).Click();
|
||||||
|
Driver.AssertNoError();
|
||||||
|
|
||||||
//Log In With New Password
|
//Log In With New Password
|
||||||
Driver.FindElement(By.Id("Login")).Click();
|
Driver.FindElement(By.Id("Login")).Click();
|
||||||
Driver.FindElement(By.Id("Email")).SendKeys(random + "@a.com");
|
Driver.FindElement(By.Id("Email")).SendKeys(email);
|
||||||
Driver.FindElement(By.Id("Password")).SendKeys("abc???");
|
Driver.FindElement(By.Id("Password")).SendKeys("abc???");
|
||||||
Driver.FindElement(By.Id("LoginButton")).Click();
|
Driver.FindElement(By.Id("LoginButton")).Click();
|
||||||
Assert.True(Driver.PageSource.Contains("Stores"), "Can't Access Stores");
|
Assert.True(Driver.PageSource.Contains("Stores"), "Can't Access Stores");
|
||||||
@ -136,27 +161,42 @@ namespace BTCPayServer.Tests
|
|||||||
Wrap(s =>
|
Wrap(s =>
|
||||||
{
|
{
|
||||||
Driver.Navigate().GoToUrl(s);
|
Driver.Navigate().GoToUrl(s);
|
||||||
RegisterNewUser(random);
|
RegisterNewUser();
|
||||||
CreateNewStore(random);
|
var store = CreateNewStore();
|
||||||
Assert.Contains("Store" + random, Driver.PageSource);
|
Driver.AssertNoError();
|
||||||
|
Assert.Contains(store, Driver.PageSource);
|
||||||
|
|
||||||
|
ClickOnAllSideMenus();
|
||||||
|
|
||||||
Driver.Quit();
|
Driver.Quit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ClickOnAllSideMenus()
|
||||||
|
{
|
||||||
|
var links = Driver.FindElements(By.CssSelector(".nav-pills .nav-link")).Select(c => c.GetAttribute("href")).ToList();
|
||||||
|
Assert.NotEmpty(links);
|
||||||
|
foreach (var l in links)
|
||||||
|
{
|
||||||
|
Driver.Navigate().GoToUrl(l);
|
||||||
|
Driver.AssertNoError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void CanCreateInvoice()
|
public void CanCreateInvoice()
|
||||||
{
|
{
|
||||||
Wrap(s =>
|
Wrap(s =>
|
||||||
{
|
{
|
||||||
Driver.Navigate().GoToUrl(s);
|
Driver.Navigate().GoToUrl(s);
|
||||||
RegisterNewUser(random);
|
RegisterNewUser();
|
||||||
CreateNewStore(random);
|
var store = CreateNewStore();
|
||||||
AddDerivationScheme();
|
AddDerivationScheme();
|
||||||
|
|
||||||
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(store + Keys.Enter);
|
||||||
Driver.FindElement(By.Id("Create")).Click();
|
Driver.FindElement(By.Id("Create")).Click();
|
||||||
Assert.True(Driver.PageSource.Contains("just created!"), "Unable to create Invoice");
|
Assert.True(Driver.PageSource.Contains("just created!"), "Unable to create Invoice");
|
||||||
Driver.Quit();
|
Driver.Quit();
|
||||||
@ -169,14 +209,14 @@ namespace BTCPayServer.Tests
|
|||||||
Wrap(s =>
|
Wrap(s =>
|
||||||
{
|
{
|
||||||
Driver.Navigate().GoToUrl(s);
|
Driver.Navigate().GoToUrl(s);
|
||||||
RegisterNewUser(random);
|
RegisterNewUser();
|
||||||
CreateNewStore(random);
|
var store = CreateNewStore();
|
||||||
|
|
||||||
Driver.FindElement(By.Id("Apps")).Click();
|
Driver.FindElement(By.Id("Apps")).Click();
|
||||||
Driver.FindElement(By.Id("CreateNewApp")).Click();
|
Driver.FindElement(By.Id("CreateNewApp")).Click();
|
||||||
Driver.FindElement(By.Name("Name")).SendKeys("PoS" + random);
|
Driver.FindElement(By.Name("Name")).SendKeys("PoS" + store);
|
||||||
Driver.FindElement(By.CssSelector("select#SelectedAppType.form-control")).SendKeys("PointOfSale" + Keys.Enter);
|
Driver.FindElement(By.CssSelector("select#SelectedAppType.form-control")).SendKeys("PointOfSale" + Keys.Enter);
|
||||||
Driver.FindElement(By.CssSelector("select#SelectedStore.form-control")).SendKeys("Store" + random + Keys.Enter);
|
Driver.FindElement(By.CssSelector("select#SelectedStore.form-control")).SendKeys(store + Keys.Enter);
|
||||||
Driver.FindElement(By.Id("Create")).Click();
|
Driver.FindElement(By.Id("Create")).Click();
|
||||||
Driver.FindElement(By.CssSelector("input#EnableShoppingCart.form-check")).Click();
|
Driver.FindElement(By.CssSelector("input#EnableShoppingCart.form-check")).Click();
|
||||||
Driver.FindElement(By.Id("SaveSettings")).Click();
|
Driver.FindElement(By.Id("SaveSettings")).Click();
|
||||||
@ -191,15 +231,15 @@ namespace BTCPayServer.Tests
|
|||||||
Wrap(s =>
|
Wrap(s =>
|
||||||
{
|
{
|
||||||
Driver.Navigate().GoToUrl(s);
|
Driver.Navigate().GoToUrl(s);
|
||||||
RegisterNewUser(random);
|
RegisterNewUser();
|
||||||
CreateNewStore(random);
|
var store = CreateNewStore();
|
||||||
AddDerivationScheme();
|
AddDerivationScheme();
|
||||||
|
|
||||||
Driver.FindElement(By.Id("Apps")).Click();
|
Driver.FindElement(By.Id("Apps")).Click();
|
||||||
Driver.FindElement(By.Id("CreateNewApp")).Click();
|
Driver.FindElement(By.Id("CreateNewApp")).Click();
|
||||||
Driver.FindElement(By.Name("Name")).SendKeys("CF" + random);
|
Driver.FindElement(By.Name("Name")).SendKeys("CF" + store);
|
||||||
Driver.FindElement(By.CssSelector("select#SelectedAppType.form-control")).SendKeys("Crowdfund" + Keys.Enter);
|
Driver.FindElement(By.CssSelector("select#SelectedAppType.form-control")).SendKeys("Crowdfund" + Keys.Enter);
|
||||||
Driver.FindElement(By.CssSelector("select#SelectedStore.form-control")).SendKeys("Store" + random + Keys.Enter);
|
Driver.FindElement(By.CssSelector("select#SelectedStore.form-control")).SendKeys(store + Keys.Enter);
|
||||||
Driver.FindElement(By.Id("Create")).Click();
|
Driver.FindElement(By.Id("Create")).Click();
|
||||||
Driver.FindElement(By.Id("Title")).SendKeys("Kukkstarter");
|
Driver.FindElement(By.Id("Title")).SendKeys("Kukkstarter");
|
||||||
Driver.FindElement(By.CssSelector("div.note-editable.card-block")).SendKeys("1BTC = 1BTC");
|
Driver.FindElement(By.CssSelector("div.note-editable.card-block")).SendKeys("1BTC = 1BTC");
|
||||||
@ -219,8 +259,8 @@ namespace BTCPayServer.Tests
|
|||||||
Wrap(s =>
|
Wrap(s =>
|
||||||
{
|
{
|
||||||
Driver.Navigate().GoToUrl(s);
|
Driver.Navigate().GoToUrl(s);
|
||||||
RegisterNewUser(random);
|
RegisterNewUser();
|
||||||
CreateNewStore(random);
|
CreateNewStore();
|
||||||
AddDerivationScheme();
|
AddDerivationScheme();
|
||||||
|
|
||||||
Driver.FindElement(By.Id("PaymentRequests")).Click();
|
Driver.FindElement(By.Id("PaymentRequests")).Click();
|
||||||
@ -236,6 +276,25 @@ namespace BTCPayServer.Tests
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void CanManageWallet()
|
||||||
|
{
|
||||||
|
Wrap(s =>
|
||||||
|
{
|
||||||
|
Driver.Navigate().GoToUrl(s);
|
||||||
|
RegisterNewUser();
|
||||||
|
CreateNewStore();
|
||||||
|
AddDerivationScheme();
|
||||||
|
|
||||||
|
Driver.FindElement(By.Id("Wallets")).Click();
|
||||||
|
Driver.FindElement(By.LinkText("Manage")).Click();
|
||||||
|
|
||||||
|
ClickOnAllSideMenus();
|
||||||
|
|
||||||
|
Driver.Quit();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public ChromeTests(ITestOutputHelper helper) : base(helper)
|
public ChromeTests(ITestOutputHelper helper) : base(helper)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
dotnet test --filter Fast=Fast --no-build
|
dotnet test --filter Fast=Fast --no-build
|
||||||
|
dotnet test --filter Selenium=Selenium--no-build -v n
|
||||||
dotnet test --filter Integration=Integration --no-build -v n
|
dotnet test --filter Integration=Integration --no-build -v n
|
||||||
if [[ "$TESTS_RUN_EXTERNAL_INTEGRATION" == "true" ]]; then
|
if [[ "$TESTS_RUN_EXTERNAL_INTEGRATION" == "true" ]]; then
|
||||||
dotnet test --filter ExternalIntegration=ExternalIntegration --no-build -v n
|
dotnet test --filter ExternalIntegration=ExternalIntegration --no-build -v n
|
||||||
|
@ -72,7 +72,7 @@
|
|||||||
{
|
{
|
||||||
if (User.IsInRole(Roles.ServerAdmin))
|
if (User.IsInRole(Roles.ServerAdmin))
|
||||||
{
|
{
|
||||||
<li class="nav-item"><a asp-area="" asp-controller="Server" asp-action="ListUsers" class="nav-link js-scroll-trigger">Server settings</a></li>
|
<li class="nav-item"><a asp-area="" asp-controller="Server" asp-action="ListUsers" class="nav-link js-scroll-trigger" id="ServerSettings">Server settings</a></li>
|
||||||
}
|
}
|
||||||
<li class="nav-item"><a asp-area="" asp-controller="UserStores" asp-action="ListStores" class="nav-link js-scroll-trigger" id="Stores">Stores</a></li>
|
<li class="nav-item"><a asp-area="" asp-controller="UserStores" asp-action="ListStores" class="nav-link js-scroll-trigger" id="Stores">Stores</a></li>
|
||||||
<li class="nav-item"><a asp-area="" asp-controller="Apps" asp-action="ListApps" class="nav-link js-scroll-trigger" id="Apps">Apps</a></li>
|
<li class="nav-item"><a asp-area="" asp-controller="Apps" asp-action="ListApps" class="nav-link js-scroll-trigger" id="Apps">Apps</a></li>
|
||||||
|
Loading…
Reference in New Issue
Block a user