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:
+70
-1
@@ -5,7 +5,9 @@
|
|||||||
@using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories
|
@using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories
|
||||||
@using ZB.MOM.WW.ScadaBridge.Commons.Messages.Notification
|
@using ZB.MOM.WW.ScadaBridge.Commons.Messages.Notification
|
||||||
@using ZB.MOM.WW.ScadaBridge.Communication
|
@using ZB.MOM.WW.ScadaBridge.Communication
|
||||||
|
@using Microsoft.AspNetCore.WebUtilities
|
||||||
@inject CommunicationService CommunicationService
|
@inject CommunicationService CommunicationService
|
||||||
|
@inject NavigationManager Navigation
|
||||||
@inject ISiteRepository SiteRepository
|
@inject ISiteRepository SiteRepository
|
||||||
@inject SiteScopeService SiteScope
|
@inject SiteScopeService SiteScope
|
||||||
@inject IDialogService Dialog
|
@inject IDialogService Dialog
|
||||||
@@ -88,6 +90,20 @@
|
|||||||
<label class="form-check-label small" for="no-stuck-only">Stuck only</label>
|
<label class="form-check-label small" for="no-stuck-only">Stuck only</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@if (_notificationIdFilter is { } notifFilter)
|
||||||
|
{
|
||||||
|
@* Register row 111 (D2): read-only exact-match pill seeded from the
|
||||||
|
?correlationId= deep link (Flow Debugger / Audit Log). Cleared by
|
||||||
|
its × (re-queries) or by Clear. *@
|
||||||
|
<div class="col-auto">
|
||||||
|
<span class="badge text-bg-secondary" data-test="notif-filter-notification"
|
||||||
|
title="@notifFilter">Notification @ShortId(notifFilter)</span>
|
||||||
|
<button type="button" class="btn btn-link btn-sm p-0 ms-1 text-decoration-none"
|
||||||
|
data-test="notif-filter-notification-clear"
|
||||||
|
aria-label="Clear notification filter" title="Clear notification filter"
|
||||||
|
@onclick="ClearNotificationFilter">×</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<button class="btn btn-outline-secondary btn-sm" @onclick="ClearFilters"
|
<button class="btn btn-outline-secondary btn-sm" @onclick="ClearFilters"
|
||||||
disabled="@(!HasActiveFilters)">Clear</button>
|
disabled="@(!HasActiveFilters)">Clear</button>
|
||||||
@@ -439,6 +455,11 @@
|
|||||||
private DateTime? _fromFilter;
|
private DateTime? _fromFilter;
|
||||||
private DateTime? _toFilter;
|
private DateTime? _toFilter;
|
||||||
|
|
||||||
|
// Register row 111 (D2): exact-match NotificationId seeded from ?correlationId=.
|
||||||
|
// Not bound to a control — surfaced as a read-only pill in the filter card.
|
||||||
|
private string? _notificationIdFilter;
|
||||||
|
private const int MaxNotificationIdFilterLength = 64;
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -457,7 +478,52 @@
|
|||||||
Logger.LogWarning(ex, "Failed to load sites for the report source-site filter.");
|
Logger.LogWarning(ex, "Failed to load sites for the report source-site filter.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Seed the ?correlationId= filter BEFORE the first fetch so the initial grid
|
||||||
|
// load is already narrowed to the linked notification.
|
||||||
|
ApplyQueryStringFilters();
|
||||||
|
|
||||||
await RefreshAll();
|
await RefreshAll();
|
||||||
|
|
||||||
|
// Deep link landed on exactly the row it named — open its detail so the
|
||||||
|
// operator does not have to find and double-click it.
|
||||||
|
if (_notificationIdFilter is { } wanted
|
||||||
|
&& _notifications is { Count: 1 }
|
||||||
|
&& _notifications[0].NotificationId == wanted)
|
||||||
|
{
|
||||||
|
await ShowDetail(_notifications[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Pre-apply the <c>?correlationId=</c> deep-link filter from the URL query
|
||||||
|
/// string (Flow Debugger External-lane node / Audit Log convention). The value
|
||||||
|
/// is the notification's own id (a string, not a GUID) — accepted trimmed when
|
||||||
|
/// non-blank and at most <see cref="MaxNotificationIdFilterLength"/> chars;
|
||||||
|
/// anything else is silently dropped, leaving the page unfiltered.
|
||||||
|
/// </summary>
|
||||||
|
private void ApplyQueryStringFilters()
|
||||||
|
{
|
||||||
|
var uri = Navigation.ToAbsoluteUri(Navigation.Uri);
|
||||||
|
var query = QueryHelpers.ParseQuery(uri.Query);
|
||||||
|
if (query.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (query.TryGetValue("correlationId", out var values))
|
||||||
|
{
|
||||||
|
var candidate = values.ToString()?.Trim();
|
||||||
|
if (!string.IsNullOrEmpty(candidate) && candidate.Length <= MaxNotificationIdFilterLength)
|
||||||
|
{
|
||||||
|
_notificationIdFilter = candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ClearNotificationFilter()
|
||||||
|
{
|
||||||
|
_notificationIdFilter = null;
|
||||||
|
await Search();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RefreshAll()
|
private async Task RefreshAll()
|
||||||
@@ -491,7 +557,8 @@
|
|||||||
To: ToUtc(_toFilter),
|
To: ToUtc(_toFilter),
|
||||||
PageNumber: _pageNumber,
|
PageNumber: _pageNumber,
|
||||||
PageSize: _pageSize,
|
PageSize: _pageSize,
|
||||||
SourceNodeFilter: NullIfEmpty(_nodeFilter));
|
SourceNodeFilter: NullIfEmpty(_nodeFilter),
|
||||||
|
NotificationIdFilter: _notificationIdFilter);
|
||||||
|
|
||||||
var response = await CommunicationService.QueryNotificationOutboxAsync(request);
|
var response = await CommunicationService.QueryNotificationOutboxAsync(request);
|
||||||
if (response.Success)
|
if (response.Success)
|
||||||
@@ -693,9 +760,11 @@
|
|||||||
_stuckOnly = false;
|
_stuckOnly = false;
|
||||||
_fromFilter = null;
|
_fromFilter = null;
|
||||||
_toFilter = null;
|
_toFilter = null;
|
||||||
|
_notificationIdFilter = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HasActiveFilters =>
|
private bool HasActiveFilters =>
|
||||||
|
_notificationIdFilter != null ||
|
||||||
!string.IsNullOrEmpty(_statusFilter) ||
|
!string.IsNullOrEmpty(_statusFilter) ||
|
||||||
!string.IsNullOrEmpty(_typeFilter) ||
|
!string.IsNullOrEmpty(_typeFilter) ||
|
||||||
!string.IsNullOrEmpty(_siteFilter) ||
|
!string.IsNullOrEmpty(_siteFilter) ||
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using Akka.Actor;
|
using Akka.Actor;
|
||||||
using Bunit;
|
using Bunit;
|
||||||
|
using Bunit.TestDoubles;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.AspNetCore.Components.Authorization;
|
using Microsoft.AspNetCore.Components.Authorization;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@@ -46,7 +48,9 @@ public class NotificationReportPageTests : BunitContext
|
|||||||
DeliveredAt: DateTimeOffset.UtcNow.AddHours(-2), IsStuck: false),
|
DeliveredAt: DateTimeOffset.UtcNow.AddHours(-2), IsStuck: false),
|
||||||
}, TotalCount: 2);
|
}, 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<RetryNotificationRequest> _retryRequests = new();
|
||||||
private readonly List<DiscardNotificationRequest> _discardRequests = new();
|
private readonly List<DiscardNotificationRequest> _discardRequests = new();
|
||||||
|
|
||||||
@@ -237,6 +241,91 @@ public class NotificationReportPageTests : BunitContext
|
|||||||
Assert.Contains("View audit history", link.TextContent);
|
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)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
@@ -254,7 +343,24 @@ public class NotificationReportPageTests : BunitContext
|
|||||||
{
|
{
|
||||||
public ScriptedOutboxActor(NotificationReportPageTests test)
|
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 =>
|
Receive<RetryNotificationRequest>(r =>
|
||||||
{
|
{
|
||||||
test._retryRequests.Add(r);
|
test._retryRequests.Add(r);
|
||||||
|
|||||||
@@ -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.Services;
|
||||||
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Transport;
|
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Transport;
|
||||||
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Audit;
|
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.Commons.Types.Transport;
|
||||||
using ZB.MOM.WW.ScadaBridge.Communication;
|
using ZB.MOM.WW.ScadaBridge.Communication;
|
||||||
using ZB.MOM.WW.ScadaBridge.ConfigurationDatabase;
|
using ZB.MOM.WW.ScadaBridge.ConfigurationDatabase;
|
||||||
using ZB.MOM.WW.ScadaBridge.Transport;
|
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 SiteCallsReportPage = ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.SiteCalls.SiteCallsReport;
|
||||||
using TransportImportPage = ZB.MOM.WW.ScadaBridge.CentralUI.Components.Pages.Design.TransportImport;
|
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
|
// 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
|
private sealed class AlwaysConfirmDialogService : IDialogService
|
||||||
{
|
{
|
||||||
public Task<bool> ConfirmAsync(string title, string message, bool danger = false, string? confirmLabel = null)
|
public Task<bool> ConfirmAsync(string title, string message, bool danger = false, string? confirmLabel = null)
|
||||||
|
|||||||
Reference in New Issue
Block a user