Skip to content

[test-quarantine] Stabilize the NavigationLock overlapping navigation E2E test - #68267

Merged
kotlarmilos merged 4 commits into
dotnet:mainfrom
Vinoth2562000:Navigation_Lock
Sep 7, 2026
Merged

kotlarmilos merged 4 commits into
dotnet:mainfrom
Vinoth2562000:Navigation_Lock

Conversation

@Vinoth2562000

Copy link
Copy Markdown
Contributor

Quarantine Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests.ServerRoutingTest.NavigationLock_OverlappingNavigationsCancelExistingNavigations_HistoryNavigation

Description

This fixes the intermittent failure in NavigationLock_OverlappingNavigationsCancelExistingNavigations_HistoryNavigation.

The test failed primarily in the Blazor Server execution variant when browser history navigation started before the browser had finished registering the location-changing listener.

Root cause

Enabling internal navigation blocking causes NavigationLock to register its location-changing handler during OnAfterRenderAsync.

For Blazor Server, the browser-side listener is enabled through an asynchronous JS interop call. The test could call Browser.Navigate().Back() before the browser processed that call. The resulting popstate event bypassed the navigation lock, causing the test to observe an unexpected URI or fail to find the blocking controls.

Waiting after Browser.Navigate().Back() did not close the race because the history navigation could already have bypassed the lock.

Fix

Add a browser-side readiness acknowledgement to the test component and wait for it before starting history navigation:

  • Yield until the NavigationLock after-render callback registers the handler
  • Complete a JS interop round trip after browser listener registration is queued
  • Expose the acknowledgement through a hidden test element
  • Wait for that element before calling Browser.Navigate().Back()

The original navigation behavior and assertions are preserved. The test still verifies that overlapping history navigations cancel the existing navigation, log the cancellation, and continue to the expected URI.

Validation

Ran the test 100 consecutive times, and the test case passed successfully every time.

Fixes #61080 #65961

…ts.ServerRoutingTest.NavigationLock_OverlappingNavigationsCancelExistingNavigations_HistoryNavigation
…ts.ServerRoutingTest.NavigationLock_OverlappingNavigationsCancelExistingNavigations_HistoryNavigation
…ts.ServerRoutingTest.NavigationLock_OverlappingNavigationsCancelExistingNavigations_HistoryNavigation
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Aug 7, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @Vinoth2562000. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@Vinoth2562000 Vinoth2562000 changed the title Navigation lock Quarantine Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests.ServerRoutingTest.NavigationLock_OverlappingNavigationsCancelExistingNavigations_HistoryNavigation Aug 13, 2026
@VigneshNatarajan27 VigneshNatarajan27 added the area-blazor Includes: Blazor, Razor Components label Aug 13, 2026
@Vinoth2562000 Vinoth2562000 changed the title Quarantine Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests.ServerRoutingTest.NavigationLock_OverlappingNavigationsCancelExistingNavigations_HistoryNavigation [test-quarantine] Quarantine Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests.ServerRoutingTest.NavigationLock_OverlappingNavigationsCancelExistingNavigations_HistoryNavigation Aug 13, 2026
@Vinoth2562000 Vinoth2562000 changed the title [test-quarantine] Quarantine Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests.ServerRoutingTest.NavigationLock_OverlappingNavigationsCancelExistingNavigations_HistoryNavigation [test-quarantine] Stabilize the NavigationLock overlapping navigation E2E test Aug 13, 2026
@Vinoth2562000
Vinoth2562000 marked this pull request as ready for review August 20, 2026 11:20
Copilot AI lite review requested due to automatic review settings August 20, 2026 11:20
@Vinoth2562000
Vinoth2562000 requested a review from a team as a code owner August 20, 2026 11:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 Blazor E2E test ServerRoutingTest.NavigationLock_OverlappingNavigationsCancelExistingNavigations_HistoryNavigation by eliminating a race between enabling NavigationLock’s internal-navigation blocking and triggering browser history navigation in the test.

Changes:

  • Adds a browser-side “ready” acknowledgement to the ConfigurableNavigationLock test component via a hidden input updated after render using JS interop.
  • Updates the E2E test to wait for the readiness signal before calling Browser.Navigate().Back().
  • Removes the quarantine attribute from the server-execution subclass now that the flake is addressed.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Components/test/testassets/BasicTestApp/RouterTest/ConfigurableNavigationLock.razor Adds JS interop + hidden readiness element updated after render when internal blocking is toggled.
src/Components/test/E2ETest/Tests/RoutingTest.cs Waits for the readiness signal before performing history navigation to avoid the observed race.
src/Components/test/E2ETest/ServerExecutionTests/TestSubclasses.cs Un-quarantines the server-execution override for the stabilized test.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

…er 30 days of successful runs

Show more lines

@kotlarmilos kotlarmilos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@kotlarmilos
kotlarmilos merged commit 4b58ad5 into dotnet:main Sep 7, 2026
29 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 8, 2026
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 community-contribution Indicates that the PR has been added by a community member test-failure

Projects

None yet

5 participants