-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Improve enhanced navigation suppression in tests #63132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Improve enhanced navigation suppression in tests #63132
Conversation
… that don't support session storage at the same time. Allow single tests to request id assignment.
…ean it after each test.
604e029
to
8c5c3b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves enhanced navigation suppression in tests by making it persistent per test instance rather than per page. The changes address issues where enhanced navigation suppression was being lost after navigating away from a page, causing tests to fall back to enhanced navigation unexpectedly.
Key changes:
- Enhanced navigation suppression now uses test-specific IDs to maintain state across navigations
- Automatic cleanup of suppression flags when tests complete to prevent interference between tests
- Re-enabled previously disabled tests that were affected by navigation suppression issues
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
BrowserTestBase.cs | Made DisposeAsync virtual to allow overriding for cleanup |
Root.razor | Updated to use test-specific suppression keys and removed immediate cleanup |
App.razor | Updated to use test-specific suppression keys and removed immediate cleanup |
EnhancedNavigationTestUtil.cs | Added test ID generation, improved error handling, and cleanup functionality |
EnhancedNavigationTest.cs | Re-enabled quarantined tests and improved test order/cleanup |
ServerTestBase.cs | Added automatic cleanup of navigation suppression on test disposal |
src/Components/test/E2ETest/ServerRenderingTests/EnhancedNavigationTest.cs
Outdated
Show resolved
Hide resolved
@@ -1,6 +1,9 @@ | |||
@using Microsoft.AspNetCore.Components.Rendering | |||
@using System.Web | |||
@inject NavigationManager NavigationManager | |||
|
|||
<h1>Hello</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used in the enhanced navigation suppression method to check if session storage has conditions to get cleaned properly (page got loaded).
…n the index page.
One more thing to fix - the less frequent failure that happens when using
|
…rease timeouts for landing page assert that can be too short once in every 20 runs.
Suppress enhanced navigation once per test
Enhanced navigation suppression was per page, after navigating away we were falling back to enhanced navigation, regardless of the test settings. It's because we were treating the storage as temporary measure where we were setting the suppression flag and instantly removing it after reading it in blazor start function. For tests that never navigated away (did not re-trigger blazor boot function) it was enough but for other ones, not.
Description
EnhancedNavigationTestUtil.SuppressEnhancedNavigation
, they will get an exception like:SuppressEnhancedNavigation
appends to the exception message an instruction how to fix this situation.sessionStorage
, we have to have access to it. It's accessible only on loaded pages, so we chose the index page as the secure place for conducting the cleanup. To assure we're at the correct location we're checking for "Hello" h1 tag. Tests that useBasicTestApp
did not have that h1 element, this PR adds it. At the same time, this PR is changing expectations ofBasicTestApp
-based tests - they used to look for h1 that was embedded in<app>
element. The search criteria got more precise.Fixes #60875