test(playwright): CliRunner AddAlarm + alarm-override-delete helpers + round-trip (typed flags)
This commit is contained in:
@@ -100,6 +100,34 @@ public static partial class CliRunner
|
||||
await RunAsync([.. args]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an alarm to a template via <c>template alarm add</c> (using the typed setpoint
|
||||
/// flags) and returns its new <c>id</c>. Throws on failure.
|
||||
/// </summary>
|
||||
public static async Task<int> AddAlarmAsync(
|
||||
int templateId, string name, string triggerType = "HiLo", int priority = 500,
|
||||
string? attribute = null, double? hi = null, double? hiHi = null,
|
||||
double? lo = null, double? loLo = null)
|
||||
{
|
||||
var inv = System.Globalization.CultureInfo.InvariantCulture;
|
||||
var args = new List<string>
|
||||
{
|
||||
"template", "alarm", "add",
|
||||
"--template-id", templateId.ToString(inv),
|
||||
"--name", name,
|
||||
"--trigger-type", triggerType,
|
||||
"--priority", priority.ToString(inv),
|
||||
};
|
||||
if (attribute is not null) { args.Add("--attribute"); args.Add(attribute); }
|
||||
if (hi.HasValue) { args.Add("--hi"); args.Add(hi.Value.ToString(inv)); }
|
||||
if (hiHi.HasValue) { args.Add("--hihi"); args.Add(hiHi.Value.ToString(inv)); }
|
||||
if (lo.HasValue) { args.Add("--lo"); args.Add(lo.Value.ToString(inv)); }
|
||||
if (loLo.HasValue) { args.Add("--lolo"); args.Add(loLo.Value.ToString(inv)); }
|
||||
|
||||
using var doc = await RunJsonAsync([.. args]);
|
||||
return RequireId(doc, "template alarm add");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an area under a site via <c>site area create</c> and returns its
|
||||
/// new <c>id</c>.
|
||||
@@ -558,6 +586,18 @@ public static partial class CliRunner
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Best-effort delete of an instance alarm override (teardown). Never throws.</summary>
|
||||
public static async Task DeleteInstanceAlarmOverrideAsync(int instanceId, string alarmCanonicalName)
|
||||
{
|
||||
var inv = System.Globalization.CultureInfo.InvariantCulture;
|
||||
try
|
||||
{
|
||||
await RunAsync("instance", "alarm-override", "delete",
|
||||
"--instance-id", instanceId.ToString(inv), "--alarm", alarmCanonicalName);
|
||||
}
|
||||
catch { /* best-effort teardown — never mask the test's own failure. */ }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Exports a Transport bundle scoped to a single template via
|
||||
/// <c>bundle export</c>.
|
||||
|
||||
Reference in New Issue
Block a user