feat(grpc-data): H2 AdminUI HistoryRead checkbox, history limit fields, X0 banner
Connection/export/mapping editors offer HistoryRead (DataOperationAuthoring, never ahead of the validator) and the HistoryTimeoutMilliseconds / MaxConcurrentHistoryReads / MaxHistoryValuesPerPage / MaxHistoryResponseBytes / MaxHistoryAssemblyBytesPerRequest fields; an informational banner shows while a post-v1 bit is ticked (plan 4.3).
This commit is contained in:
+63
@@ -0,0 +1,63 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.AdminUI.DataConnections;
|
||||
using ZB.MOM.WW.OtOpcUa.Configuration.Validation;
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.DataConnections;
|
||||
|
||||
/// <summary>H2 editor models: the HistoryRead checkbox, the history limits' defaults and the mixed-version banner.</summary>
|
||||
[Trait("Category", "Unit"), Trait("Feature", "GrpcData"), Trait("Phase", "H2")]
|
||||
public sealed class GrpcDataHistoryEditorTests
|
||||
{
|
||||
[Fact]
|
||||
public void HistoryRead_is_authorable_and_new_drafts_do_not_grant_it()
|
||||
{
|
||||
DataOperationAuthoring.AuthorableOperations.ShouldContain(DataOperations.HistoryRead);
|
||||
DataOperationAuthoring.AuthorableOperations.ShouldNotContain(DataOperations.AlarmSubscribe, "A2 bits stay unauthorable");
|
||||
// Every authorable bit is one the validator accepts — the editor never gets ahead of authoring.
|
||||
var all = DataOperationAuthoring.AuthorableOperations.Aggregate(DataOperations.None, (a, b) => a | b);
|
||||
(all & ~DataOperationSets.Understood).ShouldBe(DataOperations.None);
|
||||
new DataConnectionEditorModel().Value.AllowedOperations.HasFlag(DataOperations.HistoryRead).ShouldBeFalse();
|
||||
new RemoteMappingEditorModel().Value.AllowedOperations.HasFlag(DataOperations.HistoryRead).ShouldBeFalse();
|
||||
DataOperationAuthoring.Label(DataOperations.HistoryRead).ShouldBe("HistoryRead");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void New_drafts_carry_the_plans_history_limits()
|
||||
{
|
||||
new DataConnectionEditorModel().Value.HistoryTimeoutMilliseconds.ShouldBe(30000);
|
||||
new RemoteMappingEditorModel().Value.MaxHistoryAssemblyBytesPerRequest.ShouldBe(16 * 1024 * 1024);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_banner_shows_only_while_a_post_v1_bit_is_ticked()
|
||||
{
|
||||
DataOperationAuthoring.FeatureBitBanner(DataOperationSets.V1).ShouldBeNull();
|
||||
var banner = DataOperationAuthoring.FeatureBitBanner(DataOperations.Read | DataOperations.HistoryRead).ShouldNotBeNull();
|
||||
banner.ShouldContain("every node of both clusters must run X0+ before authoring this", Case.Insensitive);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_HistoryRead_draft_validates_and_a_zero_limit_does_not()
|
||||
{
|
||||
var draft = GrpcDataEditorValidationTestsAccess.ValidSnapshot(DataOperations.Read | DataOperations.HistoryRead);
|
||||
DataConnectionValidator.Validate(draft).ShouldNotContain(x => x.Code.EndsWith("OperationsInvalid", StringComparison.Ordinal));
|
||||
draft.DataConnections[0].HistoryTimeoutMilliseconds = 0;
|
||||
DataConnectionValidator.Validate(draft).ShouldContain(x => x.Code == "DataConnectionLimitInvalid");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A minimal valid draft for the editor tests.</summary>
|
||||
internal static class GrpcDataEditorValidationTestsAccess
|
||||
{
|
||||
public static DraftSnapshot ValidSnapshot(DataOperations operations) => new()
|
||||
{
|
||||
GenerationId = 1, ClusterId = "MAIN",
|
||||
DataConnections = [new() { DataConnectionId = "peer", ClusterId = "MAIN", Revision = 1, Enabled = true, AllowedOperations = operations,
|
||||
ConsumerNodeIds = [], EligibleTargetNodeIds = [], Endpoints = ["https://peer.example"] }],
|
||||
DataExports = [new() { DataExportId = "export", ClusterId = "MAIN", Enabled = true, AllowedOperations = operations, PrincipalId = "p", Revision = 1 }],
|
||||
RemoteNamespaceMappings = [new() { RemoteNamespaceMappingId = "mount", ClusterId = "MAIN", DataConnectionId = "peer", Enabled = true,
|
||||
AllowedOperations = operations, ConsumerNodeIds = [], Revision = 1 }],
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user