Skip to content

Commit 37b0a3c

Browse files
committed
Remove the "tax" on each test, we can return early from cleaning if supression was not requested.
1 parent 19793d7 commit 37b0a3c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace Microsoft.AspNetCore.Components.E2ETests.ServerRenderingTests;
1111

1212
public static class EnhancedNavigationTestUtil
1313
{
14+
private static bool _isSuppressed;
15+
1416
public static void SuppressEnhancedNavigation<TServerFixture>(ServerTestBase<TServerFixture> fixture, bool shouldSuppress, bool skipNavigation = false)
1517
where TServerFixture : ServerFixture
1618
{
@@ -43,12 +45,18 @@ public static void SuppressEnhancedNavigation<TServerFixture>(ServerTestBase<TSe
4345
var suppressEnhancedNavigation = ((IJavaScriptExecutor)browser).ExecuteScript($"return sessionStorage.getItem('suppress-enhanced-navigation-{testId}');");
4446
Assert.True(suppressEnhancedNavigation is not null && (string)suppressEnhancedNavigation == "true",
4547
"Expected 'suppress-enhanced-navigation' to be set in sessionStorage.");
48+
_isSuppressed = true;
4649
}
4750
}
4851

4952
public static void CleanEnhancedNavigationSuppression<TServerFixture>(ServerTestBase<TServerFixture> fixture, bool skipNavigation = false)
5053
where TServerFixture : ServerFixture
5154
{
55+
if (!_isSuppressed)
56+
{
57+
return;
58+
}
59+
5260
var browser = fixture.Browser;
5361

5462
try
@@ -84,6 +92,10 @@ public static void CleanEnhancedNavigationSuppression<TServerFixture>(ServerTest
8492
// This is expected in some tests, so we silently return
8593
return;
8694
}
95+
finally
96+
{
97+
_isSuppressed = false;
98+
}
8799
}
88100

89101
private static void NavigateToOrigin<TServerFixture>(ServerTestBase<TServerFixture> fixture)

0 commit comments

Comments
 (0)