using Bunit; using Duempelkas.App.Components; using Duempelkas.App.Services; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Rendering; using Microsoft.Extensions.DependencyInjection; using Xunit; namespace Duempelkas.Tests; public class ErrorRecoveryTests { [Fact] public void UnexpectedError_OffersRecoveryWithoutLeakingBookingData() { using var context = new BunitContext(); context.Services.AddSingleton(); var boundary = context.Render(p => p.AddChildContent()); boundary.WaitForAssertion(() => Assert.Contains("nicht bestätigt", boundary.Markup)); Assert.Contains("Zur Kontenübersicht", boundary.Markup); Assert.Contains("InvalidOperationException", boundary.Markup); Assert.DoesNotContain("SECRET_BOOKING_DATA", boundary.Markup); } private sealed class Throws : ComponentBase { protected override void BuildRenderTree(RenderTreeBuilder builder) => throw new InvalidOperationException("SECRET_BOOKING_DATA"); } }