diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/CliRunner.Helpers.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/CliRunner.Helpers.cs
index bf8b1725..f505490b 100644
--- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/CliRunner.Helpers.cs
+++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/CliRunner.Helpers.cs
@@ -237,6 +237,52 @@ public static partial class CliRunner
}
}
+ ///
+ /// Returns the ids of all areas on whose name
+ /// starts with , via site area list --site-id.
+ /// Used to delete areas a test created through the UI (where the new id is never
+ /// surfaced to the test).
+ ///
+ ///
+ /// Response shape: each element of the returned JSON array carries an integer
+ /// id and a string name (empirically verified against the dev
+ /// cluster — same shapes as the other create/list helpers in this file).
+ ///
+ ///
+ /// Owning site id.
+ ///
+ /// Name prefix to filter by (ordinal comparison). Typically the full unique name
+ /// produced by so exactly one id is returned.
+ ///
+ ///
+ /// The ids of every area on whose name starts with
+ /// ; empty if no areas match.
+ ///
+ public static async Task> ListAreaIdsByNamePrefixAsync(int siteId, string prefix)
+ {
+ using var doc = await RunJsonAsync(
+ "site", "area", "list",
+ "--site-id", siteId.ToString(System.Globalization.CultureInfo.InvariantCulture));
+
+ var ids = new List();
+ if (doc.RootElement.ValueKind == JsonValueKind.Array)
+ {
+ foreach (var area in doc.RootElement.EnumerateArray())
+ {
+ if (area.TryGetProperty("name", out var name)
+ && name.ValueKind == JsonValueKind.String
+ && (name.GetString()?.StartsWith(prefix, StringComparison.Ordinal) ?? false)
+ && area.TryGetProperty("id", out var id)
+ && id.TryGetInt32(out var areaId))
+ {
+ ids.Add(areaId);
+ }
+ }
+ }
+
+ return ids;
+ }
+
///
/// Best-effort delete of a site via site delete for teardown; swallows
/// any failure.
diff --git a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/CliRunnerHelpersTests.cs b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/CliRunnerHelpersTests.cs
index 38f2142d..82659a91 100644
--- a/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/CliRunnerHelpersTests.cs
+++ b/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Cluster/CliRunnerHelpersTests.cs
@@ -84,4 +84,31 @@ public class CliRunnerHelpersTests
await CliRunner.DeleteApiMethodAsync(id);
}
}
+
+ ///
+ /// A freshly created area is discoverable by name prefix via
+ /// , confirming the round-trip
+ /// used by UI tests that need to tear down areas whose ids are never surfaced.
+ /// Exercises ,
+ /// , and
+ /// .
+ ///
+ [SkippableFact]
+ public async Task ListAreaIdsByNamePrefix_FindsCreatedArea()
+ {
+ Skip.IfNot(await ClusterAvailability.IsAvailableAsync(), ClusterAvailability.SkipReason);
+
+ var siteId = await CliRunner.ResolveSiteIdAsync("site-a");
+ var name = CliRunner.UniqueName("listarea");
+ var areaId = await CliRunner.CreateAreaAsync(siteId, name);
+ try
+ {
+ var ids = await CliRunner.ListAreaIdsByNamePrefixAsync(siteId, name);
+ Assert.Contains(areaId, ids);
+ }
+ finally
+ {
+ await CliRunner.DeleteAreaAsync(areaId);
+ }
+ }
}