using System.Net; using MeterVault.App; using MeterVault.App.Analysis; using MeterVault.App.Components.Shared.Analysis; using MeterVault.App.Theme; using MeterVault.Core.Analysis; using MeterVault.Core.Analysis.Coverage; using MeterVault.Infrastructure.Analysis; using MeterVault.Infrastructure.Options; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Web; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; using Microsoft.JSInterop; using MudBlazor.Services; using static MeterVault.Integration.Tests.Analysis.AnalysisUiTestData; namespace MeterVault.Integration.Tests.Analysis; /// /// The shared analysis components rendered to HTML with the framework's static (no bUnit, no /// browser): they render with real MudBlazor services, the title is the page's h1, the toolbar shows the effective /// dates, the table says "—" and speaks statuses, the empty and error states offer their actions, attention items link /// to their fix. Static rendering proves the markup, not the interactive chart or navigation — those are covered by the /// pure model tests and the manual checklist. /// public sealed class AnalysisComponentRenderTests { [Fact] public async Task The_page_header_is_the_pages_h1_with_breadcrumbs_carrying_the_period() { var ytd = AnalysisQuery.Default(AnalysisDefaults.History.ForScope(QueryScope.ForMeter(5))).WithPeriod(PeriodPreset.YearToDate); RenderFragment crumbs = builder => { builder.OpenComponent(0); builder.AddComponentParameter(1, nameof(AnalysisBreadcrumbs.Query), ytd); builder.AddComponentParameter(2, nameof(AnalysisBreadcrumbs.EnergyTypeId), 1); builder.AddComponentParameter(3, nameof(AnalysisBreadcrumbs.EnergyTypeName), "Strom"); builder.AddComponentParameter(4, nameof(AnalysisBreadcrumbs.MeterId), 5); builder.AddComponentParameter(5, nameof(AnalysisBreadcrumbs.MeterName), "Wärmepumpe "); builder.CloseComponent(); }; var raw = await RenderRawAsync("en", new() { [nameof(PageHeader.Title)] = "Wärmepumpe ", [nameof(PageHeader.Description)] = "Heat pump", [nameof(PageHeader.Breadcrumbs)] = crumbs, }); var html = WebUtility.HtmlDecode(raw); // User data is text, never markup; the title is the page's one h1. Assert.Contains("<Keller>", raw, StringComparison.Ordinal); Assert.Contains("

Wärmepumpe

", html, StringComparison.Ordinal); Assert.Contains("href=\"/?period=ytd\"", html, StringComparison.Ordinal); Assert.Contains("href=\"/energy/1?period=ytd\"", html, StringComparison.Ordinal); Assert.Contains("