using Bunit; using Marathon.UI.Pages.Events; using Marathon.UI.Services; using Marathon.UI.Tests.Support; namespace Marathon.UI.Tests.Pages.Events; public sealed class DetailTests : MarathonTestContext { [Fact] public void Renders_not_found_when_detail_is_null() { Browsing.Detail = null; var cut = RenderComponent(p => p.Add(d => d.EventCode, "missing")); cut.WaitForAssertion(() => { cut.Markup.Should().Contain("Detail.NotFound"); }); } [Fact] public void Renders_event_header_and_tabs_for_each_scope() { Browsing.Detail = TestData.Detail(id: "ABC-1"); var cut = RenderComponent(p => p.Add(d => d.EventCode, "ABC-1")); cut.WaitForAssertion(() => { // Two tabs from the seeded detail (Match + Period 1). cut.FindAll(".m-detail-tab").Count.Should().Be(2); cut.Markup.Should().Contain("Arsenal"); cut.Markup.Should().Contain("Chelsea"); cut.Markup.Should().Contain("Detail.Tabs.Match"); }); } [Fact] public void Renders_snapshot_history_entries() { Browsing.Detail = TestData.Detail( id: "ABC-2", new OddsTimelinePoint(DateTimeOffset.UtcNow.AddMinutes(-30), 1.90m, 3.30m, 4.10m), new OddsTimelinePoint(DateTimeOffset.UtcNow.AddMinutes(-15), 1.85m, 3.40m, 4.20m), new OddsTimelinePoint(DateTimeOffset.UtcNow, 1.80m, 3.50m, 4.30m)); var cut = RenderComponent(p => p.Add(d => d.EventCode, "ABC-2")); cut.WaitForAssertion(() => { // Three rows in history table (one per timeline point). // We match the formatted rate cell text instead of generic table rows. cut.Markup.Should().Contain("1.85"); cut.Markup.Should().Contain("1.80"); cut.Markup.Should().Contain("1.90"); }); } [Fact] public void Renders_chart_or_data_table_fallback() { Browsing.Detail = TestData.Detail(id: "ABC-3"); var cut = RenderComponent(p => p.Add(d => d.EventCode, "ABC-3")); cut.WaitForAssertion(() => { cut.Markup.Should().Contain("Detail.Chart.Title"); //
fallback for screen readers cut.Markup.Should().Contain("Detail.Chart.AccessibleSummary"); }); } }