File tree Expand file tree Collapse file tree 3 files changed +22
-9
lines changed
src/Components/test/E2ETest Expand file tree Collapse file tree 3 files changed +22
-9
lines changed Original file line number Diff line number Diff line change 22// The .NET Foundation licenses this file to you under the MIT license.
33
44using Microsoft . AspNetCore . Components . E2ETest . Infrastructure . ServerFixtures ;
5+ using Microsoft . AspNetCore . Components . E2ETests . ServerRenderingTests ;
56using Microsoft . AspNetCore . E2ETesting ;
67using OpenQA . Selenium ;
78using Xunit . Abstractions ;
@@ -49,15 +50,7 @@ private void TryCleanSessionStorage()
4950 {
5051 try
5152 {
52- // only tests that suppress enhanced navigation will have these items set
53- var testId = ( ( IJavaScriptExecutor ) Browser ) . ExecuteScript ( $ "return sessionStorage.getItem('test-id')") ;
54- if ( testId == null )
55- {
56- return ;
57- }
58-
59- ( ( IJavaScriptExecutor ) Browser ) . ExecuteScript ( $ "sessionStorage.removeItem('test-id')") ;
60- ( ( IJavaScriptExecutor ) Browser ) . ExecuteScript ( $ "sessionStorage.removeItem('suppress-enhanced-navigation-{ testId } ')") ;
53+ EnhancedNavigationTestUtil . CleanEnhancedNavigationSuppression ( this ) ;
6154 }
6255 catch ( Exception ex )
6356 {
Original file line number Diff line number Diff line change @@ -317,6 +317,9 @@ public void RefreshCanFallBackOnFullPageReload(string renderMode)
317317 Browser . Navigate ( ) . Refresh ( ) ;
318318 Browser . Equal ( "Page with interactive components that navigate" , ( ) => Browser . Exists ( By . TagName ( "h1" ) ) . Text ) ;
319319
320+ // if we don't clean up the suppression, all subsequent navigations will be suppressed by default
321+ EnhancedNavigationTestUtil . CleanEnhancedNavigationSuppression ( this ) ;
322+
320323 // Normally, you shouldn't store references to elements because they could become stale references
321324 // after the page re-renders. However, we want to explicitly test that the element becomes stale
322325 // across renders to ensure that a full page reload occurs.
Original file line number Diff line number Diff line change @@ -47,6 +47,23 @@ public static void SuppressEnhancedNavigation<TServerFixture>(ServerTestBase<TSe
4747 "Expected 'suppress-enhanced-navigation' to be set in sessionStorage." ) ;
4848 }
4949 }
50+
51+ public static void CleanEnhancedNavigationSuppression < TServerFixture > ( ServerTestBase < TServerFixture > fixture )
52+ where TServerFixture : ServerFixture
53+ {
54+ var browser = fixture . Browser ;
55+
56+ // only tests that suppress enhanced navigation will have these items set, so it can throw
57+ var testId = ( ( IJavaScriptExecutor ) browser ) . ExecuteScript ( $ "return sessionStorage.getItem('test-id')") ;
58+ if ( testId == null )
59+ {
60+ return ;
61+ }
62+
63+ ( ( IJavaScriptExecutor ) browser ) . ExecuteScript ( $ "sessionStorage.removeItem('test-id')") ;
64+ ( ( IJavaScriptExecutor ) browser ) . ExecuteScript ( $ "sessionStorage.removeItem('suppress-enhanced-navigation-{ testId } ')") ;
65+ }
66+
5067 private static string GrantTestId ( IWebDriver browser )
5168 {
5269 var testId = Guid . NewGuid ( ) . ToString ( "N" ) [ ..8 ] ;
You can’t perform that action at this time.
0 commit comments