Skip to content

Commit 08c99cf

Browse files
committed
fixture.Navigate clears the storage, reading testId has to be done first.
1 parent b2e8441 commit 08c99cf

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/Components/test/E2ETest/ServerRenderingTests/EnhancedNavigationTestUtil.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ public static void SuppressEnhancedNavigation<TServerFixture>(ServerTestBase<TSe
1818
{
1919
var browser = fixture.Browser;
2020

21+
// Set the suppression flag - this will prevent enhanced navigation from being attached on the next navigation
22+
// and trigger detachment of currently attached enhanced navigation via the periodic check
23+
var testId = ((IJavaScriptExecutor)browser).ExecuteScript($"return sessionStorage.getItem('test-id')");
24+
if (testId == null)
25+
{
26+
throw new InvalidOperationException("Test ID not found in sessionStorage. Ensure that suppression is enabled by passing `supportEnhancedNavigationSuppression: true` to InitializeAsync.");
27+
}
28+
2129
if (!skipNavigation)
2230
{
2331
// Normally we need to navigate here first otherwise the browser isn't on the correct origin to access
@@ -26,13 +34,6 @@ public static void SuppressEnhancedNavigation<TServerFixture>(ServerTestBase<TSe
2634
browser.Equal("Hello", () => browser.Exists(By.TagName("h1")).Text);
2735
}
2836

29-
// Set the suppression flag - this will prevent enhanced navigation from being attached on the next navigation
30-
// and trigger detachment of currently attached enhanced navigation via the periodic check
31-
var testId = ((IJavaScriptExecutor)browser).ExecuteScript($"return sessionStorage.getItem('test-id')");
32-
if (testId == null)
33-
{
34-
throw new InvalidOperationException("Test ID not found in sessionStorage. Ensure that suppression is enabled by passing `supportEnhancedNavigationSuppression: true` to InitializeAsync.");
35-
}
3637
((IJavaScriptExecutor)browser).ExecuteScript($"sessionStorage.setItem('suppress-enhanced-navigation-{testId}', 'true')");
3738

3839
var suppressEnhancedNavigation = ((IJavaScriptExecutor)browser).ExecuteScript($"return sessionStorage.getItem('suppress-enhanced-navigation-{testId}');");

src/Components/test/E2ETest/ServerRenderingTests/NoInteractivityTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public NoInteractivityTest(
2525
}
2626

2727
public override Task InitializeAsync()
28-
=> InitializeAsync(BrowserFixture.StreamingContext, supportEnhancedNavigationSuppression: true);
28+
=> InitializeAsync(BrowserFixture.StreamingContext);
2929

3030
[Fact]
3131
public void NavigationManagerCanRefreshSSRPageWhenInteractivityNotPresent()

0 commit comments

Comments
 (0)