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:
@@ -19,10 +19,12 @@ using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Services;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Transport;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Audit;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Notification;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Types.Transport;
|
||||
using ZB.MOM.WW.ScadaBridge.Communication;
|
||||
using ZB.MOM.WW.ScadaBridge.ConfigurationDatabase;
|
||||
using ZB.MOM.WW.ScadaBridge.Transport;
|
||||
using NotificationReportPage = ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.Notifications.NotificationReport;
|
||||
using SiteCallsReportPage = ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.SiteCalls.SiteCallsReport;
|
||||
using TransportImportPage = ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.Design.TransportImport;
|
||||
|
||||
@@ -104,6 +106,75 @@ public sealed class QueryStringDrillInTests
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// SiteCallsReport — ?correlationId= (Flow Debugger / Audit Log deep link, D2)
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
[Fact]
|
||||
public void SiteCallsReport_CorrelationIdQuery_SeedsTheOperationFilter()
|
||||
{
|
||||
// A well-formed GUID rides on the first query as the exact-match
|
||||
// TrackedOperationIdFilter and renders the read-only Operation pill.
|
||||
var op = Guid.Parse("44444444-4444-4444-4444-444444444444");
|
||||
using var ctx = new SiteCallsReportFixture();
|
||||
var nav = (BunitNavigationManager)ctx.Services.GetRequiredService<NavigationManager>();
|
||||
nav.NavigateTo($"/site-calls/report?correlationId={op}");
|
||||
|
||||
var cut = ctx.Render<SiteCallsReportPage>();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
Assert.Single(ctx.QueryRequests);
|
||||
Assert.Equal(op, ctx.QueryRequests[0].TrackedOperationIdFilter);
|
||||
var pill = cut.Find("[data-test='site-calls-filter-operation']");
|
||||
Assert.Contains(op.ToString("N")[..12], pill.TextContent);
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SiteCallsReport_CorrelationIdQuery_Malformed_IsIgnored()
|
||||
{
|
||||
// Lax parsing, like ?status= — a value that is not a GUID leaves the
|
||||
// filter null and renders no pill, so a hand-crafted bad URL loads the
|
||||
// page unfiltered instead of breaking it.
|
||||
using var ctx = new SiteCallsReportFixture();
|
||||
var nav = (BunitNavigationManager)ctx.Services.GetRequiredService<NavigationManager>();
|
||||
nav.NavigateTo("/site-calls/report?correlationId=nope");
|
||||
|
||||
var cut = ctx.Render<SiteCallsReportPage>();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
Assert.Single(ctx.QueryRequests);
|
||||
Assert.Null(ctx.QueryRequests[0].TrackedOperationIdFilter);
|
||||
});
|
||||
Assert.Empty(cut.FindAll("[data-test='site-calls-filter-operation']"));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// NotificationReport — ?correlationId= (Flow Debugger follow-ups, D2)
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
[Fact]
|
||||
public void NotificationReport_CorrelationIdQuery_Blank_IsIgnored()
|
||||
{
|
||||
// A blank/whitespace ?correlationId= is dropped: the first query carries
|
||||
// no NotificationIdFilter and no pill renders, so a hand-crafted empty
|
||||
// deep link degrades to the plain unfiltered page.
|
||||
using var ctx = new NotificationReportFixture();
|
||||
var nav = (BunitNavigationManager)ctx.Services.GetRequiredService<NavigationManager>();
|
||||
nav.NavigateTo("/notifications/report?correlationId=%20");
|
||||
|
||||
var cut = ctx.Render<NotificationReportPage>();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
Assert.Single(ctx.QueryRequests);
|
||||
Assert.Null(ctx.QueryRequests[0].NotificationIdFilter);
|
||||
Assert.Empty(cut.FindAll("[data-test='notif-filter-notification']"));
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
// TransportImport — no query-string parameters on this route
|
||||
// -----------------------------------------------------------------
|
||||
@@ -209,6 +280,67 @@ public sealed class QueryStringDrillInTests
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class NotificationReportFixture : BunitContext
|
||||
{
|
||||
private readonly ActorSystem _system = ActorSystem.Create("qs-drillin-notif-tests");
|
||||
public readonly CommunicationService Comms;
|
||||
public readonly List<NotificationOutboxQueryRequest> QueryRequests = new();
|
||||
|
||||
public NotificationReportFixture()
|
||||
{
|
||||
Comms = new CommunicationService(
|
||||
Options.Create(new CommunicationOptions()),
|
||||
NullLogger<CommunicationService>.Instance);
|
||||
|
||||
var outbox = _system.ActorOf(Props.Create(() => new ScriptedNotificationOutboxActor(this)));
|
||||
Comms.SetNotificationOutbox(outbox);
|
||||
|
||||
Services.AddSingleton(Comms);
|
||||
Services.AddSingleton<IDialogService>(new AlwaysConfirmDialogService());
|
||||
|
||||
var siteRepo = Substitute.For<ISiteRepository>();
|
||||
siteRepo.GetAllSitesAsync(Arg.Any<CancellationToken>())
|
||||
.Returns(Task.FromResult<IReadOnlyList<Site>>(new List<Site>
|
||||
{
|
||||
new("Plant A", "plant-a") { Id = 1 },
|
||||
}));
|
||||
Services.AddSingleton(siteRepo);
|
||||
|
||||
var claims = new[]
|
||||
{
|
||||
new Claim(JwtTokenService.UsernameClaimType, "tester"),
|
||||
new Claim(JwtTokenService.RoleClaimType, "Deployer"),
|
||||
};
|
||||
var user = new ClaimsPrincipal(new ClaimsIdentity(claims, "TestAuth"));
|
||||
Services.AddSingleton<AuthenticationStateProvider>(new TestAuthStateProvider(user));
|
||||
Services.AddAuthorizationCore();
|
||||
Services.AddScoped<ZB.MOM.WW.ScadaBridge.CentralUI.Auth.SiteScopeService>();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_system.Terminate().Wait(TimeSpan.FromSeconds(5));
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class ScriptedNotificationOutboxActor : ReceiveActor
|
||||
{
|
||||
public ScriptedNotificationOutboxActor(NotificationReportFixture fixture)
|
||||
{
|
||||
Receive<NotificationOutboxQueryRequest>(req =>
|
||||
{
|
||||
fixture.QueryRequests.Add(req);
|
||||
Sender.Tell(new NotificationOutboxQueryResponse(
|
||||
req.CorrelationId, true, null,
|
||||
new List<NotificationSummary>(), TotalCount: 0));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class AlwaysConfirmDialogService : IDialogService
|
||||
{
|
||||
public Task<bool> ConfirmAsync(string title, string message, bool danger = false, string? confirmLabel = null)
|
||||
|
||||
Reference in New Issue
Block a user