From 215027c7d06f7dfcf8a57eb1b35fb2ff236a47da Mon Sep 17 00:00:00 2001 From: Ilona Tomkowicz Date: Mon, 13 Apr 2026 12:22:21 +0200 Subject: [PATCH] Fix and unquarantine CanElevateEffectiveMaxItemCount_WhenOverscanExceedsMax The test was flaky because GetVisibleItemIndices() was called once and the result was reused in all Browser.True() retry loops and across PageDown iterations. In server mode, the async virtualization update had not finished yet when the snapshot was taken, so the retry loops kept checking a stale list that never reached 200 items. Fix by re-querying GetVisibleItemIndices() inside each Browser.True() loop so retries see the current DOM state. Fixes #65962 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../ServerExecutionTests/TestSubclasses.cs | 4 ---- .../test/E2ETest/Tests/VirtualizationTest.cs | 23 +++++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/Components/test/E2ETest/ServerExecutionTests/TestSubclasses.cs b/src/Components/test/E2ETest/ServerExecutionTests/TestSubclasses.cs index 13c5c36bcea9..04996f83b507 100644 --- a/src/Components/test/E2ETest/ServerExecutionTests/TestSubclasses.cs +++ b/src/Components/test/E2ETest/ServerExecutionTests/TestSubclasses.cs @@ -104,10 +104,6 @@ public ServerVirtualizationTest(BrowserFixture browserFixture, ToggleExecutionMo public override void CanRenderHtmlTable() => base.CanRenderHtmlTable(); - [QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/65962")] - public override void CanElevateEffectiveMaxItemCount_WhenOverscanExceedsMax() - => base.CanElevateEffectiveMaxItemCount_WhenOverscanExceedsMax(); - [QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/66119")] public override void NonZeroStartIndex_ScrollToMiddleThenMeasure() => base.NonZeroStartIndex_ScrollToMiddleThenMeasure(); diff --git a/src/Components/test/E2ETest/Tests/VirtualizationTest.cs b/src/Components/test/E2ETest/Tests/VirtualizationTest.cs index bc0560a65671..04008110251d 100644 --- a/src/Components/test/E2ETest/Tests/VirtualizationTest.cs +++ b/src/Components/test/E2ETest/Tests/VirtualizationTest.cs @@ -611,14 +611,18 @@ public void EmptyContentRendered_Async() } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/65852")] - public virtual void CanElevateEffectiveMaxItemCount_WhenOverscanExceedsMax() + public void CanElevateEffectiveMaxItemCount_WhenOverscanExceedsMax() { Browser.MountTestComponent(); var container = Browser.Exists(By.Id("virtualize-large-overscan")); - // Ensure we have an initial contiguous batch and the elevated effective max has kicked in (>= OverscanCount) - var indices = GetVisibleItemIndices(); - Browser.True(() => indices.Count >= 200); + // Wait for the elevated effective max to kick in (>= OverscanCount). + // Re-query inside the retry loop so we see new items as they render. + List indices = null; + Browser.True(() => + { + indices = GetVisibleItemIndices(); + return indices.Count >= 200; + }); // Give focus so PageDown works container.Click(); @@ -633,8 +637,13 @@ public virtual void CanElevateEffectiveMaxItemCount_WhenOverscanExceedsMax() var scrollTop = (long)js.ExecuteScript("return arguments[0].scrollTop", container); while (scrollTop + clientHeight < scrollHeight) { - // Validate contiguity on the current page - Browser.True(() => IsCurrentViewContiguous(indices)); + // Re-query visible items after each scroll so contiguity and + // progress checks reflect the current DOM state. + Browser.True(() => + { + indices = GetVisibleItemIndices(); + return IsCurrentViewContiguous(indices); + }); // Track progress in indices var currentMax = indices.Max();