Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests/Monitoring/ParkedMessagesTests.cs
T
Joseph Doherty 513fa1aa16 docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
Comment/XML-doc changes only:
- add summaries to ~10k test methods, fixtures, fakes and helpers
  (+ <param> on theories, <returns> on async Task methods,
  <inheritdoc/> on interface implementations the checker can resolve)
- strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N,
  #NN, Component-0NN) from comments, keeping the explanatory text;
  reword false positives in comments only
- real docs on fakes implementing BCL/library interfaces
  (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime)
- reword the last 5 src/ false positives (CWE-1236, failures-1,
  year-0001, M365)

Only non-comment edits: four one-line nested classes split across lines
so members can carry docs. Build 0 errors / 0 warnings.
2026-10-07 15:05:49 -04:00

72 lines
3.7 KiB
C#

using Microsoft.Playwright;
using Xunit;
using ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests.Cluster;
namespace ZB.MOM.WW.ScadaBridge.CentralUI.PlaywrightTests.Monitoring;
/// <summary>
/// End-to-end render / no-hang guard for the central Parked Messages page
/// (<c>/monitoring/parked-messages</c>).
///
/// <para>
/// <b>Why this is a render guard and NOT a mutation test (unlike
/// <see cref="Notifications.NotificationActionTests"/>):</b> parked store-and-forward
/// messages live in the SITE's local SQLite buffer, not in central MS SQL. The page
/// resolves them by relaying a <c>ParkedMessageQueryRequest</c> to the owning site over
/// the cluster (an Akka Ask answered by the site's S&amp;F singleton). There is no central
/// table to seed — a directly-INSERTed central row cannot produce a parked S&amp;F message —
/// so this test cannot deterministically seed a row to act on. Instead it asserts the
/// singleton-backed query <em>resolves</em> (renders the results table or the empty-state
/// card) within a generous window rather than hanging on the cross-cluster Ask — the
/// regression class this guards against. Empty results are tolerated.
/// </para>
///
/// <para>
/// Gated on <see cref="ClusterAvailability"/> via <c>Skip.IfNot</c>: when the cluster is
/// unreachable the fact reports as Skipped (not Failed), matching the established suite
/// idiom. The query relays to a live site, so the cluster (not just MSSQL) must be up.
/// </para>
/// </summary>
[Collection("Playwright")]
public class ParkedMessagesTests
{
private const string ParkedMessagesUrl = "/monitoring/parked-messages";
private readonly PlaywrightFixture _fixture;
/// <summary>Initializes the test class with the shared Playwright fixture.</summary>
/// <param name="fixture">The shared Playwright fixture.</param>
public ParkedMessagesTests(PlaywrightFixture fixture)
{
_fixture = fixture;
}
/// <summary>Verifies that querying the parked messages page for a site renders without hanging.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[SkippableFact]
public async Task ParkedMessages_QueryForSite_RendersWithoutHang()
{
Skip.IfNot(await ClusterAvailability.IsAvailableAsync(), ClusterAvailability.SkipReason);
var page = await _fixture.NewAuthenticatedPageAsync();
await page.GotoAsync($"{PlaywrightFixture.BaseUrl}{ParkedMessagesUrl}");
await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
await Assertions.Expect(page.Locator("h4:has-text('Parked Messages')")).ToBeVisibleAsync();
// Select site-a — the <option> value is the SiteIdentifier "site-a". The select is
// an @onchange handler that, on a non-empty selection, kicks off the query itself;
// SelectOptionAsync raises the change event so the query fires. Click Query as well
// to be explicit (the button is enabled once a site is selected).
await page.Locator("#pm-filter-site").SelectOptionAsync("site-a");
await page.Locator("button.btn.btn-primary.btn-sm:has-text('Query')").ClickAsync();
// The singleton-backed query resolves to EITHER the results table or the empty-state
// card. Web-first assertion with a generous timeout (20s) — the relay round-trips to
// the site over the cluster, and the regression this guards is the query hanging
// (leaving the page stuck on "Loading…"). Either terminal state proves it resolved.
var resolved = page.Locator("table.parked-table, div.card-body:has-text('No parked messages')");
await Assertions.Expect(resolved.First).ToBeVisibleAsync(new() { Timeout = 20_000 });
}
}