Basics Done

This commit is contained in:
2026-04-13 15:08:49 +05:00
parent 9bef5813ae
commit 06ec22704b
75 changed files with 5036 additions and 2733 deletions
@@ -0,0 +1,47 @@
using Microsoft.Playwright;
namespace Enciphered.Blazor.UIComponents.Tests;
/// <summary>
/// Base class for Playwright tests. Creates a fresh browser context per test.
/// </summary>
public abstract class PlaywrightTestBase
{
protected IBrowser Browser { get; private set; } = null!;
protected IBrowserContext Context { get; private set; } = null!;
protected IPage Page { get; private set; } = null!;
protected string BaseUrl => GlobalSetup.Server.BaseUrl;
protected static ILocatorAssertions Expect(ILocator locator) => Assertions.Expect(locator);
protected static IPageAssertions Expect(IPage page) => Assertions.Expect(page);
private static IPlaywright? _playwright;
private static IBrowser? _sharedBrowser;
[OneTimeSetUp]
public async Task PlaywrightOneTimeSetUp()
{
_playwright ??= await Playwright.CreateAsync();
_sharedBrowser ??= await _playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions
{
Headless = true
});
Browser = _sharedBrowser;
}
[SetUp]
public async Task PlaywrightSetUp()
{
Context = await Browser.NewContextAsync(new BrowserNewContextOptions
{
IgnoreHTTPSErrors = true
});
Page = await Context.NewPageAsync();
}
[TearDown]
public async Task PlaywrightTearDown()
{
await Context.CloseAsync();
}
}