Skip to content

[Blazor] Fix navigation lock tests #57372

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

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ public NavigationLockPrerenderingTest(
{
}

public override Task InitializeAsync()
=> InitializeAsync(BrowserFixture.RoutingTestContext);

[Fact]
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/57153")]
public void NavigationIsLockedAfterPrerendering()
Expand Down
3 changes: 3 additions & 0 deletions src/Components/test/E2ETest/Tests/RoutingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public RoutingTest(
{
}

public override Task InitializeAsync()
=> InitializeAsync(BrowserFixture.RoutingTestContext);

protected override void InitializeAsyncCore()
{
Navigate(ServerPathBase);
Expand Down
13 changes: 13 additions & 0 deletions src/Shared/E2ETesting/BrowserFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace Microsoft.AspNetCore.E2ETesting;
public class BrowserFixture : IAsyncLifetime
{
public static string StreamingContext { get; } = "streaming";
public static string RoutingTestContext { get; } = "routing";

private readonly ConcurrentDictionary<string, (IWebDriver browser, ILogs log)> _browsers = new();

public BrowserFixture(IMessageSink diagnosticsMessageSink)
Expand Down Expand Up @@ -123,6 +125,17 @@ private async Task DeleteBrowserUserProfileDirectoriesAsync()
{
var opts = new ChromeOptions();

if (context?.StartsWith(RoutingTestContext, StringComparison.Ordinal) == true)
{
// Enables WebDriver BiDi, which is required to allow the 'beforeunload' event
// to display an alert dialog. This is needed by some of our routing tests.
// See: https://w3c.github.io/webdriver/#user-prompts
// We could consider making this the default for all tests when the BiDi spec
// becomes standard (it's in draft at the time of writing).
// See: https://w3c.github.io/webdriver-bidi/
opts.UseWebSocketUrl = true;
}

if (context?.StartsWith(StreamingContext, StringComparison.Ordinal) == true)
{
// Tells Selenium not to wait until the page navigation has completed before continuing with the tests
Expand Down
Loading