From bb6f6aaa54243e809c0fc1a3afae20740b2d7090 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Fri, 22 May 2026 08:00:46 -0400 Subject: [PATCH] test(centralui): fix flaky audit-grid resize-survives-reload test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ResizeHandle_DraggingWidensColumn_AndSurvivesReload called page.ReloadAsync() immediately after the resize drag, racing the asynchronous persist: pointer-up fires a fire-and-forget JS→.NET OnColumnResized invoke that round-trips back through JS interop to write sessionStorage. When the reload won the race the restored grid fell back to the default column width and the test failed (~1 in 3 runs). Wait for auditGrid:columnWidths to land via the existing WaitForStorageKeyAsync helper before reloading — the same guard the sibling ColumnOrderAndWidths_PersistAcrossReload_ViaSessionStorage test already uses. Verified: 6/6 consecutive passes. --- .../Audit/AuditGridColumnTests.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/ScadaLink.CentralUI.PlaywrightTests/Audit/AuditGridColumnTests.cs b/tests/ScadaLink.CentralUI.PlaywrightTests/Audit/AuditGridColumnTests.cs index 36a9dba..cd884d6 100644 --- a/tests/ScadaLink.CentralUI.PlaywrightTests/Audit/AuditGridColumnTests.cs +++ b/tests/ScadaLink.CentralUI.PlaywrightTests/Audit/AuditGridColumnTests.cs @@ -146,6 +146,14 @@ public class AuditGridColumnTests Assert.True(after > before + 40, $"Expected the {columnKey} column to widen after the resize drag (before={before}, after={after})."); + // The resize persists asynchronously: pointer-up fires a + // fire-and-forget JS→.NET OnColumnResized invoke, and the .NET + // handler then round-trips back through JS interop to write + // sessionStorage. Wait for that write to land before reloading — + // otherwise the reload races it and the restored grid falls back + // to the default width. + await WaitForStorageKeyAsync(page, "auditGrid:columnWidths"); + // Reload: the persisted width is restored from sessionStorage. await page.ReloadAsync(); await page.WaitForLoadStateAsync(LoadState.NetworkIdle);