Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POS fixes #5228

Merged
merged 2 commits into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions BTCPayServer.Tests/SeleniumTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -988,14 +988,14 @@ public async Task CanCreateAppPoS()
Assert.True(s.Driver.PageSource.Contains("Tea shop"), "Unable to create PoS");
Assert.True(s.Driver.PageSource.Contains("Cart"), "PoS not showing correct default view");
Assert.True(s.Driver.PageSource.Contains("Take my money"), "PoS not showing correct default view");
Assert.Equal(5, s.Driver.FindElements(By.CssSelector(".posItem:not(.d-none)")).Count);
Assert.Equal(6, s.Driver.FindElements(By.CssSelector(".posItem:not(.d-none)")).Count);

var drinks = s.Driver.FindElement(By.CssSelector("label[for='Category-Drinks']"));
Assert.Equal("Drinks", drinks.Text);
drinks.Click();
Assert.Single(s.Driver.FindElements(By.CssSelector(".posItem:not(.d-none)")));
s.Driver.FindElement(By.CssSelector("label[for='Category-*']")).Click();
Assert.Equal(5, s.Driver.FindElements(By.CssSelector(".posItem:not(.d-none)")).Count);
Assert.Equal(6, s.Driver.FindElements(By.CssSelector(".posItem:not(.d-none)")).Count);

s.Driver.Url = posBaseUrl + "/static";
Assert.False(s.Driver.PageSource.Contains("Cart"), "Static PoS not showing correct view");
Expand Down
17 changes: 12 additions & 5 deletions BTCPayServer.Tests/ThirdPartyTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public void CanSolveTheDogesRatesOnKraken()
[Fact]
public async Task CanGetRateCryptoCurrenciesByDefault()
{
string[] brokenShitcoins = { };
string[] brokenShitcoins = { "BTG", "BTX" };
var provider = new BTCPayNetworkProvider(ChainName.Mainnet);
var factory = FastTests.CreateBTCPayRateFactory();
var fetcher = new RateFetcher(factory);
Expand All @@ -306,9 +306,13 @@ public async Task CanGetRateCryptoCurrenciesByDefault()
foreach ((CurrencyPair key, Task<RateResult> value) in result)
{
var rateResult = await value;
TestLogs.LogInformation($"Testing {key}");
if (brokenShitcoins.Contains(key.ToString()))
if (brokenShitcoins.Contains(key.Left))
{
TestLogs.LogInformation($"Skipping {key} because it is marked as broken");
continue;
}

TestLogs.LogInformation($"Testing {key}");
Assert.True(rateResult.BidAsk != null, $"Impossible to get the rate {rateResult.EvaluatedRule}");
}

Expand All @@ -325,9 +329,12 @@ public async Task CanGetRateCryptoCurrenciesByDefault()
foreach ((CurrencyPair key, Task<RateResult> value) in result)
{
var rateResult = await value;
TestLogs.LogInformation($"Testing {key} when default currency is {k.Key}");
if (brokenShitcoins.Contains(key.ToString()))
if (brokenShitcoins.Contains(key.Left))
{
TestLogs.LogInformation($"Skipping {key} because it is marked as broken");
continue;
}
TestLogs.LogInformation($"Testing {key} when default currency is {k.Key}");
Assert.True(rateResult.BidAsk != null, $"Impossible to get the rate {rateResult.EvaluatedRule}");
}
}
Expand Down
5 changes: 2 additions & 3 deletions BTCPayServer.Tests/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2859,7 +2859,7 @@ public async void CanUseLocalProviderFiles()
using var tester = CreateServerTester();
await tester.StartAsync();
var user = tester.NewAccount();
user.GrantAccess();
await user.GrantAccessAsync();
var controller = tester.PayTester.GetController<UIServerController>(user.UserId, user.StoreId);

var fileSystemStorageConfiguration = Assert.IsType<FileSystemStorageConfiguration>(Assert
Expand All @@ -2874,7 +2874,6 @@ public async void CanUseLocalProviderFiles()
Assert.Equal(StorageProvider.FileSystem,
shouldBeRedirectingToLocalStorageConfigPage.RouteValues["provider"]);


await CanUploadRemoveFiles(controller);
}

Expand Down Expand Up @@ -2906,7 +2905,7 @@ internal static async Task CanUploadRemoveFiles(UIServerController controller)

//create a temporary link to file
var tmpLinkGenerate = Assert.IsType<RedirectToActionResult>(await controller.CreateTemporaryFileUrl(fileId,
new UIServerController.CreateTemporaryFileUrlViewModel()
new UIServerController.CreateTemporaryFileUrlViewModel
{
IsDownload = true,
TimeAmount = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,19 @@ public override async Task<string> GetFileUrl(Uri baseUri, StoredFile storedFile
BlobUrlAccess access = BlobUrlAccess.Read)
{

var localFileDescriptor = new TemporaryLocalFileDescriptor()
var localFileDescriptor = new TemporaryLocalFileDescriptor
{
Expiry = expiry,
FileId = storedFile.Id,
IsDownload = isDownload
};
var name = Guid.NewGuid().ToString();
var fullPath = Path.Combine(_datadirs.Value.TempStorageDir, name);
if (!File.Exists(fullPath))
var fileInfo = new FileInfo(fullPath);
if (!fileInfo.Exists)
{
await File.Create(fullPath).DisposeAsync();
fileInfo.Directory?.Create();
await File.Create(fileInfo.FullName).DisposeAsync();
}

await File.WriteAllTextAsync(Path.Combine(_datadirs.Value.TempStorageDir, name), JsonConvert.SerializeObject(localFileDescriptor));
Expand Down
8 changes: 3 additions & 5 deletions BTCPayServer/Views/Shared/PointOfSale/Public/Cart.cshtml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
@using BTCPayServer.Plugins.PointOfSale.Models
@using BTCPayServer.Services
@using Newtonsoft.Json.Linq;
@using BTCPayServer.Abstractions.TagHelpers
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using Newtonsoft.Json.Linq
@inject DisplayFormatter DisplayFormatter
@inject BTCPayServer.Security.ContentSecurityPolicies Csp
@model BTCPayServer.Plugins.PointOfSale.Models.ViewPointOfSaleViewModel
Expand Down Expand Up @@ -65,8 +63,8 @@
? item.PriceType == ViewPointOfSaleViewModel.ItemPriceType.Topup ? Model.CustomButtonText : Model.ButtonText
: item.BuyButtonText;
buttonText = buttonText.Replace("{0}", formatted).Replace("{Price}", formatted);
var categories = new JArray(item.Categories ?? Array.Empty<string>());
<div class="col posItem" :class="{ 'posItem--inStock': inStock(@index) }" data-index="@index" data-search="@Safe.RawEncode(item.Title + " " + item.Description)" data-categories="@Safe.Json(categories)">
var categories = new JArray(item.Categories ?? new object[] { });
<div class="col posItem" :class="{ 'posItem--inStock': inStock(@index) }" data-index="@index" data-search="@Safe.RawEncode(item.Title + " " + item.Description)" data-categories='@Safe.Json(categories)'>
<div class="card h-100 px-0" v-on:click="addToCart(@index)">
@if (!string.IsNullOrWhiteSpace(item.Image))
{
Expand Down
6 changes: 2 additions & 4 deletions BTCPayServer/wwwroot/pos/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,8 @@ document.addEventListener("DOMContentLoaded",function () {
}
},
mounted() {
const self =this;
nextTick(() => {
self.$cart = new bootstrap.Offcanvas("#cart", {backdrop: false})
})
this.$cart = new bootstrap.Offcanvas(this.$refs.cart, { backdrop: false })

window.addEventListener('pagehide', () => {
if (this.payButtonLoading) {
this.unsetPayButtonLoading();
Expand Down