115 lines
5.1 KiB
C#
115 lines
5.1 KiB
C#
using Bunit;
|
|
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared;
|
|
using ZB.MOM.WW.OtOpcUa.Commons.Messages.Admin;
|
|
using ZB.MOM.WW.OtOpcUa.Configuration.Enums;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Pages;
|
|
|
|
/// <summary>Acceptance, recorded application state, unavailable reads and no-change outcomes stay distinct.</summary>
|
|
[Trait("Category","Unit")]
|
|
public sealed class DeploymentFeedbackTests : BunitContext
|
|
{
|
|
[Theory]
|
|
[InlineData(DeploymentStatus.Dispatching)]
|
|
[InlineData(DeploymentStatus.AwaitingApplyAcks)]
|
|
public void AcceptedRequest_IsNotCompletedApplication(DeploymentStatus status)
|
|
{
|
|
var cut=Render<DeploymentFeedback>(p=>p.Add(x=>x.RequestOutcome,StartDeploymentOutcome.Accepted).Add(x=>x.Status,status));
|
|
cut.Find("[role=status]").TextContent.ShouldContain("in progress");
|
|
cut.Find("[role=status]").TextContent.ShouldNotContain("completed");
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(DeploymentStatus.Dispatching,"Dispatching")]
|
|
[InlineData(DeploymentStatus.AwaitingApplyAcks,"Awaiting apply acknowledgements")]
|
|
[InlineData(DeploymentStatus.Sealed,"Sealed")]
|
|
[InlineData(DeploymentStatus.PartiallyFailed,"Partially failed")]
|
|
[InlineData(DeploymentStatus.TimedOut,"Timed out")]
|
|
public void RealRecordedStatuses_RemainDistinct(DeploymentStatus status,string label)
|
|
{
|
|
var cut=Render<DeploymentFeedback>(p=>p.Add(x=>x.Status,status));
|
|
cut.Find("[role=status]").TextContent.ShouldContain(label);
|
|
}
|
|
|
|
[Fact]
|
|
public void SealedWithReason_IsDegraded_AndFullReasonIsOutsideLiveAnnouncement()
|
|
{
|
|
var text="<script>ignored()</script>"+new string('x',2000);
|
|
var cut=Render<DeploymentFeedback>(p=>p.Add(x=>x.Status,DeploymentStatus.Sealed).Add(x=>x.FailureReason,text));
|
|
cut.Find("[role=status]").TextContent.ShouldContain("Sealed (degraded)");
|
|
cut.Find("pre").TextContent.ShouldBe(text);
|
|
cut.FindAll("script").ShouldBeEmpty();
|
|
cut.FindAll("[role=status] pre").ShouldBeEmpty();
|
|
}
|
|
|
|
[Fact]
|
|
public void NoChanges_IsInformational_AndKeepsPriorRecordedStatus()
|
|
{
|
|
var cut=Render<DeploymentFeedback>(p=>p.Add(x=>x.RequestOutcome,StartDeploymentOutcome.NoChanges).Add(x=>x.Status,DeploymentStatus.TimedOut));
|
|
var text=cut.Find("[role=status]").TextContent;
|
|
text.ShouldContain("No configuration changes");text.ShouldContain("Timed out");text.ShouldNotContain("rejected");
|
|
}
|
|
|
|
[Fact]
|
|
public void InitialPending_IsNotEmptyHistory()
|
|
{
|
|
var cut=Render<DeploymentFeedback>(p=>p.Add(x=>x.InitialLoading,true));
|
|
cut.Find("[role=status]").TextContent.ShouldContain("Loading deployment history");
|
|
cut.Find("[role=status]").TextContent.ShouldNotContain("No deployment history");
|
|
}
|
|
|
|
[Fact]
|
|
public void FailedInitialRead_IsNotEmptyHistory()
|
|
{
|
|
var cut=Render<DeploymentFeedback>(p=>p.Add(x=>x.HistoryAvailable,false));
|
|
cut.Find("[role=status]").TextContent.ShouldContain("history is unavailable");
|
|
cut.Find("[role=status]").TextContent.ShouldNotContain("No deployment history");
|
|
}
|
|
|
|
[Fact]
|
|
public void ConfirmedEmptyRead_IsExplicitEmptyHistory()
|
|
{
|
|
var cut=Render<DeploymentFeedback>();
|
|
cut.Find("[role=status]").TextContent.ShouldContain("No deployment history");
|
|
}
|
|
|
|
[Fact]
|
|
public void AcceptedButNotYetObserved_IsNotEmptyHistory()
|
|
{
|
|
var cut=Render<DeploymentFeedback>(p=>p.Add(x=>x.RequestOutcome,StartDeploymentOutcome.Accepted));
|
|
var text=cut.Find("[role=status]").TextContent;text.ShouldContain("Request accepted");text.ShouldContain("not yet observed");text.ShouldNotContain("No deployment history");
|
|
}
|
|
|
|
[Fact]
|
|
public void TransportFailure_DoesNotInventRejectionOrSuccess()
|
|
{
|
|
var cut=Render<DeploymentFeedback>(p=>p.Add(x=>x.RequestResultUnavailable,true));
|
|
var text=cut.Find("[role=status]").TextContent;text.ShouldContain("could not be confirmed");text.ShouldNotContain("Request rejected");text.ShouldNotContain("Request accepted");
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(StartDeploymentOutcome.Rejected,"Request rejected")]
|
|
[InlineData(StartDeploymentOutcome.AnotherDeploymentInFlight,"This request was not started")]
|
|
public void KnownUnacceptedRequest_IsExplicit(StartDeploymentOutcome outcome,string expected)
|
|
{
|
|
var cut=Render<DeploymentFeedback>(p=>p.Add(x=>x.RequestOutcome,outcome));
|
|
cut.Find("[role=status]").TextContent.ShouldContain(expected);
|
|
}
|
|
|
|
[Fact]
|
|
public void WaitingForActorReply_IsNotAcceptance()
|
|
{
|
|
var cut=Render<DeploymentFeedback>(p=>p.Add(x=>x.RequestPending,true));
|
|
var text=cut.Find("[role=status]").TextContent;text.ShouldContain("Waiting for request acceptance");text.ShouldNotContain("Request accepted");
|
|
}
|
|
[Fact]
|
|
public void RejectedWithoutReason_DoesNotPromiseAMissingDisclosure()
|
|
{
|
|
var cut=Render<DeploymentFeedback>(p=>p.Add(x=>x.RequestOutcome,StartDeploymentOutcome.Rejected));
|
|
cut.Find("[role=status]").TextContent.ShouldContain("No reason was supplied");
|
|
cut.FindAll("details").ShouldBeEmpty();
|
|
}
|
|
}
|