feat(centralui): extract AlarmStateBadges shared component from DebugView (T13)
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using Bunit;
|
||||
using ZB.MOM.WW.ScadaBridge.CentralUI.Components.Shared;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Streaming;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Types.Alarms;
|
||||
using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Covers the <c>AlarmStateBadges</c> shared component lifted out of
|
||||
/// <c>DebugView</c> (M7-T13 prep). The badge cluster must render identically
|
||||
/// wherever it is hosted, so these tests pin the rendered markup: state badge
|
||||
/// class, kind label, native sub-state badges, severity, and HiLo level.
|
||||
/// </summary>
|
||||
public class AlarmStateBadgesTests : BunitContext
|
||||
{
|
||||
private static AlarmStateChanged ActiveNativeHighUnacked() => new(
|
||||
InstanceUniqueName: "Tank01",
|
||||
AlarmName: "Tank01.Level.HiHi",
|
||||
State: AlarmState.Active,
|
||||
Priority: 700,
|
||||
Timestamp: DateTimeOffset.UtcNow)
|
||||
{
|
||||
Kind = AlarmKind.NativeOpcUa,
|
||||
Level = AlarmLevel.High,
|
||||
Condition = new AlarmConditionState(
|
||||
Active: true,
|
||||
Acknowledged: false,
|
||||
Confirmed: null,
|
||||
Shelve: AlarmShelveState.Unshelved,
|
||||
Suppressed: false,
|
||||
Severity: 700),
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void Renders_StateKindSubStateSeverityAndLevel_Badges()
|
||||
{
|
||||
var alarm = ActiveNativeHighUnacked();
|
||||
|
||||
var cut = Render<AlarmStateBadges>(p => p.Add(c => c.Alarm, alarm));
|
||||
|
||||
// State badge: Active condition tinted danger.
|
||||
Assert.Contains("bg-danger", cut.Markup);
|
||||
Assert.Contains("Active", cut.Markup);
|
||||
|
||||
// Kind badge label for a native OPC UA alarm.
|
||||
Assert.Contains("OPC UA", cut.Markup);
|
||||
|
||||
// Native sub-state badge: active + unacknowledged.
|
||||
Assert.Contains("Unacked", cut.Markup);
|
||||
|
||||
// Severity span on the unified 0–1000 scale.
|
||||
Assert.Contains("sev 700", cut.Markup);
|
||||
|
||||
// HiLo level badge label.
|
||||
Assert.Contains("Hi", cut.Markup);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user