Skip to content

[Components][E2E] Stabilize virtualization test setup after scroll#66194

Merged
ilonatommy merged 2 commits intomainfrom
fix/servervirt-setup-stabilization
Apr 9, 2026
Merged

[Components][E2E] Stabilize virtualization test setup after scroll#66194
ilonatommy merged 2 commits intomainfrom
fix/servervirt-setup-stabilization

Conversation

@ilonatommy
Copy link
Copy Markdown
Member

Summary

  • stabilize the setup phase for the server virtualization prepend/append E2E tests
  • keep the actual viewport-preservation assertions unchanged
  • wait until the virtualized window has really advanced past overscan before starting the real check

Why

The intermittent failure has been happening in the preparation stage, where the test sets scrollTop = 5000 and then immediately expects the rendered range to have moved beyond the overscan window. In server mode that can race with the async virtualization update, so the test can fail before it even reaches the real prepend assertion.

Test

dotnet test .\src\Components\test\E2ETest\Microsoft.AspNetCore.Components.E2ETests.csproj --no-build --no-restore --filter "FullyQualifiedName~ServerVirtualizationTest.DynamicContent_"

The flaky server virtualization failure happens in the setup phase that scrolls past the overscan window and assumes the rendered range has already caught up. Add a helper that reapplies the target offset and waits for the virtualized window to converge before the prepend/append assertions begin.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ilonatommy ilonatommy requested a review from a team as a code owner April 7, 2026 10:29
Copilot AI review requested due to automatic review settings April 7, 2026 10:29
@github-actions github-actions Bot added the area-blazor Includes: Blazor, Razor Components label Apr 7, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Stabilizes the server-side virtualization dynamic content E2E tests by making the “scroll past overscan” setup phase wait for the rendered window to actually advance before running the viewport-preservation assertions.

Changes:

  • Added a shared helper to scroll to a target offset and poll until the first rendered item index advances beyond a threshold, then wait for scroll stabilization.
  • Updated the prepend/append dynamic content virtualization tests to use the new stabilized scroll helper (keeping the core assertions unchanged).

@ilonatommy
Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 4 pipeline(s).

@ilonatommy ilonatommy merged commit 9fa0e37 into main Apr 9, 2026
25 checks passed
@ilonatommy ilonatommy deleted the fix/servervirt-setup-stabilization branch April 9, 2026 09:46
@dotnet-policy-service dotnet-policy-service Bot added this to the 11.0-preview4 milestone Apr 9, 2026
ilonatommy added a commit to ilonatommy/aspnetcore that referenced this pull request Apr 13, 2026
Apply the same retry-based scroll stabilization pattern from PR dotnet#66194
to NonZeroStartIndex_ScrollToMiddleThenMeasure. The test was racing in
server mode because it set scrollTop and then immediately checked the
rendered items, but the async virtualization update had not finished yet.

The fix computes the target offset up front, then retries both the
scroll assignment and the rendered-index check inside a single
Browser.True() loop before calling WaitForScrollStabilization.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ilonatommy added a commit to ilonatommy/aspnetcore that referenced this pull request Apr 13, 2026
Apply the same retry-based scroll stabilization pattern from PR dotnet#66194
to NonZeroStartIndex_ScrollToMiddleThenMeasure. The test was racing in
server mode because it set scrollTop and then immediately checked the
rendered items, but the async virtualization update had not finished yet.

The fix computes the target offset up front, then retries both the
scroll assignment and the rendered-index check inside a single
Browser.True() loop before calling WaitForScrollStabilization.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ilonatommy added a commit to ilonatommy/aspnetcore that referenced this pull request Apr 13, 2026
Apply the same retry-based scroll stabilization pattern from PR dotnet#66194
to NonZeroStartIndex_ScrollToMiddleThenMeasure. The test was racing in
server mode because it set scrollTop and then immediately checked the
rendered items, but the async virtualization update had not finished yet.

The fix computes the target offset up front, then retries both the
scroll assignment and the rendered-index check inside a single
Browser.True() loop before calling WaitForScrollStabilization.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ilonatommy added a commit that referenced this pull request Apr 17, 2026
…re test setup (#66290)

* Stabilize NonZeroStartIndex_ScrollToMiddleThenMeasure E2E test setup

Apply the same retry-based scroll stabilization pattern from PR #66194
to NonZeroStartIndex_ScrollToMiddleThenMeasure. The test was racing in
server mode because it set scrollTop and then immediately checked the
rendered items, but the async virtualization update had not finished yet.

The fix computes the target offset up front, then retries both the
scroll assignment and the rendered-index check inside a single
Browser.True() loop before calling WaitForScrollStabilization.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Apply review feedback: fix spacing and reuse ScrollToOffsetWithStabilization helper

- Fix missing space around = in targetScrollTop assignment
- Extract scroll+retry logic into generalized ScrollToOffsetWithStabilization overload
- Reuse the helper in NonZeroStartIndex_ScrollToMiddleThenMeasure instead of duplicating

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix bad merge: remove stale CanElevateEffectiveMaxItemCount quarantine, restore missing PrependItems quarantine

The merge from main incorrectly re-introduced a quarantine for
CanElevateEffectiveMaxItemCount_WhenOverscanExceedsMax (#65962) which
was already fixed and unquarantined by #66291 on main. It also dropped
the DynamicContent_PrependItemsWhileScrolledToMiddle quarantine (#66308)
that was added by #66312 on main.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Use MutationObserver instead of scroll retry loop in NonZeroStartIndex test

Replace the retry-based ScrollToOffsetWithStabilization call with a
single scrollTop assignment followed by a MutationObserver that waits
for Blazor's DOM update to settle. This makes the test more
deterministic: it scrolls once and waits for the effect, rather than
retrying the scroll which could mask real bugs where the component
fails to handle the initial scroll correctly.

The MutationObserver waits for a 200ms quiet period after the last
DOM mutation, with a 2s fallback timeout. After that, scroll position
stabilization is verified, and the item index assertion is a hard
assert (not a retry loop).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-blazor Includes: Blazor, Razor Components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants