Skip to content

[Components][E2E] Stabilize NonZeroStartIndex_ScrollToMiddleThenMeasure test setup#66290

Merged
ilonatommy merged 6 commits intodotnet:mainfrom
ilonatommy:fix/servervirt-nonzero-startindex-stabilization
Apr 17, 2026
Merged

[Components][E2E] Stabilize NonZeroStartIndex_ScrollToMiddleThenMeasure test setup#66290
ilonatommy merged 6 commits intodotnet:mainfrom
ilonatommy:fix/servervirt-nonzero-startindex-stabilization

Conversation

@ilonatommy
Copy link
Copy Markdown
Member

@ilonatommy ilonatommy commented Apr 13, 2026

Summary

Fix the flaky ServerVirtualizationTest.NonZeroStartIndex_ScrollToMiddleThenMeasure E2E test by replacing the retry-based scroll pattern with a deterministic MutationObserver approach.

Why

he test was flaky in server mode because it set scrollTop and immediately checked rendered items, but the async virtualization update (which round-trips through SignalR) hadn't finished yet.

Recent failure: build 1375485 (April 12, 2026)

  1. NonZeroStartIndex_ScrollToMiddleThenMeasure — MutationObserver instead of scroll retry

    • Sets scrollTop to scrollHeight / 2 once via ExecuteAsyncScript
    • Uses a JS MutationObserver to wait for Blazor's DOM update to settle (200ms quiet period after last mutation, 2s fallback)
    • Calls WaitForScrollStabilization() to confirm the scroll position stopped bouncing
    • Uses a hard Assert.True (not a retry loop) to verify items with index > 50 are visible
    • Changed from virtual to non-virtual — the fix is in the base class, no server-specific override needed
  2. ScrollToOffsetWithStabilization — generalized into two overloads

    • New overload accepts Func<bool> itemCheckPredicate for custom scroll-success criteria
    • Original overload delegates to the new one (used by other tests)

Fixes #66119.

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 ilonatommy force-pushed the fix/servervirt-nonzero-startindex-stabilization branch from 04ec60f to 67ea598 Compare April 13, 2026 10:16
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 setup phase of the ServerVirtualizationTest.NonZeroStartIndex_ScrollToMiddleThenMeasure E2E test by switching to a retry-based scroll-and-verify pattern, reducing flakiness from async virtualization updates in server mode.

Changes:

  • Computes the target mid-scroll offset up front (scrollHeight / 2).
  • Retries both applying scrollTop and confirming the rendered range advanced (idx > 50) inside a single Browser.True() polling loop.
  • Defers WaitForScrollStabilization() until after the rendered range has reliably advanced.

Comment thread src/Components/test/E2ETest/Tests/VirtualizationTest.cs Outdated
Comment thread src/Components/test/E2ETest/Tests/VirtualizationTest.cs Outdated
ilonatommy and others added 2 commits April 14, 2026 12:05
…ization 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>
…ntined

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ilonatommy ilonatommy self-assigned this Apr 14, 2026
ilonatommy and others added 2 commits April 14, 2026 15:53
…e, restore missing PrependItems quarantine

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ilonatommy ilonatommy marked this pull request as draft April 15, 2026 09:35
@ilonatommy ilonatommy marked this pull request as draft April 15, 2026 09:35
…x 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>
@ilonatommy ilonatommy marked this pull request as ready for review April 15, 2026 12:35
@ilonatommy ilonatommy merged commit 9c820d6 into dotnet:main Apr 17, 2026
25 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the 11.0-preview4 milestone Apr 17, 2026
github-actions Bot added a commit that referenced this pull request Apr 18, 2026
…leThenMeasure

Test started failing again after being unquarantined in PR #66290.
Re-quarantining using the original issue #66119.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
wtgodbe added a commit that referenced this pull request Apr 20, 2026
…Index_ScrollToMiddleThenMeasure (#66359)

* Re-quarantine ServerVirtualizationTest.NonZeroStartIndex_ScrollToMiddleThenMeasure

Test started failing again after being unquarantined in PR #66290.
Re-quarantining using the original issue #66119.

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

* Fix ServerVirtualizationTest quarantine method declaration

Agent-Logs-Url: https://github.com/dotnet/aspnetcore/sessions/0d16c75a-b957-40e6-8d3e-f7af5396923d

Co-authored-by: wtgodbe <14283640+wtgodbe@users.noreply.github.com>

* Make virtualization test overridable for server quarantine

Agent-Logs-Url: https://github.com/dotnet/aspnetcore/sessions/0d16c75a-b957-40e6-8d3e-f7af5396923d

Co-authored-by: wtgodbe <14283640+wtgodbe@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: wtgodbe <14283640+wtgodbe@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.

Quarantine ServerVirtualizationTest.NonZeroStartIndex_ScrollToMiddleThenMeasure

3 participants