feat(central-ui): Notification report accepts ?correlationId= and opens the notification's detail
Claude-Session: https://claude.ai/code/session_01NcMG6xXdsJbmD2wYAgkK29
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System.Security.Claims;
|
||||
using Akka.Actor;
|
||||
using Bunit;
|
||||
using Bunit.TestDoubles;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -46,7 +48,9 @@ public class NotificationReportPageTests : BunitContext
|
||||
DeliveredAt: DateTimeOffset.UtcNow.AddHours(-2), IsStuck: false),
|
||||
}, TotalCount: 2);
|
||||
|
||||
// Records the most recent retry/discard requests the actor received.
|
||||
// Records every outbox query the page issued (filter assertions) and the
|
||||
// most recent retry/discard requests the actor received.
|
||||
private readonly List<NotificationOutboxQueryRequest> _queryRequests = new();
|
||||
private readonly List<RetryNotificationRequest> _retryRequests = new();
|
||||
private readonly List<DiscardNotificationRequest> _discardRequests = new();
|
||||
|
||||
@@ -237,6 +241,91 @@ public class NotificationReportPageTests : BunitContext
|
||||
Assert.Contains("View audit history", link.TextContent);
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
// Flow Debugger follow-ups (register row 111, plan D2): ?correlationId=
|
||||
// seeds a read-only Notification pill filter, rides the query as
|
||||
// NotificationIdFilter, and auto-opens the detail when exactly one row
|
||||
// with that id comes back.
|
||||
// ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
[Fact]
|
||||
public void NotificationReport_CorrelationIdQuery_SeedsTheNotificationFilterAndAutoOpensDetail()
|
||||
{
|
||||
const string id = "notif-aaaaaaaa-1111";
|
||||
_queryReply = new NotificationOutboxQueryResponse(
|
||||
"q", true, null, new List<NotificationSummary>
|
||||
{
|
||||
new(id, "Email", "Ops On-Call", "Pump fault at Plant-A",
|
||||
"Parked", RetryCount: 3, LastError: "SMTP timeout", SourceSiteId: "plant-a",
|
||||
SourceInstanceId: "Pump-001", CreatedAt: DateTimeOffset.UtcNow.AddMinutes(-30),
|
||||
DeliveredAt: null, IsStuck: true),
|
||||
}, TotalCount: 1);
|
||||
|
||||
var nav = (BunitNavigationManager)Services.GetRequiredService<NavigationManager>();
|
||||
nav.NavigateTo($"/notifications/report?correlationId={id}");
|
||||
|
||||
var cut = Render<NotificationReportPage>();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
// The very first fetch already carries the exact-match filter.
|
||||
Assert.Single(_queryRequests);
|
||||
Assert.Equal(id, _queryRequests[0].NotificationIdFilter);
|
||||
|
||||
// The read-only pill names the notification by its short id.
|
||||
var pill = cut.Find("[data-test='notif-filter-notification']");
|
||||
Assert.Contains("Notification", pill.TextContent);
|
||||
Assert.Contains(id[..12], pill.TextContent);
|
||||
|
||||
// Exactly one matching row came back → the detail modal is open on it.
|
||||
var modal = cut.Find(".modal.show");
|
||||
Assert.Contains("Pump fault at Plant-A", modal.TextContent);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClearFilters_DropsTheNotificationFilter()
|
||||
{
|
||||
var nav = (BunitNavigationManager)Services.GetRequiredService<NavigationManager>();
|
||||
nav.NavigateTo("/notifications/report?correlationId=notif-aaaaaaaa-1111");
|
||||
|
||||
var cut = Render<NotificationReportPage>();
|
||||
cut.WaitForState(() => cut.FindAll("[data-test='notif-filter-notification']").Count == 1);
|
||||
|
||||
// The pill alone makes the filter set "active" — Clear is enabled.
|
||||
var clear = cut.FindAll("button").First(b => b.TextContent.Trim() == "Clear");
|
||||
Assert.False(clear.HasAttribute("disabled"));
|
||||
|
||||
clear.Click();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
Assert.Empty(cut.FindAll("[data-test='notif-filter-notification']"));
|
||||
var clearAfter = cut.FindAll("button").First(b => b.TextContent.Trim() == "Clear");
|
||||
Assert.True(clearAfter.HasAttribute("disabled"));
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NotificationFilterPill_Clear_DropsTheFilterAndRequeries()
|
||||
{
|
||||
var nav = (BunitNavigationManager)Services.GetRequiredService<NavigationManager>();
|
||||
nav.NavigateTo("/notifications/report?correlationId=notif-aaaaaaaa-1111");
|
||||
|
||||
var cut = Render<NotificationReportPage>();
|
||||
cut.WaitForState(() => cut.FindAll("[data-test='notif-filter-notification-clear']").Count == 1);
|
||||
|
||||
cut.Find("[data-test='notif-filter-notification-clear']").Click();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
Assert.Empty(cut.FindAll("[data-test='notif-filter-notification']"));
|
||||
// The × re-runs the query without the id filter.
|
||||
Assert.Equal(2, _queryRequests.Count);
|
||||
Assert.Null(_queryRequests[1].NotificationIdFilter);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
@@ -254,7 +343,24 @@ public class NotificationReportPageTests : BunitContext
|
||||
{
|
||||
public ScriptedOutboxActor(NotificationReportPageTests test)
|
||||
{
|
||||
Receive<NotificationOutboxQueryRequest>(_ => Sender.Tell(test._queryReply));
|
||||
Receive<NotificationOutboxQueryRequest>(req =>
|
||||
{
|
||||
test._queryRequests.Add(req);
|
||||
Sender.Tell(test._queryReply with { CorrelationId = req.CorrelationId });
|
||||
});
|
||||
// The ?correlationId= auto-open path fetches the row's full detail;
|
||||
// reply with a minimal detail so the modal settles instead of the
|
||||
// Ask timing out.
|
||||
Receive<NotificationDetailRequest>(r => Sender.Tell(new NotificationDetailResponse(
|
||||
r.CorrelationId, true, null,
|
||||
new NotificationDetail(
|
||||
r.NotificationId, "Email", "Ops On-Call", "Pump fault at Plant-A",
|
||||
"Body", "Parked", RetryCount: 3, LastError: "SMTP timeout",
|
||||
ResolvedTargets: null, TypeData: null, SourceSiteId: "plant-a",
|
||||
SourceInstanceId: "Pump-001", SourceScript: null,
|
||||
SiteEnqueuedAt: DateTimeOffset.UtcNow.AddMinutes(-31),
|
||||
CreatedAt: DateTimeOffset.UtcNow.AddMinutes(-30),
|
||||
LastAttemptAt: null, NextAttemptAt: null, DeliveredAt: null))));
|
||||
Receive<RetryNotificationRequest>(r =>
|
||||
{
|
||||
test._retryRequests.Add(r);
|
||||
|
||||
Reference in New Issue
Block a user