fix(m9/T28b): forward --trigger-kind on alarm-update/script-add/script-update; fix default-selector test
Three dead-code bugs: --trigger-kind was registered but never read or forwarded on the
alarm-update, script-add, and script-update paths. Introduced TriggerConfigJson.InjectAnalysisKind
helper that rewrites any raw --trigger-config JSON blob, writing "analysisKind":"Strict" when
the flag is strict (case-insensitive) and stripping the key for any other value. Wired the
helper into all three handlers alongside the existing alarm-add path (which already used
AlarmTriggerConfigJson.Build). Added 6 unit tests for the new helper in TemplateTriggerKindTests.
Also fixed a false-positive bUnit test (AlarmTriggerEditor_Expression_NoAnalysisKindInConfig_
SelectorDefaultsAdvisory) that passed because "Advisory" appeared anywhere in the HTML; now
asserts select.GetAttribute("value") == "Advisory". Added the missing equivalent test for
ScriptTriggerEditor (ScriptTriggerEditor_Expression_NoAnalysisKindInConfig_SelectorDefaultsAdvisory).
This commit is contained in:
@@ -240,8 +240,21 @@ public class AlarmTriggerEditorAnalysisKindTests : BunitContext
|
||||
.Add(p => p.Value, @"{""expression"":""x > 0""}"));
|
||||
|
||||
var select = cut.Find("#alarm-trigger-kind");
|
||||
// The selected option must be Advisory (the default)
|
||||
Assert.Contains("Advisory", select.InnerHtml);
|
||||
// The bound value must be "Advisory" — not just present in the HTML
|
||||
Assert.Equal("Advisory", select.GetAttribute("value"));
|
||||
}
|
||||
|
||||
// Selector defaults to Advisory when config has no analysisKind (ScriptTriggerEditor)
|
||||
[Fact]
|
||||
public void ScriptTriggerEditor_Expression_NoAnalysisKindInConfig_SelectorDefaultsAdvisory()
|
||||
{
|
||||
var cut = Render<ScriptTriggerEditor>(ps => ps
|
||||
.Add(p => p.TriggerType, "Expression")
|
||||
.Add(p => p.TriggerConfig, @"{""expression"":""x > 0"",""mode"":""OnTrue""}"));
|
||||
|
||||
var select = cut.Find("#script-trigger-kind");
|
||||
// The bound value must be "Advisory" — not just present in the HTML
|
||||
Assert.Equal("Advisory", select.GetAttribute("value"));
|
||||
}
|
||||
|
||||
// Choosing Strict writes analysisKind:"Strict" into emitted config
|
||||
|
||||
Reference in New Issue
Block a user