7b0b9c7365
Solution + 23 src projects + 26 test projects renamed; folders, csproj, namespaces, and ScadaLinkDbContext/ScadaBridgeDbContext class updated. ActorSystem "scadalink" → "scadabridge", Akka seed-node URLs migrated. SQL roles/logins, LDAP domains, CLI command name, and CLI config dir (~/.scadalink → ~/.scadabridge) also renamed. Build green; 5 Host.Tests fail awaiting SQL login rename in next commit. Pre-existing StaleTagMonitor timing flakes unchanged. Rename script committed at tools/rename-to-scadabridge.sh.
70 lines
2.6 KiB
C#
70 lines
2.6 KiB
C#
using Bunit;
|
|
using Microsoft.AspNetCore.Components;
|
|
using ZB.MOM.WW.ScadaBridge.CentralUI.Components.Shared;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Tests.Shared;
|
|
|
|
/// <summary>
|
|
/// Component tests for the OnTrue/WhileTrue mode selector that
|
|
/// <see cref="ScriptTriggerEditor"/> exposes for Conditional and Expression
|
|
/// triggers.
|
|
/// </summary>
|
|
public class ScriptTriggerEditorTests : BunitContext
|
|
{
|
|
private const string ConditionalConfig =
|
|
@"{""attributeName"":""Temp"",""operator"":"">"",""threshold"":50}";
|
|
|
|
private const string ConditionalWhileTrueConfig =
|
|
@"{""attributeName"":""Temp"",""operator"":"">"",""threshold"":50,""mode"":""WhileTrue""}";
|
|
|
|
[Fact]
|
|
public void SelectingWhileTrue_EmitsConfigWithWhileTrueMode()
|
|
{
|
|
ScriptTriggerValue? captured = null;
|
|
var cut = Render<ScriptTriggerEditor>(ps => ps
|
|
.Add(p => p.TriggerType, "Conditional")
|
|
.Add(p => p.TriggerConfig, ConditionalConfig)
|
|
.Add(p => p.Changed,
|
|
EventCallback.Factory.Create<ScriptTriggerValue>(this, v => captured = v)));
|
|
|
|
cut.Find("#script-trigger-mode").Change("WhileTrue");
|
|
|
|
Assert.NotNull(captured);
|
|
Assert.Contains("\"mode\":\"WhileTrue\"", captured!.Config);
|
|
}
|
|
|
|
[Fact]
|
|
public void ModeSelector_DefaultsToOnTrue_WhenConfigHasNoMode()
|
|
{
|
|
ScriptTriggerValue? captured = null;
|
|
var cut = Render<ScriptTriggerEditor>(ps => ps
|
|
.Add(p => p.TriggerType, "Conditional")
|
|
.Add(p => p.TriggerConfig, ConditionalConfig)
|
|
.Add(p => p.Changed,
|
|
EventCallback.Factory.Create<ScriptTriggerValue>(this, v => captured = v)));
|
|
|
|
// Change the threshold to force an emit without touching the mode.
|
|
cut.Find("input[type=number]").Input("75");
|
|
|
|
Assert.NotNull(captured);
|
|
Assert.Contains("\"mode\":\"OnTrue\"", captured!.Config);
|
|
}
|
|
|
|
[Fact]
|
|
public void LoadedWhileTrueMode_IsRetainedAcrossAnUnrelatedEdit()
|
|
{
|
|
ScriptTriggerValue? captured = null;
|
|
var cut = Render<ScriptTriggerEditor>(ps => ps
|
|
.Add(p => p.TriggerType, "Conditional")
|
|
.Add(p => p.TriggerConfig, ConditionalWhileTrueConfig)
|
|
.Add(p => p.Changed,
|
|
EventCallback.Factory.Create<ScriptTriggerValue>(this, v => captured = v)));
|
|
|
|
// Editing the threshold must not silently drop the loaded WhileTrue mode.
|
|
cut.Find("input[type=number]").Input("75");
|
|
|
|
Assert.NotNull(captured);
|
|
Assert.Contains("\"mode\":\"WhileTrue\"", captured!.Config);
|
|
}
|
|
}
|