Files
maraphon-app/tests/Marathon.UI.Tests/Support/MarathonTestContext.cs
alexei.dolgolyov 9f090cec1f feat(phase-8-frontend): results loader UI + browsing list + 41 localization keys
* Pages/Results/ResultsList.razor — completed-events list with date range,
  sport/winner filter, search, footer count.
* Pages/Results/ResultsLoader.razor — driver page with two modes (load all
  in range / load selected events), live progress reporting via
  IProgress<PullResultsProgress>, summary line, cancellable.
* Replaces the Phase 5 Pages/Results.razor placeholder.

Service layer:
* IResultsBrowsingService + ResultsBrowsingService (Scoped, mirrors the
  Event/Anomaly browsing-service pattern). Reads IResultRepository +
  IEventRepository, projects to immutable view-model records.
* UiServicesExtensions: registers ResultsBrowsingService; also fixes an
  unrelated localization resolver bug (drop ResourcesPath since
  SharedResource lives in the Marathon.UI.Resources namespace already).

Localization:
* 41 new Results.* keys (RU+EN parity) covering both pages, filter chips,
  loader modes, progress states, and footer copy.

Tests:
* ResultsListTests + ResultsLoaderTests — 22 new bUnit tests covering
  filter narrowing, mode switching, progress aggregation, and empty
  states.
* FakeResultsBrowsingService support type for tests.
* MarathonTestContext registers the fake; TestData adds factories for
  EventResult/EventResultListItem.
2026-05-09 15:10:49 +03:00

51 lines
2.0 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 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);
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;
}
}