250a93e718
- Add IDashboardSummaryService/DashboardSummaryService: real event/snapshot/ anomaly counts, top-5 signals, and per-stage pipeline health from worker state. - Home: replace hard-coded zeros + placeholder feed with live data, a clickable signal feed, and a first-run empty state with a Settings CTA. - MainLayout: add an appbar capture-status pill (Capturing/Paused) bound to the poller toggles, refreshed via IOptionsMonitor.OnChange. - MyBets: success snackbar on bet submit. Backtest: surface a Cancel button while a run is in flight. - Add en/ru localization for all new strings; register IOptionsMonitor<WorkerOptions> in the bUnit test context for layout-rendering tests.
57 lines
2.3 KiB
C#
57 lines
2.3 KiB
C#
using Bunit;
|
|
using Marathon.UI.Resources;
|
|
using Marathon.UI.Services;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Localization;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
using Microsoft.Extensions.Options;
|
|
using MudBlazor.Services;
|
|
|
|
namespace Marathon.UI.Tests.Support;
|
|
|
|
/// <summary>
|
|
/// Shared bUnit <see cref="TestContext"/> with the Marathon.UI services
|
|
/// pre-registered: localizer, theme + locale state, in-memory settings writer,
|
|
/// MudBlazor services, and a no-op logger.
|
|
/// </summary>
|
|
public abstract class MarathonTestContext : TestContext
|
|
{
|
|
protected TestSettingsWriter Writer { get; } = new();
|
|
protected ThemeState Theme { get; } = new();
|
|
protected LocaleState Locale { get; } = new();
|
|
protected EventBrowsingState BrowsingState { get; } = new();
|
|
protected FakeEventBrowsingService Browsing { get; } = new();
|
|
protected AnomalyBrowsingState AnomalyState { get; } = new();
|
|
protected FakeAnomalyBrowsingService AnomalyBrowsing { get; } = new();
|
|
protected FakeResultsBrowsingService Results { get; } = new();
|
|
|
|
protected MarathonTestContext()
|
|
{
|
|
Services.AddSingleton(Writer);
|
|
Services.AddSingleton<ISettingsWriter>(Writer);
|
|
Services.AddSingleton(Theme);
|
|
Services.AddSingleton(Locale);
|
|
Services.AddSingleton(BrowsingState);
|
|
Services.AddSingleton<IEventBrowsingService>(Browsing);
|
|
Services.AddSingleton(AnomalyState);
|
|
Services.AddSingleton<IAnomalyBrowsingService>(AnomalyBrowsing);
|
|
Services.AddSingleton<IResultsBrowsingService>(Results);
|
|
|
|
// WorkerOptions monitor backs the MainLayout capture-status pill (defaults
|
|
// to all pollers enabled). Tests needing a specific state can re-register.
|
|
Services.AddSingleton<IOptionsMonitor<WorkerOptions>>(
|
|
new TestOptionsMonitor<WorkerOptions>(new WorkerOptions()));
|
|
|
|
Services.AddSingleton(typeof(IStringLocalizer<>), typeof(TestLocalizer<>));
|
|
Services.AddSingleton(typeof(ILogger<>), typeof(NullLogger<>));
|
|
Services.AddLogging();
|
|
|
|
Services.AddMudServices();
|
|
|
|
// bUnit defaults JS interop to Strict; loosen so MudBlazor's interop
|
|
// calls don't blow up tests that aren't asserting on JS-driven UI.
|
|
JSInterop.Mode = JSRuntimeMode.Loose;
|
|
}
|
|
}
|