tests(apphost.tests): added support for end to end testing using playwright
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
|
||||
|
||||
namespace FiscalOS.AppHost.Tests.Infra;
|
||||
|
||||
public abstract class BaseTest(
|
||||
AspireFixture aspire,
|
||||
PlaywrightFixture playwright
|
||||
) : IAsyncLifetime, IClassFixture<AspireFixture>, IClassFixture<PlaywrightFixture>
|
||||
{
|
||||
protected AspireFixture AspireFixture { get; } = aspire;
|
||||
protected PlaywrightFixture PlaywrightFixture { get; } = playwright;
|
||||
|
||||
protected IBrowserContext Context { get; private set; } = null!;
|
||||
protected IPage Page { get; private set; } = null!;
|
||||
|
||||
public async ValueTask InitializeAsync()
|
||||
{
|
||||
Context = await PlaywrightFixture.Browser.NewContextAsync(new()
|
||||
{
|
||||
BaseURL = AspireFixture.GetBaseWebUri().ToString(),
|
||||
});
|
||||
Page = await Context.NewPageAsync();
|
||||
}
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
await Page.CloseAsync();
|
||||
await Context.CloseAsync();
|
||||
await Context.DisposeAsync();
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public static ILocatorAssertions Expect(ILocator locator)
|
||||
{
|
||||
return Assertions.Expect(locator);
|
||||
}
|
||||
|
||||
public static IPageAssertions Expect(IPage page)
|
||||
{
|
||||
return Assertions.Expect(page);
|
||||
}
|
||||
|
||||
public static IAPIResponseAssertions Expect(IAPIResponse response)
|
||||
{
|
||||
return Assertions.Expect(response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user