feat(site-runtime): persist native-alarm display metadata so rehydrated conditions render fully (UA4)
This commit is contained in:
@@ -184,6 +184,42 @@ public class NativeAlarmActorTests : TestKit, IDisposable
|
||||
Assert.Contains(rows, r => r.ConditionJson.Contains("49"));
|
||||
}
|
||||
|
||||
// ── PLAN-03 Task 21 (UA4): rehydration restores display metadata ────────
|
||||
|
||||
[Fact]
|
||||
public async Task Rehydration_RestoresDisplayMetadata()
|
||||
{
|
||||
var instance1 = CreateTestProbe();
|
||||
var dcl1 = CreateTestProbe();
|
||||
var actor1 = SpawnWithFlush(instance1.Ref, dcl1.Ref, TimeSpan.FromMilliseconds(100));
|
||||
dcl1.ExpectMsg<SubscribeAlarmsRequest>();
|
||||
|
||||
// A live raise carrying full display metadata.
|
||||
actor1.Tell(new NativeAlarmTransitionUpdate("Opc", new NativeAlarmTransition(
|
||||
"ref-1", "T01", "HighLevelAlarm", AlarmTransitionKind.Raise,
|
||||
new AlarmConditionState(true, false, null, AlarmShelveState.Unshelved, false, 800),
|
||||
"Process", "desc", "Tank overflow", "", "", null, DateTimeOffset.UtcNow, "92", "90")));
|
||||
instance1.ExpectMsg<AlarmStateChanged>(m => m.State == AlarmState.Active);
|
||||
|
||||
// Wait for the coalesced flush to land the metadata in SQLite.
|
||||
await AwaitAssertAsync(async () =>
|
||||
{
|
||||
var rows = await _storage.GetNativeAlarmsAsync("inst", Source().CanonicalName);
|
||||
Assert.Contains(rows, r => r.MetadataJson != null && r.MetadataJson.Contains("HighLevelAlarm"));
|
||||
}, TimeSpan.FromSeconds(3));
|
||||
|
||||
// A fresh actor on the SAME storage rehydrates in PreStart and re-emits the condition
|
||||
// with the restored metadata instead of empty strings.
|
||||
var instance2 = CreateTestProbe();
|
||||
var dcl2 = CreateTestProbe();
|
||||
SpawnWithFlush(instance2.Ref, dcl2.Ref, TimeSpan.FromMilliseconds(100));
|
||||
|
||||
var emitted = instance2.FishForMessage<AlarmStateChanged>(m => m.SourceReference == "ref-1", TimeSpan.FromSeconds(5));
|
||||
Assert.Equal("HighLevelAlarm", emitted.AlarmTypeName);
|
||||
Assert.Equal("Process", emitted.Category);
|
||||
Assert.Equal("Tank overflow", emitted.Message);
|
||||
}
|
||||
|
||||
// ── M1.5: site event log `alarm` category ──────────────────────────────
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user