Loading...
Loading...
Builds Sorcha.UI Blazor WASM pages with accompanying Playwright E2E tests using the Docker test infrastructure. Use when: Working on Sorcha.UI, building new pages, replacing template pages, adding UI features, or testing UI functionality against Docker.
npx skill4agent add stuartf303/sorcha sorcha-uidocker-compose up -ddocker-compose up -d
# UI at http://localhost:5400 | API Gateway at http://localhost:80
# Login: admin@sorcha.local / Dev_Pass_2025!tests/Sorcha.UI.E2E.Tests/PageObjects/{PageName}Page.csusing Microsoft.Playwright;
using Sorcha.UI.E2E.Tests.Infrastructure;
using Sorcha.UI.E2E.Tests.PageObjects.Shared;
namespace Sorcha.UI.E2E.Tests.PageObjects;
public class WalletListPage
{
private readonly IPage _page;
public WalletListPage(IPage page) => _page = page;
// Use data-testid as primary selector strategy
public ILocator WalletCards => MudBlazorHelpers.TestIdPrefix(_page, "wallet-card-");
public ILocator CreateButton => MudBlazorHelpers.TestId(_page, "create-wallet-btn");
public ILocator EmptyState => MudBlazorHelpers.TestId(_page, "wallet-empty-state");
public ILocator SearchInput => _page.Locator("input[placeholder*='Search']");
// Fallback to MudBlazor class selectors
public ILocator Table => MudBlazorHelpers.Table(_page);
public ILocator LoadingSpinner => MudBlazorHelpers.CircularProgress(_page);
public async Task NavigateAsync()
{
await _page.GotoAsync($"{TestConstants.UiWebUrl}{TestConstants.AuthenticatedRoutes.Wallets}");
await _page.WaitForLoadStateAsync(LoadState.NetworkIdle);
await MudBlazorHelpers.WaitForBlazorAsync(_page);
}
public async Task<int> GetWalletCountAsync() => await WalletCards.CountAsync();
public async Task<bool> IsEmptyStateVisibleAsync() =>
await EmptyState.CountAsync() > 0 && await EmptyState.IsVisibleAsync();
}tests/Sorcha.UI.E2E.Tests/Docker/{Feature}Tests.csusing Sorcha.UI.E2E.Tests.Infrastructure;
using Sorcha.UI.E2E.Tests.PageObjects;
namespace Sorcha.UI.E2E.Tests.Docker;
[Parallelizable(ParallelScope.Self)]
[TestFixture]
[Category("Docker")]
[Category("Wallets")]
[Category("Authenticated")]
public class WalletListTests : AuthenticatedDockerTestBase
{
private WalletListPage _walletList = null!;
[SetUp]
public override async Task BaseSetUp()
{
await base.BaseSetUp();
_walletList = new WalletListPage(Page);
}
[Test]
[Retry(2)]
public async Task WalletList_LoadsWithoutErrors()
{
await NavigateAuthenticatedAsync(TestConstants.AuthenticatedRoutes.Wallets);
// Base class automatically checks console errors, network 5xx, CSS health
}
[Test]
public async Task WalletList_ShowsEmptyStateOrWallets()
{
await _walletList.NavigateAsync();
var count = await _walletList.GetWalletCountAsync();
if (count == 0)
{
Assert.That(await _walletList.IsEmptyStateVisibleAsync(), Is.True,
"Empty system should show empty state message");
}
else
{
Assert.That(count, Is.GreaterThan(0));
}
}
}src/Apps/Sorcha.UI/Sorcha.UI.Web.Client/Pages/{Page}.razor@page "/wallets"
@layout MainLayout
@rendermode @(new InteractiveWebAssemblyRenderMode(prerender: false))
@attribute [Authorize]
@inject HttpClient Http
<PageTitle>Wallets - Sorcha</PageTitle>
@if (_isLoading)
{
<MudProgressCircular Indeterminate="true" data-testid="wallet-loading" />
}
else if (_wallets.Count == 0)
{
<MudAlert Severity="Severity.Info" data-testid="wallet-empty-state">
No wallets found. Create your first wallet to get started.
</MudAlert>
}
else
{
@foreach (var wallet in _wallets)
{
<MudCard data-testid="wallet-card-@wallet.Id" Class="mb-3">
<MudCardContent>
<MudText Typo="Typo.h6">@wallet.Name</MudText>
</MudCardContent>
</MudCard>
}
}
<MudButton data-testid="create-wallet-btn" Variant="Variant.Filled"
Color="Color.Primary" Href="wallets/create">
Create Wallet
</MudButton># Run tests for the feature you just built
dotnet test tests/Sorcha.UI.E2E.Tests --filter "Category=Wallets"
# Run all smoke tests (fast CI gate)
dotnet test tests/Sorcha.UI.E2E.Tests --filter "Category=Smoke"
# Run all Docker tests
dotnet test tests/Sorcha.UI.E2E.Tests --filter "Category=Docker"tests/Sorcha.UI.E2E.Tests/bin/Debug/net10.0/screenshots/| Concept | Usage | Location |
|---|---|---|
| Unauthenticated tests with auto error capture | |
| Login once, reuse auth state across tests | |
| URLs, credentials, routes, timeouts | |
| Page Objects | Encapsulate selectors and actions per page | |
| Shared MudBlazor locators and layout validation | |
| Primary selector strategy for resilient tests | Added to Razor components |
| Categories | Filter tests by feature or concern | |
PageTest (Playwright NUnit)
└── DockerTestBase (console errors, network failures, screenshots)
├── ComponentHealthTests, LoginTests (unauthenticated)
└── AuthenticatedDockerTestBase (login once, reuse state, layout health)
├── DashboardTests
├── NavigationTests
├── WalletTests
└── ... (one per feature area)| Category | Scope | Use |
|---|---|---|
| All pages load, no JS errors | CI gate |
| All tests targeting Docker | Full Docker suite |
| Login, logout, redirects | Authentication features |
| All tests needing login | Post-login features |
| Dashboard page | Dashboard development |
| Drawer, app bar, routing | Layout changes |
| CSS, MudBlazor, responsive | Style/component changes |
| Wallet pages | Wallet features |
| Blueprint pages | Blueprint features |
| Register pages | Register features |
| Schema library | Schema features |
| Administration pages | Admin features |
| What | Where |
|---|---|
| Blazor pages | |
| Shared components | |
| Layout | |
| Test infrastructure | |
| Page objects | |
| Docker tests | |
| MudBlazor helpers | |
Fetch latest Playwright .NET and MudBlazor documentation with Context7.
/websites/playwright_dev_dotnet/websites/mudblazor