Test fixes

This commit is contained in:
Dennis Reimann 2023-08-23 18:12:53 +02:00
parent 5ccbf51d7d
commit ffb0ba9df7
No known key found for this signature in database
GPG Key ID: 5009E1797F03F8D0
4 changed files with 24 additions and 16 deletions

View File

@ -13,7 +13,7 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.8" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.0.8" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
<PackageReference Include="Microsoft.Playwright" Version="1.35.0" />
<PackageReference Include="Microsoft.Playwright" Version="1.37.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@ -111,20 +111,19 @@ class BaseWebApplicationFactory<T> : WebApplicationFactory<T> where T : class
private static void InstallPlaywright()
{
var exitCode = Microsoft.Playwright.Program.Main(
new[] {"install-deps"});
if (exitCode != 0)
var exitCode = Microsoft.Playwright.Program.Main(new[] {"install-deps"});
/*if (exitCode != 0)
{
throw new Exception(
$"Playwright exited with code {exitCode} on install-deps");
}
}*/
exitCode = Microsoft.Playwright.Program.Main(new[] {"install"});
if (exitCode != 0)
/*if (exitCode != 0)
{
throw new Exception(
$"Playwright exited with code {exitCode} on install");
}
}*/
}
@ -133,12 +132,16 @@ class BaseWebApplicationFactory<T> : WebApplicationFactory<T> where T : class
Assert.NotNull(ServerAddress);
await _playwrightInstallTask;
Playwright = await Microsoft.Playwright.Playwright.CreateAsync();
Browser = await Playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions()
Browser = await Playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
{
Headless = false,
});
return await Browser.NewContextAsync(new BrowserNewContextOptions());
return await Browser.NewContextAsync(new BrowserNewContextOptions
{
IgnoreHTTPSErrors = true,
IsMobile = true
});
}
public IPlaywright? Playwright { get; set; }

View File

@ -11,7 +11,7 @@ public class UnitTest1
{
_testOutputHelper = testOutputHelper;
}
[Fact]
public async Task Test1()
{
@ -20,13 +20,18 @@ public class UnitTest1
await page.GotoAsync(factory.ServerAddress);
factory.Eventually(() =>
{
Assert.EndsWith(Routes.FirstRun, page.Url);
Assert.EndsWith(Routes.Home, page.Url);
});
await (await page.QuerySelectorAsync("#btn-pair")).ClickAsync();
Thread.Sleep(3000);
var carousel = await page.QuerySelectorAsync("#OnboardingCarousel");
await (await carousel.QuerySelectorAsync("[aria-label='3']")).ClickAsync();
Thread.Sleep(3000);
await (await page.QuerySelectorAsync("#PairButton")).ClickAsync();
factory.Eventually(() =>
{
Assert.EndsWith(Routes.Pair, page.Url);
});
}
}
}

View File

@ -30,8 +30,8 @@
<MudText Typo="Typo.subtitle1" Align="Align.Center" Class="flex-grow-1">
Free and open-source bitcoin point of sale. With 0% Fees & No Third-party.
</MudText>
<MudButton Size="Size.Large" Variant="Variant.Filled" Color="Color.Primary" Href="@Routes.Pair" id="btn-pair">Pair with BTCPay Server</MudButton>
<MudButton Size="Size.Large" Variant="Variant.Filled" Color="Color.Primary" Href="@Routes.Standalone" Disabled="true" id="btn-standalone">Use standalone</MudButton>
<MudButton Size="Size.Large" Variant="Variant.Filled" Color="Color.Primary" Href="@Routes.Pair" id="PairButton">Pair with BTCPay Server</MudButton>
<MudButton Size="Size.Large" Variant="Variant.Filled" Color="Color.Primary" Href="@Routes.Standalone" Disabled="true" id="StandaloneButton">Use standalone</MudButton>
</MudContainer>
</MudCarouselItem>
</MudCarousel>