diff --git a/BTCPayServer.Tests/BTCPayServerTester.cs b/BTCPayServer.Tests/BTCPayServerTester.cs index 077b2c873..7d09d69c6 100644 --- a/BTCPayServer.Tests/BTCPayServerTester.cs +++ b/BTCPayServer.Tests/BTCPayServerTester.cs @@ -37,6 +37,7 @@ using Xunit; using BTCPayServer.Services; using System.Net.Http; using Microsoft.AspNetCore.Hosting.Server.Features; +using System.Threading.Tasks; namespace BTCPayServer.Tests { @@ -158,11 +159,6 @@ namespace BTCPayServer.Tests InvoiceRepository = (InvoiceRepository)_Host.Services.GetService(typeof(InvoiceRepository)); StoreRepository = (StoreRepository)_Host.Services.GetService(typeof(StoreRepository)); Networks = (BTCPayNetworkProvider)_Host.Services.GetService(typeof(BTCPayNetworkProvider)); - var dashBoard = (NBXplorerDashboard)_Host.Services.GetService(typeof(NBXplorerDashboard)); - while(!dashBoard.IsFullySynched()) - { - Thread.Sleep(10); - } if (MockRates) { @@ -223,6 +219,35 @@ namespace BTCPayServer.Tests }); rateProvider.Providers.Add("bittrex", bittrex); } + + + + WaitSiteIsOperational().GetAwaiter().GetResult(); + } + + private async Task WaitSiteIsOperational() + { + var synching = WaitIsFullySynched(); + var accessingHomepage = WaitCanAccessHomepage(); + await Task.WhenAll(synching, accessingHomepage).ConfigureAwait(false); + } + + private async Task WaitCanAccessHomepage() + { + var resp = await HttpClient.GetAsync("/").ConfigureAwait(false); + while (resp.StatusCode != HttpStatusCode.OK) + { + await Task.Delay(10).ConfigureAwait(false); + } + } + + private async Task WaitIsFullySynched() + { + var dashBoard = GetService(); + while (!dashBoard.IsFullySynched()) + { + await Task.Delay(10).ConfigureAwait(false); + } } private string FindBTCPayServerDirectory() diff --git a/BTCPayServer.Tests/SeleniumTester.cs b/BTCPayServer.Tests/SeleniumTester.cs index d2156e61f..8d1ca130f 100644 --- a/BTCPayServer.Tests/SeleniumTester.cs +++ b/BTCPayServer.Tests/SeleniumTester.cs @@ -19,7 +19,6 @@ namespace BTCPayServer.Tests public static SeleniumTester Create([CallerMemberNameAttribute] string scope = null) { - var server = ServerTester.Create(scope); return new SeleniumTester() { @@ -45,6 +44,7 @@ namespace BTCPayServer.Tests } Logs.Tester.LogInformation("Selenium: Browsing to " + Server.PayTester.ServerUri); Driver.Navigate().GoToUrl(Server.PayTester.ServerUri); + Driver.AssertNoError(); }