Skip to content

Commit 48a0721

Browse files
Fix navigation lock tests (#57372)
1 parent 8fd758f commit 48a0721

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/Components/test/E2ETest/ServerExecutionTests/NavigationLockPrerenderingTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public NavigationLockPrerenderingTest(
2121
{
2222
}
2323

24+
public override Task InitializeAsync()
25+
=> InitializeAsync(BrowserFixture.RoutingTestContext);
26+
2427
[Fact]
2528
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/57153")]
2629
public void NavigationIsLockedAfterPrerendering()

src/Components/test/E2ETest/Tests/RoutingTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ public RoutingTest(
2626
{
2727
}
2828

29+
public override Task InitializeAsync()
30+
=> InitializeAsync(BrowserFixture.RoutingTestContext);
31+
2932
protected override void InitializeAsyncCore()
3033
{
3134
Navigate(ServerPathBase);

src/Shared/E2ETesting/BrowserFixture.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ namespace Microsoft.AspNetCore.E2ETesting;
1414
public class BrowserFixture : IAsyncLifetime
1515
{
1616
public static string StreamingContext { get; } = "streaming";
17+
public static string RoutingTestContext { get; } = "routing";
18+
1719
private readonly ConcurrentDictionary<string, (IWebDriver browser, ILogs log)> _browsers = new();
1820

1921
public BrowserFixture(IMessageSink diagnosticsMessageSink)
@@ -123,6 +125,17 @@ private async Task DeleteBrowserUserProfileDirectoriesAsync()
123125
{
124126
var opts = new ChromeOptions();
125127

128+
if (context?.StartsWith(RoutingTestContext, StringComparison.Ordinal) == true)
129+
{
130+
// Enables WebDriver BiDi, which is required to allow the 'beforeunload' event
131+
// to display an alert dialog. This is needed by some of our routing tests.
132+
// See: https://w3c.github.io/webdriver/#user-prompts
133+
// We could consider making this the default for all tests when the BiDi spec
134+
// becomes standard (it's in draft at the time of writing).
135+
// See: https://w3c.github.io/webdriver-bidi/
136+
opts.UseWebSocketUrl = true;
137+
}
138+
126139
if (context?.StartsWith(StreamingContext, StringComparison.Ordinal) == true)
127140
{
128141
// Tells Selenium not to wait until the page navigation has completed before continuing with the tests

0 commit comments

Comments
 (0)