mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 05:54:26 +01:00
Add ability for to upload screenshot to circleci artifact for Playwright tests
This commit is contained in:
@@ -16,6 +16,12 @@ jobs:
|
||||
- run:
|
||||
command: |
|
||||
cd .circleci && ./run-tests.sh "Playwright=Playwright"
|
||||
- run:
|
||||
when: always
|
||||
command: |
|
||||
docker run --rm -v btcpayservertests_tests_datadir:/data -v /tmp/Artifacts:/host alpine sh -c "cp -r /data/. /host/"
|
||||
- store_artifacts:
|
||||
path: /tmp/Artifacts
|
||||
selenium_tests:
|
||||
machine:
|
||||
image: ubuntu-2004:2024.11.1
|
||||
|
||||
@@ -10,7 +10,7 @@ n=0
|
||||
until [ "$n" -ge 10 ]
|
||||
do
|
||||
docker-compose -f "docker-compose.altcoins.yml" pull && break
|
||||
n=$((n+1))
|
||||
n=$((n+1))
|
||||
sleep 5
|
||||
done
|
||||
|
||||
|
||||
@@ -405,10 +405,8 @@ goodies:
|
||||
Assert.Contains("0,77 €", await s.Page.TextContentAsync("#PaymentDetails-TaxIncluded"));
|
||||
Assert.Contains("10,67 €", await s.Page.TextContentAsync("#PaymentDetails-TotalFiat"));
|
||||
//
|
||||
// Pay
|
||||
await s.PayInvoice(true);
|
||||
|
||||
|
||||
// Receipt
|
||||
await s.Page.ClickAsync("#ReceiptLink");
|
||||
await s.Page.WaitForSelectorAsync("#CartData table");
|
||||
@@ -435,7 +433,17 @@ goodies:
|
||||
|
||||
// Check inventory got updated and is now 3 instead of 5
|
||||
await s.GoToUrl(posUrl);
|
||||
Assert.Equal("3 left", await s.Page.TextContentAsync(".posItem:nth-child(3) .badge.inventory"));
|
||||
try
|
||||
{
|
||||
Assert.Equal("3 left", await s.Page.TextContentAsync(".posItem:nth-child(3) .badge.inventory"));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Flaky
|
||||
await s.TakeScreenshot("BadInventory.png");
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
// Guest user can access recent transactions
|
||||
await s.GoToHome();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
@@ -566,7 +567,15 @@ namespace BTCPayServer.Tests
|
||||
await Page.ClickAsync("#FakePayment");
|
||||
await Page.Locator("#CheatSuccessMessage").WaitForAsync();
|
||||
// TODO: Fix flakyness
|
||||
await Page.Locator("text=Payment Received").WaitForAsync();
|
||||
try
|
||||
{
|
||||
await Page.Locator("text=Payment Received").WaitForAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
await TakeScreenshot("PayInvoice.png");
|
||||
throw;
|
||||
}
|
||||
|
||||
if (mine)
|
||||
{
|
||||
@@ -574,6 +583,25 @@ namespace BTCPayServer.Tests
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Take a screenshot. If running in CI, it is uploaded in the artifacts (see https://github.com/btcpayserver/btcpayserver/pull/6794)
|
||||
/// </summary>
|
||||
/// <param name="fileName"></param>
|
||||
public async Task TakeScreenshot(string fileName)
|
||||
{
|
||||
var screenshotDir = Environment.GetEnvironmentVariable("TESTS_ARTIFACTS_DIR") ?? "Screenshots";
|
||||
Directory.CreateDirectory(screenshotDir);
|
||||
screenshotDir = Path.Combine(screenshotDir, this.Server.Scope);
|
||||
Directory.CreateDirectory(screenshotDir);
|
||||
var filePath = Path.Combine(screenshotDir, fileName);
|
||||
Server.TestLogs.LogInformation("Saving test screenshot to " + filePath);
|
||||
await Page.ScreenshotAsync(new()
|
||||
{
|
||||
Path = filePath,
|
||||
FullPage = true,
|
||||
});
|
||||
}
|
||||
|
||||
public async Task MineBlockOnInvoiceCheckout()
|
||||
{
|
||||
await Page.ClickAsync("#mine-block button");
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace BTCPayServer.Tests
|
||||
internal ILog TestLogs;
|
||||
public ServerTester(string scope, bool newDb, ILog testLogs, ILoggerProvider loggerProvider, BTCPayNetworkProvider networkProvider)
|
||||
{
|
||||
Scope = scope;
|
||||
LoggerProvider = loggerProvider;
|
||||
this.TestLogs = testLogs;
|
||||
_Directory = scope;
|
||||
@@ -73,6 +74,8 @@ namespace BTCPayServer.Tests
|
||||
PayTester.SocksEndpoint = GetEnvironment("TESTS_SOCKSENDPOINT", "localhost:9050");
|
||||
}
|
||||
|
||||
public string Scope { get; set; }
|
||||
|
||||
public void ActivateLangs()
|
||||
{
|
||||
TestLogs.LogInformation("Activating Langs...");
|
||||
|
||||
@@ -82,7 +82,17 @@ public class WalletTests(ITestOutputHelper helper) : UnitTestBase(helper)
|
||||
await w.AssertNotFound(cpfpTx);
|
||||
|
||||
// However, the new transaction should have copied the CPFP tag from the transaction it replaced, and have a RBF label as well.
|
||||
await w.AssertHasLabels(rbfTx, "CPFP");
|
||||
try
|
||||
{
|
||||
await w.AssertHasLabels(rbfTx, "CPFP");
|
||||
}
|
||||
catch
|
||||
{
|
||||
// TODO: Flaky
|
||||
await s.TakeScreenshot("AssertHasLabels-Fails.png");
|
||||
throw;
|
||||
}
|
||||
|
||||
await w.AssertHasLabels(rbfTx, "RBF");
|
||||
|
||||
// Now, we sweep all the UTXOs to a single destination. This should be RBF-able. (Fee deducted on the lone UTXO)
|
||||
|
||||
@@ -29,6 +29,7 @@ services:
|
||||
TESTS_SSHPASSWORD: ""
|
||||
TESTS_SSHKEYFILE: ""
|
||||
TESTS_SOCKSENDPOINT: "tor:9050"
|
||||
TESTS_ARTIFACTS_DIR: "/tmp/Artifacts"
|
||||
expose:
|
||||
- "80"
|
||||
depends_on:
|
||||
@@ -44,6 +45,7 @@ services:
|
||||
- "sshd_datadir:/root/.ssh"
|
||||
- "customer_lightningd_datadir:/etc/customer_lightningd_datadir"
|
||||
- "merchant_lightningd_datadir:/etc/merchant_lightningd_datadir"
|
||||
- "tests_datadir:/tmp/Artifacts"
|
||||
|
||||
# The dev container is not actually used, it is just handy to run `docker-compose up dev` to start all services
|
||||
dev:
|
||||
@@ -366,6 +368,7 @@ services:
|
||||
- "elementsd_liquid_datadir:/data"
|
||||
|
||||
volumes:
|
||||
tests_datadir:
|
||||
sshd_datadir:
|
||||
bitcoin_datadir:
|
||||
elementsd_liquid_datadir:
|
||||
|
||||
@@ -87,6 +87,9 @@ namespace BTCPayServer
|
||||
}
|
||||
}
|
||||
|
||||
if (Logs.Events.IsEnabled(LogLevel.Information))
|
||||
Logs.Events.LogInformation("Event published {0}", evt);
|
||||
|
||||
foreach (var sub in actionList)
|
||||
{
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user