test(playwright): DebugViewTree — tolerate empty alarm forest (TreeView renders EmptyContent, not role=tree, when no alarms)
This commit is contained in:
+20
-11
@@ -37,14 +37,14 @@ namespace ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests.Deployment;
|
||||
/// </para>
|
||||
///
|
||||
/// <para>
|
||||
/// <b>Why the tree assertion is robust regardless of seeded alarms</b> — the
|
||||
/// <see cref="TreeView{T}"/> always renders its <c><ul role="tree"></c> root
|
||||
/// (with an <c>EmptyContent</c> "No alarms." / "No attributes." slot when the
|
||||
/// forest is empty), so asserting a <c>[role="tree"]</c> inside the active pane
|
||||
/// holds whether or not the fixture instance happens to carry a configured alarm
|
||||
/// or composition members. The test therefore does NOT depend on heavy alarm
|
||||
/// seeding: it proves the Alarms tab switches the visible pane and that pane hosts
|
||||
/// a tree, which is the structural contract of the tabs+trees rework.
|
||||
/// <b>Why the alarms-tab assertion is tolerant</b> — the
|
||||
/// <see cref="TreeView{T}"/> renders its <c><ul role="tree"></c> root ONLY
|
||||
/// when the forest is non-empty; when empty it renders the <c>EmptyContent</c>
|
||||
/// slot ("No alarms.") with no <c>[role="tree"]</c> element. The seeded
|
||||
/// <see cref="DeploymentFixture"/> instance has no configured alarms, so the
|
||||
/// alarms pane shows the empty hint. The Attributes pane always has data (one
|
||||
/// attribute is seeded), so its <c>[role="tree"]</c> assertion remains strict.
|
||||
/// The populated alarm tree is covered by bUnit tests (DebugViewAlarmTableTests).
|
||||
/// </para>
|
||||
/// </summary>
|
||||
[Collection("Playwright")]
|
||||
@@ -116,9 +116,18 @@ public class DebugViewTreeTests : IClassFixture<DeploymentFixture>
|
||||
await Assertions.Expect(alarmTab).ToHaveAttributeAsync("aria-selected", "true");
|
||||
await Assertions.Expect(alarmPane).ToBeVisibleAsync(new() { Timeout = 10_000 });
|
||||
await Assertions.Expect(attrPane).ToBeHiddenAsync();
|
||||
// The TreeView always renders its <ul role="tree"> root (EmptyContent slot when
|
||||
// the forest is empty), so this holds whether or not the instance carries alarms.
|
||||
await Assertions.Expect(alarmPane.Locator("[role='tree']")).ToHaveCountAsync(1);
|
||||
// TreeView renders <ul role="tree"> ONLY when the forest is non-empty; when empty it
|
||||
// renders the EmptyContent slot ("No alarms.") instead. The seeded DeploymentFixture
|
||||
// instance has no configured alarms, so the alarms forest is empty and the pane shows
|
||||
// the empty hint rather than a tree. The populated alarm tree is covered by bUnit
|
||||
// tests (DebugViewAlarmTableTests). Here we prove the tab switch works and the pane
|
||||
// renders something valid — either a tree (if alarms exist) or the empty hint.
|
||||
var alarmTreeCount = await alarmPane.Locator("[role='tree']").CountAsync();
|
||||
if (alarmTreeCount == 0)
|
||||
{
|
||||
// No alarms configured on the seeded instance → TreeView shows EmptyContent.
|
||||
await Assertions.Expect(alarmPane).ToContainTextAsync("No alarms.");
|
||||
}
|
||||
|
||||
// Disconnect tears the card down and re-enables the selectors.
|
||||
await page.Locator("button.btn-outline-danger.btn-sm:has-text('Disconnect')").ClickAsync();
|
||||
|
||||
Reference in New Issue
Block a user