What changed, and why it matters
This commit fixes a flaky automated UI test by making the test wait until a notifications component has finished rendering before checking its contents. The code change adds a 'rendered' CSS class once Blazor has finished pre-rendering and updates the test to look for that class. There is no security relevance.
No security action needed; this is a test reliability fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The Blazor component NotificationsDropDown.razor now conditionally adds a ‘rendered’ class to its root div after JavaScript runtime pre-rendering completes. The Playwright UI test is updated to wait for ‘#Notifications.rendered’ before asserting notification badge text and list content. This eliminates a race condition where the test asserted on elements before the component had hydrated.
Changed components
BTCPayServer/Blazor/NotificationsDropDown.razorBTCPayServer.Tests/PlaywrightTests.csInspect captured patch +2 / −1
diff --git a/BTCPayServer.Tests/PlaywrightTests.cs b/BTCPayServer.Tests/PlaywrightTests.cs
index b312db4..7bd0757 100644
--- a/BTCPayServer.Tests/PlaywrightTests.cs
+++ b/BTCPayServer.Tests/PlaywrightTests.cs
@@ -1538,6 +1538,7 @@ namespace BTCPayServer.Tests
await s.LogIn(admin.RegisterDetails.Email, admin.RegisterDetails.Password);
await s.GoToHome();
+ await Expect(s.Page.Locator("#Notifications.rendered")).ToBeVisibleAsync();
await Expect(s.Page.Locator("#NotificationsBadge")).ToContainTextAsync("1");
await s.Page.ClickAsync("#NotificationsHandle");
await Expect(s.Page.Locator("#NotificationsList .notification")).ToContainTextAsync($"New user {unapproved.RegisterDetails.Email} requires approval");
diff --git a/BTCPayServer/Blazor/NotificationsDropDown.razor b/BTCPayServer/Blazor/NotificationsDropDown.razor
index 4102ec4..35bc2cd 100644
--- a/BTCPayServer/Blazor/NotificationsDropDown.razor
+++ b/BTCPayServer/Blazor/NotificationsDropDown.razor
@@ -15,7 +15,7 @@
@inject BTCPayServerOptions _BTCPayServerOptions
@inject EventAggregator _EventAggregator
-<div id="Notifications">
+<div id="Notifications" class="@(!_JSRuntime.IsPreRendering() ? "rendered" : "")">
@if (UnseenCount == "0")
{
<a href="@NotificationsUrl" id="NotificationsHandle" class="mainMenuButton" title="@StringLocalizer["Notifications"]">
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.