feat(centralui): open ExecutionDetailModal on tree-node double-click
This commit is contained in:
@@ -7,7 +7,9 @@ using Microsoft.AspNetCore.Components.Authorization;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using NSubstitute;
|
||||
using ScadaLink.CentralUI.Services;
|
||||
using ScadaLink.Commons.Entities.Audit;
|
||||
using ScadaLink.Commons.Types.Audit;
|
||||
using ScadaLink.Commons.Types.Enums;
|
||||
using ScadaLink.Security;
|
||||
using ExecutionTreePage = ScadaLink.CentralUI.Components.Pages.Audit.ExecutionTreePage;
|
||||
|
||||
@@ -111,6 +113,68 @@ public class ExecutionTreePageTests : BunitContext
|
||||
_queryService.DidNotReceive().GetExecutionTreeAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DoubleClickTreeNode_OpensExecutionDetailModal()
|
||||
{
|
||||
var root = Guid.Parse("33333333-3333-3333-3333-333333333333");
|
||||
var child = Guid.Parse("44444444-4444-4444-4444-444444444444");
|
||||
_queryService = Substitute.For<IAuditLogQueryService>();
|
||||
_queryService.GetExecutionTreeAsync(child, Arg.Any<CancellationToken>())
|
||||
.Returns(Task.FromResult<IReadOnlyList<ExecutionTreeNode>>(new List<ExecutionTreeNode>
|
||||
{
|
||||
Node(root, null),
|
||||
Node(child, root),
|
||||
}));
|
||||
// The modal loads the double-clicked execution's audit rows on open.
|
||||
_queryService.QueryAsync(Arg.Any<AuditLogQueryFilter>(), Arg.Any<AuditLogPaging?>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Task.FromResult<IReadOnlyList<AuditEvent>>(Array.Empty<AuditEvent>()));
|
||||
// AuditEventDetail (reachable from the modal) owns a clipboard interop call.
|
||||
JSInterop.Mode = JSRuntimeMode.Loose;
|
||||
|
||||
var cut = RenderPage($"executionId={child}", "Admin");
|
||||
|
||||
// The modal is absent until a node is activated.
|
||||
Assert.Empty(cut.FindAll("[data-test=\"execution-detail-modal\"]"));
|
||||
|
||||
var body = cut.Find($"[data-test=\"tree-node-{child}\"] .execution-tree-body");
|
||||
body.DoubleClick();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
Assert.NotEmpty(cut.FindAll("[data-test=\"execution-detail-modal\"]")));
|
||||
_queryService.Received().QueryAsync(
|
||||
Arg.Is<AuditLogQueryFilter>(f => f.ExecutionId == child),
|
||||
Arg.Any<AuditLogPaging?>(),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClosingExecutionDetailModal_HidesIt()
|
||||
{
|
||||
var root = Guid.Parse("55555555-5555-5555-5555-555555555555");
|
||||
var child = Guid.Parse("66666666-6666-6666-6666-666666666666");
|
||||
_queryService = Substitute.For<IAuditLogQueryService>();
|
||||
_queryService.GetExecutionTreeAsync(child, Arg.Any<CancellationToken>())
|
||||
.Returns(Task.FromResult<IReadOnlyList<ExecutionTreeNode>>(new List<ExecutionTreeNode>
|
||||
{
|
||||
Node(root, null),
|
||||
Node(child, root),
|
||||
}));
|
||||
_queryService.QueryAsync(Arg.Any<AuditLogQueryFilter>(), Arg.Any<AuditLogPaging?>(), Arg.Any<CancellationToken>())
|
||||
.Returns(Task.FromResult<IReadOnlyList<AuditEvent>>(Array.Empty<AuditEvent>()));
|
||||
JSInterop.Mode = JSRuntimeMode.Loose;
|
||||
|
||||
var cut = RenderPage($"executionId={child}", "Admin");
|
||||
|
||||
cut.Find($"[data-test=\"tree-node-{child}\"] .execution-tree-body").DoubleClick();
|
||||
cut.WaitForAssertion(() =>
|
||||
Assert.NotEmpty(cut.FindAll("[data-test=\"execution-detail-modal\"]")));
|
||||
|
||||
cut.Find("[data-test=\"execution-detail-close\"]").Click();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
Assert.Empty(cut.FindAll("[data-test=\"execution-detail-modal\"]")));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ExecutionTreePage_HasOperationalAuditAuthorizeAttribute()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user