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:
Joseph Doherty
2026-06-18 10:54:42 -04:00
parent ea69178dd9
commit 0bd5e0986f
4 changed files with 171 additions and 15 deletions
@@ -421,6 +421,9 @@ public static class TemplateCommands
updateCmd.Add(updateTriggerKindOption);
updateCmd.SetAction(async (ParseResult result) =>
{
var triggerConfig = TriggerConfigJson.InjectAnalysisKind(
result.GetValue(updateTriggerConfigOption),
result.GetValue(updateTriggerKindOption));
return await CommandHelpers.ExecuteCommandAsync(
result, urlOption, formatOption, usernameOption, passwordOption,
new UpdateTemplateAlarmCommand(
@@ -429,7 +432,7 @@ public static class TemplateCommands
result.GetValue(updateTriggerTypeOption)!,
result.GetValue(updatePriorityOption)!,
result.GetValue(updateDescOption),
result.GetValue(updateTriggerConfigOption),
triggerConfig,
result.GetValue(updateLockedOption)));
});
group.Add(updateCmd);
@@ -549,6 +552,9 @@ public static class TemplateCommands
addCmd.Add(scriptTriggerKindOption);
addCmd.SetAction(async (ParseResult result) =>
{
var triggerConfig = TriggerConfigJson.InjectAnalysisKind(
result.GetValue(triggerConfigOption),
result.GetValue(scriptTriggerKindOption));
return await CommandHelpers.ExecuteCommandAsync(
result, urlOption, formatOption, usernameOption, passwordOption,
new AddTemplateScriptCommand(
@@ -556,7 +562,7 @@ public static class TemplateCommands
result.GetValue(nameOption)!,
result.GetValue(codeOption)!,
result.GetValue(triggerTypeOption)!,
result.GetValue(triggerConfigOption),
triggerConfig,
result.GetValue(lockedOption),
result.GetValue(paramsOption),
result.GetValue(returnOption)));
@@ -591,6 +597,9 @@ public static class TemplateCommands
updateCmd.Add(updateScriptTriggerKindOption);
updateCmd.SetAction(async (ParseResult result) =>
{
var triggerConfig = TriggerConfigJson.InjectAnalysisKind(
result.GetValue(updateTriggerConfigOption),
result.GetValue(updateScriptTriggerKindOption));
return await CommandHelpers.ExecuteCommandAsync(
result, urlOption, formatOption, usernameOption, passwordOption,
new UpdateTemplateScriptCommand(
@@ -598,7 +607,7 @@ public static class TemplateCommands
result.GetValue(updateNameOption)!,
result.GetValue(updateCodeOption)!,
result.GetValue(updateTriggerTypeOption)!,
result.GetValue(updateTriggerConfigOption),
triggerConfig,
result.GetValue(updateLockedOption),
result.GetValue(updateParamsOption),
result.GetValue(updateReturnOption)));