feat(notif): NotificationDetailRequest query for full notification detail
This commit is contained in:
@@ -306,6 +306,57 @@ public class NotificationOutboxActorQueryTests : TestKit
|
||||
Assert.Contains("not found", response.ErrorMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetailRequest_KnownId_ReturnsFullDetail_WithBodyAndResolvedTargets()
|
||||
{
|
||||
var row = MakeNotification(
|
||||
status: NotificationStatus.Delivered, retryCount: 2, lastError: "transient blip");
|
||||
row.Body = "Tank-7 has exceeded its high-level setpoint.";
|
||||
row.ResolvedTargets = "[\"ops@example.com\",\"oncall@example.com\"]";
|
||||
row.TypeData = "{\"priority\":\"high\"}";
|
||||
row.SourceScript = "HighLevelAlarm.csx";
|
||||
row.SiteEnqueuedAt = DateTimeOffset.UtcNow.AddMinutes(-5);
|
||||
row.DeliveredAt = DateTimeOffset.UtcNow;
|
||||
_repository.GetByIdAsync(row.NotificationId, Arg.Any<CancellationToken>()).Returns(row);
|
||||
var actor = CreateActor();
|
||||
|
||||
actor.Tell(new NotificationDetailRequest("corr-d1", row.NotificationId), TestActor);
|
||||
|
||||
var response = ExpectMsg<NotificationDetailResponse>();
|
||||
Assert.Equal("corr-d1", response.CorrelationId);
|
||||
Assert.True(response.Success);
|
||||
Assert.Null(response.ErrorMessage);
|
||||
Assert.NotNull(response.Detail);
|
||||
var detail = response.Detail!;
|
||||
Assert.Equal(row.NotificationId, detail.NotificationId);
|
||||
Assert.Equal("Email", detail.Type);
|
||||
Assert.Equal("Delivered", detail.Status);
|
||||
Assert.Equal("Tank-7 has exceeded its high-level setpoint.", detail.Body);
|
||||
Assert.Equal("[\"ops@example.com\",\"oncall@example.com\"]", detail.ResolvedTargets);
|
||||
Assert.Equal("{\"priority\":\"high\"}", detail.TypeData);
|
||||
Assert.Equal("HighLevelAlarm.csx", detail.SourceScript);
|
||||
Assert.Equal("instance-42", detail.SourceInstanceId);
|
||||
Assert.Equal(2, detail.RetryCount);
|
||||
Assert.Equal("transient blip", detail.LastError);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DetailRequest_UnknownId_ReturnsNotFound()
|
||||
{
|
||||
_repository.GetByIdAsync(Arg.Any<string>(), Arg.Any<CancellationToken>())
|
||||
.Returns((Notification?)null);
|
||||
var actor = CreateActor();
|
||||
|
||||
actor.Tell(new NotificationDetailRequest("corr-d2", "missing-id"), TestActor);
|
||||
|
||||
var response = ExpectMsg<NotificationDetailResponse>();
|
||||
Assert.Equal("corr-d2", response.CorrelationId);
|
||||
Assert.False(response.Success);
|
||||
Assert.Null(response.Detail);
|
||||
Assert.NotNull(response.ErrorMessage);
|
||||
Assert.Contains("not found", response.ErrorMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void KpiRequest_ComputesKpis_AndMapsSnapshot()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user