mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 14:04:26 +01:00
Redirect to invoice details instead of list upon creation (#3936)
* Redirect to invoice details instead of list upon creation close #3909 * fix tests
This commit is contained in:
@@ -37,9 +37,6 @@ namespace BTCPayServer.Tests
|
|||||||
s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
|
s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
|
||||||
s.GoToHome();
|
s.GoToHome();
|
||||||
s.CreateInvoice();
|
s.CreateInvoice();
|
||||||
s.Driver.FindElement(By.ClassName("invoice-details-link")).Click();
|
|
||||||
s.Driver.AssertNoError();
|
|
||||||
s.Driver.Navigate().Back();
|
|
||||||
s.Driver.FindElement(By.ClassName("invoice-checkout-link")).Click();
|
s.Driver.FindElement(By.ClassName("invoice-checkout-link")).Click();
|
||||||
Assert.NotEmpty(s.Driver.FindElements(By.Id("checkoutCtrl")));
|
Assert.NotEmpty(s.Driver.FindElements(By.Id("checkoutCtrl")));
|
||||||
|
|
||||||
@@ -102,9 +99,6 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
// Now create an invoice that doesn't require a refund email
|
// Now create an invoice that doesn't require a refund email
|
||||||
s.CreateInvoice(100, "USD", "", null, false);
|
s.CreateInvoice(100, "USD", "", null, false);
|
||||||
s.Driver.FindElement(By.ClassName("invoice-details-link")).Click();
|
|
||||||
s.Driver.AssertNoError();
|
|
||||||
s.Driver.Navigate().Back();
|
|
||||||
s.Driver.FindElement(By.ClassName("invoice-checkout-link")).Click();
|
s.Driver.FindElement(By.ClassName("invoice-checkout-link")).Click();
|
||||||
Assert.NotEmpty(s.Driver.FindElements(By.Id("checkoutCtrl")));
|
Assert.NotEmpty(s.Driver.FindElements(By.Id("checkoutCtrl")));
|
||||||
s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
|
s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
|
||||||
@@ -115,9 +109,6 @@ namespace BTCPayServer.Tests
|
|||||||
|
|
||||||
// Now create an invoice that requires refund email but already has one set, email input shouldn't show up
|
// Now create an invoice that requires refund email but already has one set, email input shouldn't show up
|
||||||
s.CreateInvoice(100, "USD", "a@g.com", null, true);
|
s.CreateInvoice(100, "USD", "a@g.com", null, true);
|
||||||
s.Driver.FindElement(By.ClassName("invoice-details-link")).Click();
|
|
||||||
s.Driver.AssertNoError();
|
|
||||||
s.Driver.Navigate().Back();
|
|
||||||
s.Driver.FindElement(By.ClassName("invoice-checkout-link")).Click();
|
s.Driver.FindElement(By.ClassName("invoice-checkout-link")).Click();
|
||||||
Assert.NotEmpty(s.Driver.FindElements(By.Id("checkoutCtrl")));
|
Assert.NotEmpty(s.Driver.FindElements(By.Id("checkoutCtrl")));
|
||||||
s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
|
s.Driver.AssertElementNotFound(By.Id("emailAddressFormInput"));
|
||||||
|
|||||||
@@ -417,24 +417,23 @@ namespace BTCPayServer.Tests
|
|||||||
s.AddDerivationScheme();
|
s.AddDerivationScheme();
|
||||||
s.GoToInvoices();
|
s.GoToInvoices();
|
||||||
s.CreateInvoice();
|
s.CreateInvoice();
|
||||||
s.Driver.FindElement(By.ClassName("changeInvoiceStateToggle")).Click();
|
s.Driver.FindElement(By.Id("markStatusDropdownMenuButton")).Click();
|
||||||
s.Driver.FindElements(By.ClassName("changeInvoiceState"))[0].Click();
|
s.Driver.FindElements(By.ClassName("changeInvoiceState"))[0].Click();
|
||||||
TestUtils.Eventually(() => Assert.Contains("Invalid (marked)", s.Driver.PageSource));
|
TestUtils.Eventually(() => Assert.Contains("Invalid (marked)", s.Driver.PageSource));
|
||||||
s.Driver.Navigate().Refresh();
|
s.Driver.Navigate().Refresh();
|
||||||
|
|
||||||
s.Driver.FindElement(By.ClassName("changeInvoiceStateToggle")).Click();
|
s.Driver.FindElement(By.Id("markStatusDropdownMenuButton")).Click();
|
||||||
s.Driver.FindElements(By.ClassName("changeInvoiceState"))[0].Click();
|
s.Driver.FindElements(By.ClassName("changeInvoiceState"))[0].Click();
|
||||||
TestUtils.Eventually(() => Assert.Contains("Settled (marked)", s.Driver.PageSource));
|
TestUtils.Eventually(() => Assert.Contains("Settled (marked)", s.Driver.PageSource));
|
||||||
|
|
||||||
s.Driver.FindElement(By.ClassName("invoice-details-link")).Click();
|
s.Driver.Navigate().Refresh();
|
||||||
Assert.Contains("Settled (marked)", s.Driver.PageSource);
|
|
||||||
|
|
||||||
s.Driver.FindElement(By.ClassName("changeInvoiceStateToggle")).Click();
|
s.Driver.FindElement(By.Id("markStatusDropdownMenuButton")).Click();
|
||||||
s.Driver.FindElements(By.ClassName("changeInvoiceState"))[0].Click();
|
s.Driver.FindElements(By.ClassName("changeInvoiceState"))[0].Click();
|
||||||
TestUtils.Eventually(() => Assert.Contains("Invalid (marked)", s.Driver.PageSource));
|
TestUtils.Eventually(() => Assert.Contains("Invalid (marked)", s.Driver.PageSource));
|
||||||
s.Driver.Navigate().Refresh();
|
s.Driver.Navigate().Refresh();
|
||||||
|
|
||||||
s.Driver.FindElement(By.ClassName("changeInvoiceStateToggle")).Click();
|
s.Driver.FindElement(By.Id("markStatusDropdownMenuButton")).Click();
|
||||||
s.Driver.FindElements(By.ClassName("changeInvoiceState"))[0].Click();
|
s.Driver.FindElements(By.ClassName("changeInvoiceState"))[0].Click();
|
||||||
TestUtils.Eventually(() => Assert.Contains("Settled (marked)", s.Driver.PageSource));
|
TestUtils.Eventually(() => Assert.Contains("Settled (marked)", s.Driver.PageSource));
|
||||||
}
|
}
|
||||||
@@ -562,7 +561,7 @@ namespace BTCPayServer.Tests
|
|||||||
Assert.Contains("There are no invoices matching your criteria.", s.Driver.PageSource);
|
Assert.Contains("There are no invoices matching your criteria.", s.Driver.PageSource);
|
||||||
var invoiceId = s.CreateInvoice();
|
var invoiceId = s.CreateInvoice();
|
||||||
s.FindAlertMessage();
|
s.FindAlertMessage();
|
||||||
s.Driver.FindElement(By.ClassName("invoice-details-link")).Click();
|
|
||||||
var invoiceUrl = s.Driver.Url;
|
var invoiceUrl = s.Driver.Url;
|
||||||
|
|
||||||
//let's test archiving an invoice
|
//let's test archiving an invoice
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -33,7 +32,6 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using NBitcoin;
|
using NBitcoin;
|
||||||
using NBitpayClient;
|
using NBitpayClient;
|
||||||
using NBXplorer;
|
using NBXplorer;
|
||||||
using NBXplorer.Models;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using BitpayCreateInvoiceRequest = BTCPayServer.Models.BitpayCreateInvoiceRequest;
|
using BitpayCreateInvoiceRequest = BTCPayServer.Models.BitpayCreateInvoiceRequest;
|
||||||
using StoreData = BTCPayServer.Data.StoreData;
|
using StoreData = BTCPayServer.Data.StoreData;
|
||||||
@@ -86,6 +84,7 @@ namespace BTCPayServer.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("invoices/{invoiceId}")]
|
[HttpGet("invoices/{invoiceId}")]
|
||||||
|
[HttpGet("/stores/{storeId}/invoices/${invoiceId}")]
|
||||||
[Authorize(Policy = Policies.CanViewInvoices, AuthenticationSchemes = AuthenticationSchemes.Cookie)]
|
[Authorize(Policy = Policies.CanViewInvoices, AuthenticationSchemes = AuthenticationSchemes.Cookie)]
|
||||||
public async Task<IActionResult> Invoice(string invoiceId)
|
public async Task<IActionResult> Invoice(string invoiceId)
|
||||||
{
|
{
|
||||||
@@ -1100,7 +1099,8 @@ namespace BTCPayServer.Controllers
|
|||||||
|
|
||||||
TempData[WellKnownTempData.SuccessMessage] = $"Invoice {result.Data.Id} just created!";
|
TempData[WellKnownTempData.SuccessMessage] = $"Invoice {result.Data.Id} just created!";
|
||||||
CreatedInvoiceId = result.Data.Id;
|
CreatedInvoiceId = result.Data.Id;
|
||||||
return RedirectToAction(nameof(ListInvoices), new { result.Data.StoreId });
|
|
||||||
|
return RedirectToAction(nameof(Invoice), new { storeId = result.Data.StoreId, invoiceId = result.Data.Id });
|
||||||
}
|
}
|
||||||
catch (BitpayHttpException ex)
|
catch (BitpayHttpException ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user